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