Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef SkOTUtils_DEFINED |
michael@0 | 9 | #define SkOTUtils_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkOTTableTypes.h" |
michael@0 | 12 | #include "SkOTTable_name.h" |
michael@0 | 13 | #include "SkTypeface.h" |
michael@0 | 14 | |
michael@0 | 15 | class SkData; |
michael@0 | 16 | class SkStream; |
michael@0 | 17 | |
michael@0 | 18 | struct SkOTUtils { |
michael@0 | 19 | /** |
michael@0 | 20 | * Calculates the OpenType checksum for data. |
michael@0 | 21 | */ |
michael@0 | 22 | static uint32_t CalcTableChecksum(SK_OT_ULONG *data, size_t length); |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * Renames an sfnt font. On failure (invalid data or not an sfnt font) |
michael@0 | 26 | * returns NULL. |
michael@0 | 27 | * |
michael@0 | 28 | * Essentially, this removes any existing 'name' table and replaces it |
michael@0 | 29 | * with a new one in which FontFamilyName, FontSubfamilyName, |
michael@0 | 30 | * UniqueFontIdentifier, FullFontName, and PostscriptName are fontName. |
michael@0 | 31 | * |
michael@0 | 32 | * The new 'name' table records will be written with the Windows, |
michael@0 | 33 | * UnicodeBMPUCS2, and English_UnitedStates settings. |
michael@0 | 34 | * |
michael@0 | 35 | * fontName and fontNameLen must be specified in terms of ASCII chars. |
michael@0 | 36 | */ |
michael@0 | 37 | static SkData* RenameFont(SkStream* fontData, const char* fontName, int fontNameLen); |
michael@0 | 38 | |
michael@0 | 39 | /** An implementation of LocalizedStrings which obtains it's data from a 'name' table. */ |
michael@0 | 40 | class LocalizedStrings_NameTable : public SkTypeface::LocalizedStrings { |
michael@0 | 41 | public: |
michael@0 | 42 | /** Takes ownership of the nameTableData and will free it with SK_DELETE. */ |
michael@0 | 43 | LocalizedStrings_NameTable(SkOTTableName* nameTableData, |
michael@0 | 44 | SkOTTableName::Record::NameID::Predefined::Value types[], |
michael@0 | 45 | int typesCount) |
michael@0 | 46 | : fTypes(types), fTypesCount(typesCount), fTypesIndex(0) |
michael@0 | 47 | , fNameTableData(nameTableData), fFamilyNameIter(*nameTableData, fTypes[fTypesIndex]) |
michael@0 | 48 | { } |
michael@0 | 49 | |
michael@0 | 50 | /** Creates an iterator over all the family names in the 'name' table of a typeface. |
michael@0 | 51 | * If no valid 'name' table can be found, returns NULL. |
michael@0 | 52 | */ |
michael@0 | 53 | static LocalizedStrings_NameTable* CreateForFamilyNames(const SkTypeface& typeface); |
michael@0 | 54 | |
michael@0 | 55 | virtual bool next(SkTypeface::LocalizedString* localizedString) SK_OVERRIDE; |
michael@0 | 56 | private: |
michael@0 | 57 | static SkOTTableName::Record::NameID::Predefined::Value familyNameTypes[3]; |
michael@0 | 58 | |
michael@0 | 59 | SkOTTableName::Record::NameID::Predefined::Value* fTypes; |
michael@0 | 60 | int fTypesCount; |
michael@0 | 61 | int fTypesIndex; |
michael@0 | 62 | SkAutoTDeleteArray<SkOTTableName> fNameTableData; |
michael@0 | 63 | SkOTTableName::Iterator fFamilyNameIter; |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | /** An implementation of LocalizedStrings which has one name. */ |
michael@0 | 67 | class LocalizedStrings_SingleName : public SkTypeface::LocalizedStrings { |
michael@0 | 68 | public: |
michael@0 | 69 | LocalizedStrings_SingleName(SkString name, SkString language) |
michael@0 | 70 | : fName(name), fLanguage(language), fHasNext(true) |
michael@0 | 71 | { } |
michael@0 | 72 | |
michael@0 | 73 | virtual bool next(SkTypeface::LocalizedString* localizedString) SK_OVERRIDE { |
michael@0 | 74 | localizedString->fString = fName; |
michael@0 | 75 | localizedString->fLanguage = fLanguage; |
michael@0 | 76 | |
michael@0 | 77 | bool hadNext = fHasNext; |
michael@0 | 78 | fHasNext = false; |
michael@0 | 79 | return hadNext; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | private: |
michael@0 | 83 | SkString fName; |
michael@0 | 84 | SkString fLanguage; |
michael@0 | 85 | bool fHasNext; |
michael@0 | 86 | }; |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | #endif |