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: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Windows only app to show a modal debug dialog - launched by nsDebug.cpp */
8 #include <windows.h>
9 #include <stdlib.h>
10 #ifdef _MSC_VER
11 #include <strsafe.h>
12 #endif
13 #ifdef __MINGW32__
14 /* MingW currently does not implement a wide version of the
15 startup routines. Workaround is to implement something like
16 it ourselves. See bug 472063 */
17 #include <stdio.h>
18 #include <shellapi.h>
19 int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
21 #undef __argc
22 #undef __wargv
24 static int __argc;
25 static wchar_t** __wargv;
27 int WINAPI
28 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
29 LPSTR lpszCommandLine, int nCmdShow)
30 {
31 LPWSTR commandLine = GetCommandLineW();
33 /* parse for __argc and __wargv for compatibility, since mingw
34 * doesn't claim to support it :(
35 */
36 __wargv = CommandLineToArgvW(commandLine, &__argc);
37 if (!__wargv)
38 return 127;
40 /* need to strip off any leading whitespace plus the first argument
41 * (the executable itself) to match what should be passed to wWinMain
42 */
43 while ((*commandLine <= L' ') && *commandLine) {
44 ++commandLine;
45 }
46 if (*commandLine == L'"') {
47 ++commandLine;
48 while ((*commandLine != L'"') && *commandLine) {
49 ++commandLine;
50 }
51 if (*commandLine) {
52 ++commandLine;
53 }
54 } else {
55 while (*commandLine > L' ') {
56 ++commandLine;
57 }
58 }
59 while ((*commandLine <= L' ') && *commandLine) {
60 ++commandLine;
61 }
63 int result = wWinMain(hInstance, hPrevInstance, commandLine, nCmdShow);
64 LocalFree(__wargv);
65 return result;
66 }
67 #endif /* __MINGW32__ */
70 int WINAPI
71 wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
72 LPWSTR lpszCmdLine, int nCmdShow)
73 {
74 /* support for auto answering based on words in the assertion.
75 * the assertion message is sent as a series of arguements (words) to the commandline.
76 * set a "word" to 0xffffffff to let the word not affect this code.
77 * set a "word" to 0xfffffffe to show the dialog.
78 * set a "word" to 0x5 to ignore (program should continue).
79 * set a "word" to 0x4 to retry (should fall into debugger).
80 * set a "word" to 0x3 to abort (die).
81 */
82 DWORD regType;
83 DWORD regValue = -1;
84 DWORD regLength = sizeof regValue;
85 HKEY hkeyCU, hkeyLM;
86 RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU);
87 RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM);
88 int argc =0;
89 for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) {
90 bool ok = false;
91 if (hkeyCU)
92 ok = RegQueryValueExW(hkeyCU, __wargv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
93 if (!ok && hkeyLM)
94 ok = RegQueryValueExW(hkeyLM, __wargv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
95 if (!ok)
96 regValue = -1;
97 }
98 if (hkeyCU)
99 RegCloseKey(hkeyCU);
100 if (hkeyLM)
101 RegCloseKey(hkeyLM);
102 if (regValue != (DWORD)-1 && regValue != (DWORD)-2)
103 return regValue;
104 static const int size = 4096;
105 static WCHAR msg[size];
107 #ifdef _MSC_VER
108 StringCchPrintfW(msg,
109 #else
110 snwprintf(msg,
111 #endif
112 size,
113 L"%s\n\nClick Abort to exit the Application.\n"
114 L"Click Retry to Debug the Application.\n"
115 L"Click Ignore to continue running the Application.",
116 lpszCmdLine);
117 msg[size - 1] = L'\0';
118 return MessageBoxW(nullptr, msg, L"NSGlue_Assertion",
119 MB_ICONSTOP | MB_SYSTEMMODAL |
120 MB_ABORTRETRYIGNORE | MB_DEFBUTTON3);
121 }