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 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkDOM_DEFINED |
michael@0 | 11 | #define SkDOM_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkChunkAlloc.h" |
michael@0 | 14 | #include "SkScalar.h" |
michael@0 | 15 | #include "SkTemplates.h" |
michael@0 | 16 | |
michael@0 | 17 | struct SkDOMNode; |
michael@0 | 18 | struct SkDOMAttr; |
michael@0 | 19 | |
michael@0 | 20 | class SkDOM { |
michael@0 | 21 | public: |
michael@0 | 22 | SkDOM(); |
michael@0 | 23 | ~SkDOM(); |
michael@0 | 24 | |
michael@0 | 25 | typedef SkDOMNode Node; |
michael@0 | 26 | typedef SkDOMAttr Attr; |
michael@0 | 27 | |
michael@0 | 28 | /** Returns null on failure |
michael@0 | 29 | */ |
michael@0 | 30 | const Node* build(const char doc[], size_t len); |
michael@0 | 31 | const Node* copy(const SkDOM& dom, const Node* node); |
michael@0 | 32 | |
michael@0 | 33 | const Node* getRootNode() const; |
michael@0 | 34 | |
michael@0 | 35 | enum Type { |
michael@0 | 36 | kElement_Type, |
michael@0 | 37 | kText_Type |
michael@0 | 38 | }; |
michael@0 | 39 | Type getType(const Node*) const; |
michael@0 | 40 | |
michael@0 | 41 | const char* getName(const Node*) const; |
michael@0 | 42 | const Node* getFirstChild(const Node*, const char elem[] = NULL) const; |
michael@0 | 43 | const Node* getNextSibling(const Node*, const char elem[] = NULL) const; |
michael@0 | 44 | |
michael@0 | 45 | const char* findAttr(const Node*, const char attrName[]) const; |
michael@0 | 46 | const Attr* getFirstAttr(const Node*) const; |
michael@0 | 47 | const Attr* getNextAttr(const Node*, const Attr*) const; |
michael@0 | 48 | const char* getAttrName(const Node*, const Attr*) const; |
michael@0 | 49 | const char* getAttrValue(const Node*, const Attr*) const; |
michael@0 | 50 | |
michael@0 | 51 | // helpers for walking children |
michael@0 | 52 | int countChildren(const Node* node, const char elem[] = NULL) const; |
michael@0 | 53 | |
michael@0 | 54 | // helpers for calling SkParse |
michael@0 | 55 | bool findS32(const Node*, const char name[], int32_t* value) const; |
michael@0 | 56 | bool findScalars(const Node*, const char name[], SkScalar value[], int count) const; |
michael@0 | 57 | bool findHex(const Node*, const char name[], uint32_t* value) const; |
michael@0 | 58 | bool findBool(const Node*, const char name[], bool*) const; |
michael@0 | 59 | int findList(const Node*, const char name[], const char list[]) const; |
michael@0 | 60 | |
michael@0 | 61 | bool findScalar(const Node* node, const char name[], SkScalar value[]) const |
michael@0 | 62 | { |
michael@0 | 63 | return this->findScalars(node, name, value, 1); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | bool hasAttr(const Node*, const char name[], const char value[]) const; |
michael@0 | 67 | bool hasS32(const Node*, const char name[], int32_t value) const; |
michael@0 | 68 | bool hasScalar(const Node*, const char name[], SkScalar value) const; |
michael@0 | 69 | bool hasHex(const Node*, const char name[], uint32_t value) const; |
michael@0 | 70 | bool hasBool(const Node*, const char name[], bool value) const; |
michael@0 | 71 | |
michael@0 | 72 | class AttrIter { |
michael@0 | 73 | public: |
michael@0 | 74 | AttrIter(const class SkDOM&, const Node*); |
michael@0 | 75 | const char* next(const char** value); |
michael@0 | 76 | private: |
michael@0 | 77 | const Attr* fAttr; |
michael@0 | 78 | const Attr* fStop; |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | SkDEBUGCODE(void dump(const Node* node = NULL, int tabLevel = 0) const;) |
michael@0 | 82 | SkDEBUGCODE(static void UnitTest();) |
michael@0 | 83 | |
michael@0 | 84 | private: |
michael@0 | 85 | SkChunkAlloc fAlloc; |
michael@0 | 86 | Node* fRoot; |
michael@0 | 87 | friend class AttrIter; |
michael@0 | 88 | friend class SkDOMParser; |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | #endif |