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 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #include "nsIPlatformCharset.h" |
michael@0 | 6 | #include "nsILocaleService.h" |
michael@0 | 7 | #include "nsCOMPtr.h" |
michael@0 | 8 | #include "nsReadableUtils.h" |
michael@0 | 9 | #include "nsIComponentManager.h" |
michael@0 | 10 | #include <stdio.h> |
michael@0 | 11 | |
michael@0 | 12 | int |
michael@0 | 13 | main(int argc, const char** argv) |
michael@0 | 14 | { |
michael@0 | 15 | |
michael@0 | 16 | nsCOMPtr<nsIPlatformCharset> platform_charset = |
michael@0 | 17 | do_CreateInstance(NS_PLATFORMCHARSET_CONTRACTID); |
michael@0 | 18 | if (!platform_charset) return -1; |
michael@0 | 19 | |
michael@0 | 20 | nsCOMPtr<nsILocaleService> locale_service = |
michael@0 | 21 | do_CreateInstance(NS_LOCALESERVICE_CONTRACTID); |
michael@0 | 22 | if (!locale_service) return -1; |
michael@0 | 23 | |
michael@0 | 24 | nsCOMPtr<nsILocale> locale; |
michael@0 | 25 | nsAutoCString charset; |
michael@0 | 26 | nsAutoString category; |
michael@0 | 27 | |
michael@0 | 28 | nsresult rv = locale_service->GetSystemLocale(getter_AddRefs(locale)); |
michael@0 | 29 | if (NS_FAILED(rv)) return -1; |
michael@0 | 30 | |
michael@0 | 31 | rv = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_MESSAGES"), category); |
michael@0 | 32 | if (NS_FAILED(rv)) return -1; |
michael@0 | 33 | |
michael@0 | 34 | rv = platform_charset->GetDefaultCharsetForLocale(category, charset); |
michael@0 | 35 | if (NS_FAILED(rv)) return -1; |
michael@0 | 36 | |
michael@0 | 37 | printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get()); |
michael@0 | 38 | |
michael@0 | 39 | category.AssignLiteral("en-US"); |
michael@0 | 40 | rv = platform_charset->GetDefaultCharsetForLocale(category, charset); |
michael@0 | 41 | if (NS_FAILED(rv)) return -1; |
michael@0 | 42 | |
michael@0 | 43 | printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get()); |
michael@0 | 44 | |
michael@0 | 45 | return 0; |
michael@0 | 46 | } |