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 2010 Google Inc. |
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 SkPDFStream_DEFINED |
michael@0 | 11 | #define SkPDFStream_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkPDFTypes.h" |
michael@0 | 14 | #include "SkRefCnt.h" |
michael@0 | 15 | #include "SkStream.h" |
michael@0 | 16 | #include "SkTemplates.h" |
michael@0 | 17 | |
michael@0 | 18 | class SkPDFCatalog; |
michael@0 | 19 | |
michael@0 | 20 | /** \class SkPDFStream |
michael@0 | 21 | |
michael@0 | 22 | A stream object in a PDF. Note, all streams must be indirect objects (via |
michael@0 | 23 | SkObjRef). |
michael@0 | 24 | TODO(vandebo): SkStream should be replaced by SkStreamRewindable when that |
michael@0 | 25 | is feasible. |
michael@0 | 26 | */ |
michael@0 | 27 | class SkPDFStream : public SkPDFDict { |
michael@0 | 28 | SK_DECLARE_INST_COUNT(SkPDFStream) |
michael@0 | 29 | public: |
michael@0 | 30 | /** Create a PDF stream. A Length entry is automatically added to the |
michael@0 | 31 | * stream dictionary. The stream may be retained (stream->ref() may be |
michael@0 | 32 | * called) so its contents must not be changed after calling this. |
michael@0 | 33 | * @param data The data part of the stream. |
michael@0 | 34 | */ |
michael@0 | 35 | explicit SkPDFStream(SkData* data); |
michael@0 | 36 | /** Deprecated constructor. */ |
michael@0 | 37 | explicit SkPDFStream(SkStream* stream); |
michael@0 | 38 | /** Create a PDF stream with the same content and dictionary entries |
michael@0 | 39 | * as the passed one. |
michael@0 | 40 | */ |
michael@0 | 41 | explicit SkPDFStream(const SkPDFStream& pdfStream); |
michael@0 | 42 | virtual ~SkPDFStream(); |
michael@0 | 43 | |
michael@0 | 44 | // The SkPDFObject interface. |
michael@0 | 45 | virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
michael@0 | 46 | bool indirect); |
michael@0 | 47 | virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
michael@0 | 48 | |
michael@0 | 49 | protected: |
michael@0 | 50 | enum State { |
michael@0 | 51 | kUnused_State, //!< The stream hasn't been requested yet. |
michael@0 | 52 | kNoCompression_State, //!< The stream's been requested in an |
michael@0 | 53 | // uncompressed form. |
michael@0 | 54 | kCompressed_State, //!< The stream's already been compressed. |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | /* Create a PDF stream with no data. The setData method must be called to |
michael@0 | 58 | * set the data. |
michael@0 | 59 | */ |
michael@0 | 60 | SkPDFStream(); |
michael@0 | 61 | |
michael@0 | 62 | // Populate the stream dictionary. This method returns false if |
michael@0 | 63 | // fSubstitute should be used. |
michael@0 | 64 | virtual bool populate(SkPDFCatalog* catalog); |
michael@0 | 65 | |
michael@0 | 66 | void setSubstitute(SkPDFStream* stream) { |
michael@0 | 67 | fSubstitute.reset(stream); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | SkPDFStream* getSubstitute() { |
michael@0 | 71 | return fSubstitute.get(); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | void setData(SkData* data); |
michael@0 | 75 | void setData(SkStream* stream); |
michael@0 | 76 | |
michael@0 | 77 | SkStream* getData() { |
michael@0 | 78 | return fData.get(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | void setState(State state) { |
michael@0 | 82 | fState = state; |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | State getState() { |
michael@0 | 86 | return fState; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | private: |
michael@0 | 90 | // Indicates what form (or if) the stream has been requested. |
michael@0 | 91 | State fState; |
michael@0 | 92 | |
michael@0 | 93 | // TODO(vandebo): Use SkData (after removing deprecated constructor). |
michael@0 | 94 | SkAutoTUnref<SkStream> fData; |
michael@0 | 95 | SkAutoTUnref<SkPDFStream> fSubstitute; |
michael@0 | 96 | |
michael@0 | 97 | typedef SkPDFDict INHERITED; |
michael@0 | 98 | }; |
michael@0 | 99 | |
michael@0 | 100 | #endif |