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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include <string.h>
7 #include "nsXPCOM.h"
8 #include "nsINIParser.h"
9 #include "nsIFile.h"
11 static bool
12 StringCB(const char *aKey, const char *aValue, void* aClosure)
13 {
14 printf("%s=%s\n", aKey, aValue);
16 return true;
17 }
19 static bool
20 SectionCB(const char *aSection, void* aClosure)
21 {
22 nsINIParser *ini = reinterpret_cast<nsINIParser*>(aClosure);
24 printf("[%s]\n", aSection);
26 ini->GetStrings(aSection, StringCB, nullptr);
28 printf("\n");
30 return true;
31 }
33 int main(int argc, char **argv)
34 {
35 if (argc < 2) {
36 fprintf(stderr, "Usage: %s <ini-file>\n", argv[0]);
37 return 255;
38 }
40 nsCOMPtr<nsIFile> lf;
42 nsresult rv = NS_NewNativeLocalFile(nsDependentCString(argv[1]),
43 true,
44 getter_AddRefs(lf));
45 if (NS_FAILED(rv)) {
46 fprintf(stderr, "Error: NS_NewNativeLocalFile failed\n");
47 return 1;
48 }
50 nsINIParser ini;
51 rv = ini.Init(lf);
52 if (NS_FAILED(rv)) {
53 fprintf(stderr, "Error: Init failed.");
54 return 2;
55 }
57 ini.GetSections(SectionCB, &ini);
59 return 0;
60 }