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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef nsDOMJSUtils_h__ |
michael@0 | 6 | #define nsDOMJSUtils_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "nsIScriptContext.h" |
michael@0 | 9 | #include "jsapi.h" |
michael@0 | 10 | |
michael@0 | 11 | class nsIJSArgArray; |
michael@0 | 12 | |
michael@0 | 13 | // seems like overkill for just this 1 function - but let's see what else |
michael@0 | 14 | // falls out first. |
michael@0 | 15 | inline nsIScriptContext * |
michael@0 | 16 | GetScriptContextFromJSContext(JSContext *cx) |
michael@0 | 17 | { |
michael@0 | 18 | if (!(JS::ContextOptionsRef(cx).privateIsNSISupports())) { |
michael@0 | 19 | return nullptr; |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | nsCOMPtr<nsIScriptContext> scx = |
michael@0 | 23 | do_QueryInterface(static_cast<nsISupports *> |
michael@0 | 24 | (::JS_GetContextPrivate(cx))); |
michael@0 | 25 | |
michael@0 | 26 | // This will return a pointer to something that's about to be |
michael@0 | 27 | // released, but that's ok here. |
michael@0 | 28 | return scx; |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | JSObject* GetDefaultScopeFromJSContext(JSContext *cx); |
michael@0 | 32 | |
michael@0 | 33 | // A factory function for turning a JS::Value argv into an nsIArray |
michael@0 | 34 | // but also supports an effecient way of extracting the original argv. |
michael@0 | 35 | // Bug 312003 describes why this must be "void *", but argv will be cast to |
michael@0 | 36 | // JS::Value* and the args are found at: |
michael@0 | 37 | // ((JS::Value*)aArgv)[0], ..., ((JS::Value*)aArgv)[aArgc - 1] |
michael@0 | 38 | // The resulting object will take a copy of the array, and ensure each |
michael@0 | 39 | // element is rooted. |
michael@0 | 40 | // Optionally, aArgv may be nullptr, in which case the array is allocated and |
michael@0 | 41 | // rooted, but all items remain nullptr. This presumably means the caller |
michael@0 | 42 | // will then QI us for nsIJSArgArray, and set our array elements. |
michael@0 | 43 | nsresult NS_CreateJSArgv(JSContext *aContext, uint32_t aArgc, void *aArgv, |
michael@0 | 44 | nsIJSArgArray **aArray); |
michael@0 | 45 | |
michael@0 | 46 | #endif // nsDOMJSUtils_h__ |