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 | * Copyright 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | |
michael@0 | 9 | #include "SkDeviceProfile.h" |
michael@0 | 10 | #include "SkThread.h" |
michael@0 | 11 | |
michael@0 | 12 | #define DEFAULT_GAMMAEXP 2.2f |
michael@0 | 13 | #define DEFAULT_CONTRASTSCALE 0.5f |
michael@0 | 14 | #define DEFAULT_LCDCONFIG SkDeviceProfile::kNone_LCDConfig |
michael@0 | 15 | #define DEFAULT_FONTHINTLEVEL SkDeviceProfile::kSlight_FontHintLevel |
michael@0 | 16 | |
michael@0 | 17 | static float pin(float value, float min, float max) { |
michael@0 | 18 | if (value < min) { |
michael@0 | 19 | value = min; |
michael@0 | 20 | } else if (value > max) { |
michael@0 | 21 | value = max; |
michael@0 | 22 | } |
michael@0 | 23 | return value; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | SkDeviceProfile::SkDeviceProfile(float gammaExp, float contrast, |
michael@0 | 27 | LCDConfig config, FontHintLevel level) { |
michael@0 | 28 | fGammaExponent = pin(gammaExp, 0, 10); |
michael@0 | 29 | fContrastScale = pin(contrast, 0, 1); |
michael@0 | 30 | fLCDConfig = config; |
michael@0 | 31 | fFontHintLevel = level; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | void SkDeviceProfile::generateTableForLuminanceByte(U8CPU lumByte, |
michael@0 | 35 | uint8_t table[256]) const { |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 39 | |
michael@0 | 40 | SkDeviceProfile* SkDeviceProfile::Create(float gammaExp, |
michael@0 | 41 | float contrast, |
michael@0 | 42 | LCDConfig config, |
michael@0 | 43 | FontHintLevel level) { |
michael@0 | 44 | return SkNEW_ARGS(SkDeviceProfile, (gammaExp, contrast, config, level)); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | SK_DECLARE_STATIC_MUTEX(gMutex); |
michael@0 | 48 | static SkDeviceProfile* gDefaultProfile; |
michael@0 | 49 | static SkDeviceProfile* gGlobalProfile; |
michael@0 | 50 | |
michael@0 | 51 | SkDeviceProfile* SkDeviceProfile::GetDefault() { |
michael@0 | 52 | SkAutoMutexAcquire amc(gMutex); |
michael@0 | 53 | |
michael@0 | 54 | if (NULL == gDefaultProfile) { |
michael@0 | 55 | gDefaultProfile = SkDeviceProfile::Create(DEFAULT_GAMMAEXP, |
michael@0 | 56 | DEFAULT_CONTRASTSCALE, |
michael@0 | 57 | DEFAULT_LCDCONFIG, |
michael@0 | 58 | DEFAULT_FONTHINTLEVEL); |
michael@0 | 59 | } |
michael@0 | 60 | return gDefaultProfile; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | SkDeviceProfile* SkDeviceProfile::RefGlobal() { |
michael@0 | 64 | SkAutoMutexAcquire amc(gMutex); |
michael@0 | 65 | |
michael@0 | 66 | if (NULL == gGlobalProfile) { |
michael@0 | 67 | gGlobalProfile = SkDeviceProfile::GetDefault(); |
michael@0 | 68 | } |
michael@0 | 69 | gGlobalProfile->ref(); |
michael@0 | 70 | return gGlobalProfile; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | void SkDeviceProfile::SetGlobal(SkDeviceProfile* profile) { |
michael@0 | 74 | SkAutoMutexAcquire amc(gMutex); |
michael@0 | 75 | |
michael@0 | 76 | SkRefCnt_SafeAssign(gGlobalProfile, profile); |
michael@0 | 77 | } |