intl/icu/source/common/servslkf.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 (C) 2001-2005, International Business Machines Corporation and *
michael@0 4 * others. All Rights Reserved. *
michael@0 5 *******************************************************************************
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 */
michael@0 9 #include "unicode/utypes.h"
michael@0 10
michael@0 11 #if !UCONFIG_NO_SERVICE
michael@0 12
michael@0 13 #include "unicode/resbund.h"
michael@0 14 #include "uresimp.h"
michael@0 15 #include "cmemory.h"
michael@0 16 #include "servloc.h"
michael@0 17 #include "ustrfmt.h"
michael@0 18 #include "uhash.h"
michael@0 19 #include "charstr.h"
michael@0 20 #include "ucln_cmn.h"
michael@0 21 #include "uassert.h"
michael@0 22
michael@0 23 #define UNDERSCORE_CHAR ((UChar)0x005f)
michael@0 24 #define AT_SIGN_CHAR ((UChar)64)
michael@0 25 #define PERIOD_CHAR ((UChar)46)
michael@0 26
michael@0 27 U_NAMESPACE_BEGIN
michael@0 28
michael@0 29 /*
michael@0 30 ******************************************************************
michael@0 31 */
michael@0 32
michael@0 33 SimpleLocaleKeyFactory::SimpleLocaleKeyFactory(UObject* objToAdopt,
michael@0 34 const UnicodeString& locale,
michael@0 35 int32_t kind,
michael@0 36 int32_t coverage)
michael@0 37 : LocaleKeyFactory(coverage)
michael@0 38 , _obj(objToAdopt)
michael@0 39 , _id(locale)
michael@0 40 , _kind(kind)
michael@0 41 {
michael@0 42 }
michael@0 43
michael@0 44 SimpleLocaleKeyFactory::SimpleLocaleKeyFactory(UObject* objToAdopt,
michael@0 45 const Locale& locale,
michael@0 46 int32_t kind,
michael@0 47 int32_t coverage)
michael@0 48 : LocaleKeyFactory(coverage)
michael@0 49 , _obj(objToAdopt)
michael@0 50 , _id()
michael@0 51 , _kind(kind)
michael@0 52 {
michael@0 53 LocaleUtility::initNameFromLocale(locale, _id);
michael@0 54 }
michael@0 55
michael@0 56 SimpleLocaleKeyFactory::~SimpleLocaleKeyFactory()
michael@0 57 {
michael@0 58 delete _obj;
michael@0 59 _obj = NULL;
michael@0 60 }
michael@0 61
michael@0 62 UObject*
michael@0 63 SimpleLocaleKeyFactory::create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const
michael@0 64 {
michael@0 65 if (U_SUCCESS(status)) {
michael@0 66 const LocaleKey& lkey = (const LocaleKey&)key;
michael@0 67 if (_kind == LocaleKey::KIND_ANY || _kind == lkey.kind()) {
michael@0 68 UnicodeString keyID;
michael@0 69 lkey.currentID(keyID);
michael@0 70 if (_id == keyID) {
michael@0 71 return service->cloneInstance(_obj);
michael@0 72 }
michael@0 73 }
michael@0 74 }
michael@0 75 return NULL;
michael@0 76 }
michael@0 77
michael@0 78 //UBool
michael@0 79 //SimpleLocaleKeyFactory::isSupportedID(const UnicodeString& id, UErrorCode& /* status */) const
michael@0 80 //{
michael@0 81 // return id == _id;
michael@0 82 //}
michael@0 83
michael@0 84 void
michael@0 85 SimpleLocaleKeyFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const
michael@0 86 {
michael@0 87 if (U_SUCCESS(status)) {
michael@0 88 if (_coverage & 0x1) {
michael@0 89 result.remove(_id);
michael@0 90 } else {
michael@0 91 result.put(_id, (void*)this, status);
michael@0 92 }
michael@0 93 }
michael@0 94 }
michael@0 95
michael@0 96 #ifdef SERVICE_DEBUG
michael@0 97 UnicodeString&
michael@0 98 SimpleLocaleKeyFactory::debug(UnicodeString& result) const
michael@0 99 {
michael@0 100 LocaleKeyFactory::debug(result);
michael@0 101 result.append(", id: ");
michael@0 102 result.append(_id);
michael@0 103 result.append(", kind: ");
michael@0 104 result.append(_kind);
michael@0 105 return result;
michael@0 106 }
michael@0 107
michael@0 108 UnicodeString&
michael@0 109 SimpleLocaleKeyFactory::debugClass(UnicodeString& result) const
michael@0 110 {
michael@0 111 return result.append("SimpleLocaleKeyFactory");
michael@0 112 }
michael@0 113 #endif
michael@0 114
michael@0 115 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleLocaleKeyFactory)
michael@0 116
michael@0 117 U_NAMESPACE_END
michael@0 118
michael@0 119 /* !UCONFIG_NO_SERVICE */
michael@0 120 #endif
michael@0 121
michael@0 122

mercurial