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