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 | #include "nsXPCOM.h" |
michael@0 | 6 | #include "nsXPCOMPrivate.h" |
michael@0 | 7 | #include "nsXPCOMStrings.h" |
michael@0 | 8 | #include "xptcall.h" |
michael@0 | 9 | |
michael@0 | 10 | #include <string.h> |
michael@0 | 11 | |
michael@0 | 12 | /** |
michael@0 | 13 | * Private Method to register an exit routine. This method |
michael@0 | 14 | * used to allow you to setup a callback that will be called from |
michael@0 | 15 | * the NS_ShutdownXPCOM function after all services and |
michael@0 | 16 | * components have gone away. It was fatally flawed in that the component |
michael@0 | 17 | * DLL could be released before the exit function was called; it is now a |
michael@0 | 18 | * stub implementation that does nothing. |
michael@0 | 19 | */ |
michael@0 | 20 | XPCOM_API(nsresult) |
michael@0 | 21 | NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, uint32_t priority); |
michael@0 | 22 | |
michael@0 | 23 | XPCOM_API(nsresult) |
michael@0 | 24 | NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine); |
michael@0 | 25 | |
michael@0 | 26 | static const XPCOMFunctions kFrozenFunctions = { |
michael@0 | 27 | XPCOM_GLUE_VERSION, |
michael@0 | 28 | sizeof(XPCOMFunctions), |
michael@0 | 29 | &NS_InitXPCOM2, |
michael@0 | 30 | &NS_ShutdownXPCOM, |
michael@0 | 31 | &NS_GetServiceManager, |
michael@0 | 32 | &NS_GetComponentManager, |
michael@0 | 33 | &NS_GetComponentRegistrar, |
michael@0 | 34 | &NS_GetMemoryManager, |
michael@0 | 35 | &NS_NewLocalFile, |
michael@0 | 36 | &NS_NewNativeLocalFile, |
michael@0 | 37 | &NS_RegisterXPCOMExitRoutine, |
michael@0 | 38 | &NS_UnregisterXPCOMExitRoutine, |
michael@0 | 39 | |
michael@0 | 40 | // these functions were added post 1.4 |
michael@0 | 41 | &NS_GetDebug, |
michael@0 | 42 | nullptr, |
michael@0 | 43 | |
michael@0 | 44 | // these functions were added post 1.6 |
michael@0 | 45 | &NS_StringContainerInit, |
michael@0 | 46 | &NS_StringContainerFinish, |
michael@0 | 47 | &NS_StringGetData, |
michael@0 | 48 | &NS_StringSetData, |
michael@0 | 49 | &NS_StringSetDataRange, |
michael@0 | 50 | &NS_StringCopy, |
michael@0 | 51 | &NS_CStringContainerInit, |
michael@0 | 52 | &NS_CStringContainerFinish, |
michael@0 | 53 | &NS_CStringGetData, |
michael@0 | 54 | &NS_CStringSetData, |
michael@0 | 55 | &NS_CStringSetDataRange, |
michael@0 | 56 | &NS_CStringCopy, |
michael@0 | 57 | &NS_CStringToUTF16, |
michael@0 | 58 | &NS_UTF16ToCString, |
michael@0 | 59 | &NS_StringCloneData, |
michael@0 | 60 | &NS_CStringCloneData, |
michael@0 | 61 | |
michael@0 | 62 | // these functions were added post 1.7 (post Firefox 1.0) |
michael@0 | 63 | &NS_Alloc, |
michael@0 | 64 | &NS_Realloc, |
michael@0 | 65 | &NS_Free, |
michael@0 | 66 | &NS_StringContainerInit2, |
michael@0 | 67 | &NS_CStringContainerInit2, |
michael@0 | 68 | &NS_StringGetMutableData, |
michael@0 | 69 | &NS_CStringGetMutableData, |
michael@0 | 70 | nullptr, |
michael@0 | 71 | |
michael@0 | 72 | // these functions were added post 1.8 |
michael@0 | 73 | &NS_DebugBreak, |
michael@0 | 74 | &NS_LogInit, |
michael@0 | 75 | &NS_LogTerm, |
michael@0 | 76 | &NS_LogAddRef, |
michael@0 | 77 | &NS_LogRelease, |
michael@0 | 78 | &NS_LogCtor, |
michael@0 | 79 | &NS_LogDtor, |
michael@0 | 80 | &NS_LogCOMPtrAddRef, |
michael@0 | 81 | &NS_LogCOMPtrRelease, |
michael@0 | 82 | &NS_GetXPTCallStub, |
michael@0 | 83 | &NS_DestroyXPTCallStub, |
michael@0 | 84 | &NS_InvokeByIndex, |
michael@0 | 85 | nullptr, |
michael@0 | 86 | nullptr, |
michael@0 | 87 | &NS_StringSetIsVoid, |
michael@0 | 88 | &NS_StringGetIsVoid, |
michael@0 | 89 | &NS_CStringSetIsVoid, |
michael@0 | 90 | &NS_CStringGetIsVoid, |
michael@0 | 91 | |
michael@0 | 92 | // these functions were added post 1.9, but then made obsolete |
michael@0 | 93 | nullptr, |
michael@0 | 94 | nullptr, |
michael@0 | 95 | |
michael@0 | 96 | &NS_CycleCollectorSuspect3, |
michael@0 | 97 | }; |
michael@0 | 98 | |
michael@0 | 99 | EXPORT_XPCOM_API(nsresult) |
michael@0 | 100 | NS_GetFrozenFunctions(XPCOMFunctions *functions, const char* /* libraryPath */) |
michael@0 | 101 | { |
michael@0 | 102 | if (!functions) |
michael@0 | 103 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 104 | |
michael@0 | 105 | if (functions->version != XPCOM_GLUE_VERSION) |
michael@0 | 106 | return NS_ERROR_FAILURE; |
michael@0 | 107 | |
michael@0 | 108 | uint32_t size = functions->size; |
michael@0 | 109 | if (size > sizeof(XPCOMFunctions)) |
michael@0 | 110 | size = sizeof(XPCOMFunctions); |
michael@0 | 111 | |
michael@0 | 112 | size -= offsetof(XPCOMFunctions, init); |
michael@0 | 113 | |
michael@0 | 114 | memcpy(&functions->init, &kFrozenFunctions.init, size); |
michael@0 | 115 | |
michael@0 | 116 | return NS_OK; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | /* |
michael@0 | 120 | * Stubs for nsXPCOMPrivate.h |
michael@0 | 121 | */ |
michael@0 | 122 | |
michael@0 | 123 | EXPORT_XPCOM_API(nsresult) |
michael@0 | 124 | NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, uint32_t priority) |
michael@0 | 125 | { |
michael@0 | 126 | return NS_OK; |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | EXPORT_XPCOM_API(nsresult) |
michael@0 | 130 | NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine) |
michael@0 | 131 | { |
michael@0 | 132 | return NS_OK; |
michael@0 | 133 | } |