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 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "xpctest_private.h" |
michael@0 | 8 | |
michael@0 | 9 | NS_IMPL_ISUPPORTS(xpcTestObjectReadOnly, nsIXPCTestObjectReadOnly) |
michael@0 | 10 | |
michael@0 | 11 | xpcTestObjectReadOnly :: xpcTestObjectReadOnly() { |
michael@0 | 12 | boolProperty = true; |
michael@0 | 13 | shortProperty = 32767; |
michael@0 | 14 | longProperty = 2147483647; |
michael@0 | 15 | floatProperty = 5.5f; |
michael@0 | 16 | charProperty = 'X'; |
michael@0 | 17 | // timeProperty is PRTime and signed type. |
michael@0 | 18 | // So it has to allow negative value. |
michael@0 | 19 | timeProperty = -1; |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetStrReadOnly(char * *aStrReadOnly){ |
michael@0 | 23 | char aString[] = "XPConnect Read-Only String"; |
michael@0 | 24 | |
michael@0 | 25 | if (!aStrReadOnly) |
michael@0 | 26 | return NS_ERROR_NULL_POINTER; |
michael@0 | 27 | *aStrReadOnly = (char*) nsMemory::Clone(aString, |
michael@0 | 28 | sizeof(char)*(strlen(aString)+1)); |
michael@0 | 29 | return *aStrReadOnly ? NS_OK : NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetBoolReadOnly(bool *aBoolReadOnly) { |
michael@0 | 33 | *aBoolReadOnly = boolProperty; |
michael@0 | 34 | return NS_OK; |
michael@0 | 35 | } |
michael@0 | 36 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetShortReadOnly(int16_t *aShortReadOnly){ |
michael@0 | 37 | *aShortReadOnly = shortProperty; |
michael@0 | 38 | return NS_OK; |
michael@0 | 39 | } |
michael@0 | 40 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetLongReadOnly(int32_t *aLongReadOnly){ |
michael@0 | 41 | *aLongReadOnly = longProperty; |
michael@0 | 42 | return NS_OK; |
michael@0 | 43 | } |
michael@0 | 44 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetFloatReadOnly(float *aFloatReadOnly){ |
michael@0 | 45 | *aFloatReadOnly = floatProperty; |
michael@0 | 46 | return NS_OK; |
michael@0 | 47 | } |
michael@0 | 48 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetCharReadOnly(char *aCharReadOnly){ |
michael@0 | 49 | *aCharReadOnly = charProperty; |
michael@0 | 50 | return NS_OK; |
michael@0 | 51 | } |
michael@0 | 52 | NS_IMETHODIMP xpcTestObjectReadOnly :: GetTimeReadOnly(PRTime *aTimeReadOnly){ |
michael@0 | 53 | *aTimeReadOnly = timeProperty; |
michael@0 | 54 | return NS_OK; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | NS_IMPL_ISUPPORTS(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite) |
michael@0 | 58 | |
michael@0 | 59 | xpcTestObjectReadWrite :: xpcTestObjectReadWrite() { |
michael@0 | 60 | const char s[] = "XPConnect Read-Writable String"; |
michael@0 | 61 | stringProperty = (char*) nsMemory::Clone(s, sizeof(char)*(strlen(s)+1)); |
michael@0 | 62 | boolProperty = true; |
michael@0 | 63 | shortProperty = 32767; |
michael@0 | 64 | longProperty = 2147483647; |
michael@0 | 65 | floatProperty = 5.5f; |
michael@0 | 66 | charProperty = 'X'; |
michael@0 | 67 | // timeProperty is PRTime and signed type. |
michael@0 | 68 | // So it has to allow negative value. |
michael@0 | 69 | timeProperty = -1; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | xpcTestObjectReadWrite :: ~xpcTestObjectReadWrite() |
michael@0 | 73 | { |
michael@0 | 74 | nsMemory::Free(stringProperty); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetStringProperty(char * *aStringProperty) { |
michael@0 | 78 | if (!aStringProperty) |
michael@0 | 79 | return NS_ERROR_NULL_POINTER; |
michael@0 | 80 | *aStringProperty = (char*) nsMemory::Clone(stringProperty, |
michael@0 | 81 | sizeof(char)*(strlen(stringProperty)+1)); |
michael@0 | 82 | return *aStringProperty ? NS_OK : NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 83 | |
michael@0 | 84 | } |
michael@0 | 85 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetStringProperty(const char * aStringProperty) { |
michael@0 | 86 | nsMemory::Free(stringProperty); |
michael@0 | 87 | stringProperty = (char*) nsMemory::Clone(aStringProperty, |
michael@0 | 88 | sizeof(char)*(strlen(aStringProperty)+1)); |
michael@0 | 89 | return NS_OK; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetBooleanProperty(bool *aBooleanProperty) { |
michael@0 | 93 | *aBooleanProperty = boolProperty; |
michael@0 | 94 | return NS_OK; |
michael@0 | 95 | } |
michael@0 | 96 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetBooleanProperty(bool aBooleanProperty) { |
michael@0 | 97 | boolProperty = aBooleanProperty; |
michael@0 | 98 | return NS_OK; |
michael@0 | 99 | } |
michael@0 | 100 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetShortProperty(int16_t *aShortProperty) { |
michael@0 | 101 | *aShortProperty = shortProperty; |
michael@0 | 102 | return NS_OK; |
michael@0 | 103 | } |
michael@0 | 104 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetShortProperty(int16_t aShortProperty) { |
michael@0 | 105 | shortProperty = aShortProperty; |
michael@0 | 106 | return NS_OK; |
michael@0 | 107 | } |
michael@0 | 108 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetLongProperty(int32_t *aLongProperty) { |
michael@0 | 109 | *aLongProperty = longProperty; |
michael@0 | 110 | return NS_OK; |
michael@0 | 111 | } |
michael@0 | 112 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetLongProperty(int32_t aLongProperty) { |
michael@0 | 113 | longProperty = aLongProperty; |
michael@0 | 114 | return NS_OK; |
michael@0 | 115 | } |
michael@0 | 116 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetFloatProperty(float *aFloatProperty) { |
michael@0 | 117 | *aFloatProperty = floatProperty; |
michael@0 | 118 | return NS_OK; |
michael@0 | 119 | } |
michael@0 | 120 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetFloatProperty(float aFloatProperty) { |
michael@0 | 121 | floatProperty = aFloatProperty; |
michael@0 | 122 | return NS_OK; |
michael@0 | 123 | } |
michael@0 | 124 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetCharProperty(char *aCharProperty) { |
michael@0 | 125 | *aCharProperty = charProperty; |
michael@0 | 126 | return NS_OK; |
michael@0 | 127 | } |
michael@0 | 128 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetCharProperty(char aCharProperty) { |
michael@0 | 129 | charProperty = aCharProperty; |
michael@0 | 130 | return NS_OK; |
michael@0 | 131 | } |
michael@0 | 132 | NS_IMETHODIMP xpcTestObjectReadWrite :: GetTimeProperty(PRTime *aTimeProperty) { |
michael@0 | 133 | *aTimeProperty = timeProperty; |
michael@0 | 134 | return NS_OK; |
michael@0 | 135 | } |
michael@0 | 136 | NS_IMETHODIMP xpcTestObjectReadWrite :: SetTimeProperty(PRTime aTimeProperty) { |
michael@0 | 137 | timeProperty = aTimeProperty; |
michael@0 | 138 | return NS_OK; |
michael@0 | 139 | } |