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 2007 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 IMAGE_CODEC_BMPDECODERHELPER_H__ |
michael@0 | 11 | #define IMAGE_CODEC_BMPDECODERHELPER_H__ |
michael@0 | 12 | |
michael@0 | 13 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 14 | // this section is my current "glue" between google3 code and android. |
michael@0 | 15 | // will be fixed soon |
michael@0 | 16 | |
michael@0 | 17 | #include "SkTypes.h" |
michael@0 | 18 | #include <limits.h> |
michael@0 | 19 | #define DISALLOW_EVIL_CONSTRUCTORS(name) |
michael@0 | 20 | #define CHECK(predicate) SkASSERT(predicate) |
michael@0 | 21 | typedef uint8_t uint8; |
michael@0 | 22 | typedef uint32_t uint32; |
michael@0 | 23 | |
michael@0 | 24 | template <typename T> class scoped_array { |
michael@0 | 25 | private: |
michael@0 | 26 | T* ptr_; |
michael@0 | 27 | scoped_array(scoped_array const&); |
michael@0 | 28 | scoped_array& operator=(const scoped_array&); |
michael@0 | 29 | |
michael@0 | 30 | public: |
michael@0 | 31 | explicit scoped_array(T* p = 0) : ptr_(p) {} |
michael@0 | 32 | ~scoped_array() { |
michael@0 | 33 | delete[] ptr_; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | void reset(T* p = 0) { |
michael@0 | 37 | if (p != ptr_) { |
michael@0 | 38 | delete[] ptr_; |
michael@0 | 39 | ptr_ = p; |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | T& operator[](int i) const { |
michael@0 | 44 | return ptr_[i]; |
michael@0 | 45 | } |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 49 | |
michael@0 | 50 | namespace image_codec { |
michael@0 | 51 | |
michael@0 | 52 | class BmpDecoderCallback { |
michael@0 | 53 | public: |
michael@0 | 54 | BmpDecoderCallback() { } |
michael@0 | 55 | virtual ~BmpDecoderCallback() {} |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * This is called once for an image. It is passed the width and height and |
michael@0 | 59 | * should return the address of a buffer that is large enough to store |
michael@0 | 60 | * all of the resulting pixels (widht * height * 3 bytes). If it returns NULL, |
michael@0 | 61 | * then the decoder will abort, but return true, as the caller has received |
michael@0 | 62 | * valid dimensions. |
michael@0 | 63 | */ |
michael@0 | 64 | virtual uint8* SetSize(int width, int height) = 0; |
michael@0 | 65 | |
michael@0 | 66 | private: |
michael@0 | 67 | DISALLOW_EVIL_CONSTRUCTORS(BmpDecoderCallback); |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | class BmpDecoderHelper { |
michael@0 | 71 | public: |
michael@0 | 72 | BmpDecoderHelper() { } |
michael@0 | 73 | ~BmpDecoderHelper() { } |
michael@0 | 74 | bool DecodeImage(const char* data, |
michael@0 | 75 | size_t len, |
michael@0 | 76 | int max_pixels, |
michael@0 | 77 | BmpDecoderCallback* callback); |
michael@0 | 78 | |
michael@0 | 79 | private: |
michael@0 | 80 | DISALLOW_EVIL_CONSTRUCTORS(BmpDecoderHelper); |
michael@0 | 81 | |
michael@0 | 82 | void DoRLEDecode(); |
michael@0 | 83 | void DoStandardDecode(); |
michael@0 | 84 | void PutPixel(int x, int y, uint8 col); |
michael@0 | 85 | |
michael@0 | 86 | int GetInt(); |
michael@0 | 87 | int GetShort(); |
michael@0 | 88 | uint8 GetByte(); |
michael@0 | 89 | int CalcShiftRight(uint32 mask); |
michael@0 | 90 | int CalcShiftLeft(uint32 mask); |
michael@0 | 91 | |
michael@0 | 92 | const uint8* data_; |
michael@0 | 93 | size_t pos_; |
michael@0 | 94 | size_t len_; |
michael@0 | 95 | int width_; |
michael@0 | 96 | int height_; |
michael@0 | 97 | int bpp_; |
michael@0 | 98 | int pixelPad_; |
michael@0 | 99 | int rowPad_; |
michael@0 | 100 | scoped_array<uint8> colTab_; |
michael@0 | 101 | uint32 redBits_; |
michael@0 | 102 | uint32 greenBits_; |
michael@0 | 103 | uint32 blueBits_; |
michael@0 | 104 | int redShiftRight_; |
michael@0 | 105 | int greenShiftRight_; |
michael@0 | 106 | int blueShiftRight_; |
michael@0 | 107 | int redShiftLeft_; |
michael@0 | 108 | int greenShiftLeft_; |
michael@0 | 109 | int blueShiftLeft_; |
michael@0 | 110 | uint8* output_; |
michael@0 | 111 | bool inverted_; |
michael@0 | 112 | }; |
michael@0 | 113 | |
michael@0 | 114 | } // namespace |
michael@0 | 115 | |
michael@0 | 116 | #endif |