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 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 SkPDFImage_DEFINED |
michael@0 | 11 | #define SkPDFImage_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkPicture.h" |
michael@0 | 14 | #include "SkPDFDevice.h" |
michael@0 | 15 | #include "SkPDFStream.h" |
michael@0 | 16 | #include "SkPDFTypes.h" |
michael@0 | 17 | #include "SkRefCnt.h" |
michael@0 | 18 | |
michael@0 | 19 | class SkBitmap; |
michael@0 | 20 | class SkPDFCatalog; |
michael@0 | 21 | struct SkIRect; |
michael@0 | 22 | |
michael@0 | 23 | /** \class SkPDFImage |
michael@0 | 24 | |
michael@0 | 25 | An image XObject. |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | // We could play the same trick here as is done in SkPDFGraphicState, storing |
michael@0 | 29 | // a copy of the Bitmap object (not the pixels), the pixel generation number, |
michael@0 | 30 | // and settings used from the paint to canonicalize image objects. |
michael@0 | 31 | class SkPDFImage : public SkPDFStream { |
michael@0 | 32 | public: |
michael@0 | 33 | /** Create a new Image XObject to represent the passed bitmap. |
michael@0 | 34 | * @param bitmap The image to encode. |
michael@0 | 35 | * @param srcRect The rectangle to cut out of bitmap. |
michael@0 | 36 | * @param paint Used to calculate alpha, masks, etc. |
michael@0 | 37 | * @return The image XObject or NUll if there is nothing to draw for |
michael@0 | 38 | * the given parameters. |
michael@0 | 39 | */ |
michael@0 | 40 | static SkPDFImage* CreateImage(const SkBitmap& bitmap, |
michael@0 | 41 | const SkIRect& srcRect, |
michael@0 | 42 | SkPicture::EncodeBitmap encoder); |
michael@0 | 43 | |
michael@0 | 44 | virtual ~SkPDFImage(); |
michael@0 | 45 | |
michael@0 | 46 | /** Add a Soft Mask (alpha or shape channel) to the image. Refs mask. |
michael@0 | 47 | * @param mask A gray scale image representing the mask. |
michael@0 | 48 | * @return The mask argument is returned. |
michael@0 | 49 | */ |
michael@0 | 50 | SkPDFImage* addSMask(SkPDFImage* mask); |
michael@0 | 51 | |
michael@0 | 52 | bool isEmpty() { |
michael@0 | 53 | return fSrcRect.isEmpty(); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | // The SkPDFObject interface. |
michael@0 | 57 | virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
michael@0 | 58 | SkTSet<SkPDFObject*>* newResourceObjects); |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | SkBitmap fBitmap; |
michael@0 | 62 | bool fIsAlpha; |
michael@0 | 63 | SkIRect fSrcRect; |
michael@0 | 64 | SkPicture::EncodeBitmap fEncoder; |
michael@0 | 65 | bool fStreamValid; |
michael@0 | 66 | |
michael@0 | 67 | SkTDArray<SkPDFObject*> fResources; |
michael@0 | 68 | |
michael@0 | 69 | /** Create a PDF image XObject. Entries for the image properties are |
michael@0 | 70 | * automatically added to the stream dictionary. |
michael@0 | 71 | * @param stream The image stream. May be NULL. Otherwise, this |
michael@0 | 72 | * (instead of the input bitmap) will be used as the |
michael@0 | 73 | * PDF's content stream, possibly with lossless encoding. |
michael@0 | 74 | * @param bitmap The image. If a stream is not given, its color data |
michael@0 | 75 | * will be used as the image. If a stream is given, this |
michael@0 | 76 | * is used for configuration only. |
michael@0 | 77 | * @param isAlpha Whether or not this is the alpha of an image. |
michael@0 | 78 | * @param srcRect The clipping applied to bitmap before generating |
michael@0 | 79 | * imageData. |
michael@0 | 80 | * @param encoder A function used to encode the bitmap for compression. |
michael@0 | 81 | * May be NULL. |
michael@0 | 82 | */ |
michael@0 | 83 | SkPDFImage(SkStream* stream, const SkBitmap& bitmap, bool isAlpha, |
michael@0 | 84 | const SkIRect& srcRect, SkPicture::EncodeBitmap encoder); |
michael@0 | 85 | |
michael@0 | 86 | /** Copy constructor, used to generate substitutes. |
michael@0 | 87 | * @param image The SkPDFImage to copy. |
michael@0 | 88 | */ |
michael@0 | 89 | SkPDFImage(SkPDFImage& pdfImage); |
michael@0 | 90 | |
michael@0 | 91 | // Populate the stream dictionary. This method returns false if |
michael@0 | 92 | // fSubstitute should be used. |
michael@0 | 93 | virtual bool populate(SkPDFCatalog* catalog); |
michael@0 | 94 | |
michael@0 | 95 | typedef SkPDFStream INHERITED; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | #endif |