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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
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 "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | native HKEY(HKEY); |
michael@0 | 10 | |
michael@0 | 11 | /** |
michael@0 | 12 | * This interface is designed to provide scriptable access to the Windows |
michael@0 | 13 | * registry system ("With Great Power Comes Great Responsibility"). The |
michael@0 | 14 | * interface represents a single key in the registry. |
michael@0 | 15 | * |
michael@0 | 16 | * This interface is highly Win32 specific. |
michael@0 | 17 | */ |
michael@0 | 18 | [scriptable, uuid(2555b930-d64f-437e-9be7-0a2cb252c1f4)] |
michael@0 | 19 | interface nsIWindowsRegKey : nsISupports |
michael@0 | 20 | { |
michael@0 | 21 | /** |
michael@0 | 22 | * Root keys. The values for these keys correspond to the values from |
michael@0 | 23 | * WinReg.h in the MS Platform SDK. The ROOT_KEY_ prefix corresponds to the |
michael@0 | 24 | * HKEY_ prefix in the MS Platform SDK. |
michael@0 | 25 | * |
michael@0 | 26 | * This interface is not restricted to using only these root keys. |
michael@0 | 27 | */ |
michael@0 | 28 | const unsigned long ROOT_KEY_CLASSES_ROOT = 0x80000000; |
michael@0 | 29 | const unsigned long ROOT_KEY_CURRENT_USER = 0x80000001; |
michael@0 | 30 | const unsigned long ROOT_KEY_LOCAL_MACHINE = 0x80000002; |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * Values for the mode parameter passed to the open and create methods. |
michael@0 | 34 | * The values defined here correspond to the REGSAM values defined in |
michael@0 | 35 | * WinNT.h in the MS Platform SDK, where ACCESS_ is replaced with KEY_. |
michael@0 | 36 | * |
michael@0 | 37 | * This interface is not restricted to using only these access types. |
michael@0 | 38 | */ |
michael@0 | 39 | const unsigned long ACCESS_BASIC = 0x00020000; |
michael@0 | 40 | const unsigned long ACCESS_QUERY_VALUE = 0x00000001; |
michael@0 | 41 | const unsigned long ACCESS_SET_VALUE = 0x00000002; |
michael@0 | 42 | const unsigned long ACCESS_CREATE_SUB_KEY = 0x00000004; |
michael@0 | 43 | const unsigned long ACCESS_ENUMERATE_SUB_KEYS = 0x00000008; |
michael@0 | 44 | const unsigned long ACCESS_NOTIFY = 0x00000010; |
michael@0 | 45 | const unsigned long ACCESS_READ = ACCESS_BASIC | |
michael@0 | 46 | ACCESS_QUERY_VALUE | |
michael@0 | 47 | ACCESS_ENUMERATE_SUB_KEYS | |
michael@0 | 48 | ACCESS_NOTIFY; |
michael@0 | 49 | const unsigned long ACCESS_WRITE = ACCESS_BASIC | |
michael@0 | 50 | ACCESS_SET_VALUE | |
michael@0 | 51 | ACCESS_CREATE_SUB_KEY; |
michael@0 | 52 | const unsigned long ACCESS_ALL = ACCESS_READ | |
michael@0 | 53 | ACCESS_WRITE; |
michael@0 | 54 | const unsigned long WOW64_32 = 0x00000200; |
michael@0 | 55 | const unsigned long WOW64_64 = 0x00000100; |
michael@0 | 56 | |
michael@0 | 57 | |
michael@0 | 58 | /** |
michael@0 | 59 | * Values for the type of a registry value. The numeric values of these |
michael@0 | 60 | * constants are taken directly from WinNT.h in the MS Platform SDK. |
michael@0 | 61 | * The Microsoft documentation should be consulted for the exact meaning of |
michael@0 | 62 | * these value types. |
michael@0 | 63 | * |
michael@0 | 64 | * This interface is somewhat restricted to using only these value types. |
michael@0 | 65 | * There is no method that is directly equivalent to RegQueryValueEx or |
michael@0 | 66 | * RegSetValueEx. In particular, this interface does not support the |
michael@0 | 67 | * REG_MULTI_SZ and REG_EXPAND_SZ value types. It is still possible to |
michael@0 | 68 | * enumerate values that have other types (i.e., getValueType may return a |
michael@0 | 69 | * type not defined below). |
michael@0 | 70 | */ |
michael@0 | 71 | const unsigned long TYPE_NONE = 0; // REG_NONE |
michael@0 | 72 | const unsigned long TYPE_STRING = 1; // REG_SZ |
michael@0 | 73 | const unsigned long TYPE_BINARY = 3; // REG_BINARY |
michael@0 | 74 | const unsigned long TYPE_INT = 4; // REG_DWORD |
michael@0 | 75 | const unsigned long TYPE_INT64 = 11; // REG_QWORD |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * This attribute exposes the native HKEY and is available to provide C++ |
michael@0 | 79 | * consumers with the flexibility of making other Windows registry API calls |
michael@0 | 80 | * that are not exposed via this interface. |
michael@0 | 81 | * |
michael@0 | 82 | * It is possible to initialize this object by setting an HKEY on it. In |
michael@0 | 83 | * that case, it is the responsibility of the consumer setting the HKEY to |
michael@0 | 84 | * ensure that it is a valid HKEY. |
michael@0 | 85 | * |
michael@0 | 86 | * WARNING: Setting the key does not close the old key. |
michael@0 | 87 | */ |
michael@0 | 88 | [noscript] attribute HKEY key; |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * This method closes the key. If the key is already closed, then this |
michael@0 | 92 | * method does nothing. |
michael@0 | 93 | */ |
michael@0 | 94 | void close(); |
michael@0 | 95 | |
michael@0 | 96 | /** |
michael@0 | 97 | * This method opens an existing key. This method fails if the key |
michael@0 | 98 | * does not exist. |
michael@0 | 99 | * |
michael@0 | 100 | * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey |
michael@0 | 101 | * parameter of this function. However, for compatibility with 64-bit |
michael@0 | 102 | * Windows, that usage should probably be avoided in favor of openChild. |
michael@0 | 103 | * |
michael@0 | 104 | * @param rootKey |
michael@0 | 105 | * A root key defined above or any valid HKEY on 32-bit Windows. |
michael@0 | 106 | * @param relPath |
michael@0 | 107 | * A relative path from the given root key. |
michael@0 | 108 | * @param mode |
michael@0 | 109 | * Access mode, which is a bit-wise OR of the ACCESS_ values defined |
michael@0 | 110 | * above. |
michael@0 | 111 | */ |
michael@0 | 112 | void open(in unsigned long rootKey, in AString relPath, in unsigned long mode); |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * This method opens an existing key or creates a new key. |
michael@0 | 116 | * |
michael@0 | 117 | * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey |
michael@0 | 118 | * parameter of this function. However, for compatibility with 64-bit |
michael@0 | 119 | * Windows, that usage should probably be avoided in favor of createChild. |
michael@0 | 120 | * |
michael@0 | 121 | * @param rootKey |
michael@0 | 122 | * A root key defined above or any valid HKEY on 32-bit Windows. |
michael@0 | 123 | * @param relPath |
michael@0 | 124 | * A relative path from the given root key. |
michael@0 | 125 | * @param mode |
michael@0 | 126 | * Access mode, which is a bit-wise OR of the ACCESS_ values defined |
michael@0 | 127 | * above. |
michael@0 | 128 | */ |
michael@0 | 129 | void create(in unsigned long rootKey, in AString relPath, in unsigned long mode); |
michael@0 | 130 | |
michael@0 | 131 | /** |
michael@0 | 132 | * This method opens a subkey relative to this key. This method fails if the |
michael@0 | 133 | * key does not exist. |
michael@0 | 134 | * |
michael@0 | 135 | * @return nsIWindowsRegKey for the newly opened subkey. |
michael@0 | 136 | */ |
michael@0 | 137 | nsIWindowsRegKey openChild(in AString relPath, in unsigned long mode); |
michael@0 | 138 | |
michael@0 | 139 | /** |
michael@0 | 140 | * This method opens or creates a subkey relative to this key. |
michael@0 | 141 | * |
michael@0 | 142 | * @return nsIWindowsRegKey for the newly opened or created subkey. |
michael@0 | 143 | */ |
michael@0 | 144 | nsIWindowsRegKey createChild(in AString relPath, in unsigned long mode); |
michael@0 | 145 | |
michael@0 | 146 | /** |
michael@0 | 147 | * This attribute returns the number of child keys. |
michael@0 | 148 | */ |
michael@0 | 149 | readonly attribute unsigned long childCount; |
michael@0 | 150 | |
michael@0 | 151 | /** |
michael@0 | 152 | * This method returns the name of the n'th child key. |
michael@0 | 153 | * |
michael@0 | 154 | * @param index |
michael@0 | 155 | * The index of the requested child key. |
michael@0 | 156 | */ |
michael@0 | 157 | AString getChildName(in unsigned long index); |
michael@0 | 158 | |
michael@0 | 159 | /** |
michael@0 | 160 | * This method checks to see if the key has a child by the given name. |
michael@0 | 161 | * |
michael@0 | 162 | * @param name |
michael@0 | 163 | * The name of the requested child key. |
michael@0 | 164 | */ |
michael@0 | 165 | boolean hasChild(in AString name); |
michael@0 | 166 | |
michael@0 | 167 | /** |
michael@0 | 168 | * This attribute returns the number of values under this key. |
michael@0 | 169 | */ |
michael@0 | 170 | readonly attribute unsigned long valueCount; |
michael@0 | 171 | |
michael@0 | 172 | /** |
michael@0 | 173 | * This method returns the name of the n'th value under this key. |
michael@0 | 174 | * |
michael@0 | 175 | * @param index |
michael@0 | 176 | * The index of the requested value. |
michael@0 | 177 | */ |
michael@0 | 178 | AString getValueName(in unsigned long index); |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * This method checks to see if the key has a value by the given name. |
michael@0 | 182 | * |
michael@0 | 183 | * @param name |
michael@0 | 184 | * The name of the requested value. |
michael@0 | 185 | */ |
michael@0 | 186 | boolean hasValue(in AString name); |
michael@0 | 187 | |
michael@0 | 188 | /** |
michael@0 | 189 | * This method removes a child key and all of its values. This method will |
michael@0 | 190 | * fail if the key has any children of its own. |
michael@0 | 191 | * |
michael@0 | 192 | * @param relPath |
michael@0 | 193 | * The relative path from this key to the key to be removed. |
michael@0 | 194 | */ |
michael@0 | 195 | void removeChild(in AString relPath); |
michael@0 | 196 | |
michael@0 | 197 | /** |
michael@0 | 198 | * This method removes the value with the given name. |
michael@0 | 199 | * |
michael@0 | 200 | * @param name |
michael@0 | 201 | * The name of the value to be removed. |
michael@0 | 202 | */ |
michael@0 | 203 | void removeValue(in AString name); |
michael@0 | 204 | |
michael@0 | 205 | /** |
michael@0 | 206 | * This method returns the type of the value with the given name. The return |
michael@0 | 207 | * value is one of the "TYPE_" constants defined above. |
michael@0 | 208 | * |
michael@0 | 209 | * @param name |
michael@0 | 210 | * The name of the value to query. |
michael@0 | 211 | */ |
michael@0 | 212 | unsigned long getValueType(in AString name); |
michael@0 | 213 | |
michael@0 | 214 | /** |
michael@0 | 215 | * This method reads the string contents of the named value as a Unicode |
michael@0 | 216 | * string. |
michael@0 | 217 | * |
michael@0 | 218 | * @param name |
michael@0 | 219 | * The name of the value to query. This parameter can be the empty |
michael@0 | 220 | * string to request the key's default value. |
michael@0 | 221 | */ |
michael@0 | 222 | AString readStringValue(in AString name); |
michael@0 | 223 | |
michael@0 | 224 | /** |
michael@0 | 225 | * This method reads the integer contents of the named value. |
michael@0 | 226 | * |
michael@0 | 227 | * @param name |
michael@0 | 228 | * The name of the value to query. |
michael@0 | 229 | */ |
michael@0 | 230 | unsigned long readIntValue(in AString name); |
michael@0 | 231 | |
michael@0 | 232 | /** |
michael@0 | 233 | * This method reads the 64-bit integer contents of the named value. |
michael@0 | 234 | * |
michael@0 | 235 | * @param name |
michael@0 | 236 | * The name of the value to query. |
michael@0 | 237 | */ |
michael@0 | 238 | unsigned long long readInt64Value(in AString name); |
michael@0 | 239 | |
michael@0 | 240 | /** |
michael@0 | 241 | * This method reads the binary contents of the named value under this key. |
michael@0 | 242 | * |
michael@0 | 243 | * JavaScript callers should take care with the result of this method since |
michael@0 | 244 | * it will be byte-expanded to form a JS string. (The binary data will be |
michael@0 | 245 | * treated as an ISO-Latin-1 character string, which it is not). |
michael@0 | 246 | * |
michael@0 | 247 | * @param name |
michael@0 | 248 | * The name of the value to query. |
michael@0 | 249 | */ |
michael@0 | 250 | ACString readBinaryValue(in AString name); |
michael@0 | 251 | |
michael@0 | 252 | /** |
michael@0 | 253 | * This method writes the unicode string contents of the named value. The |
michael@0 | 254 | * value will be created if it does not already exist. |
michael@0 | 255 | * |
michael@0 | 256 | * @param name |
michael@0 | 257 | * The name of the value to modify. This parameter can be the empty |
michael@0 | 258 | * string to modify the key's default value. |
michael@0 | 259 | * @param data |
michael@0 | 260 | * The data for the value to modify. |
michael@0 | 261 | */ |
michael@0 | 262 | void writeStringValue(in AString name, in AString data); |
michael@0 | 263 | |
michael@0 | 264 | /** |
michael@0 | 265 | * This method writes the integer contents of the named value. The value |
michael@0 | 266 | * will be created if it does not already exist. |
michael@0 | 267 | * |
michael@0 | 268 | * @param name |
michael@0 | 269 | * The name of the value to modify. |
michael@0 | 270 | * @param data |
michael@0 | 271 | * The data for the value to modify. |
michael@0 | 272 | */ |
michael@0 | 273 | void writeIntValue(in AString name, in unsigned long data); |
michael@0 | 274 | |
michael@0 | 275 | /** |
michael@0 | 276 | * This method writes the 64-bit integer contents of the named value. The |
michael@0 | 277 | * value will be created if it does not already exist. |
michael@0 | 278 | * |
michael@0 | 279 | * @param name |
michael@0 | 280 | * The name of the value to modify. |
michael@0 | 281 | * @param data |
michael@0 | 282 | * The data for the value to modify. |
michael@0 | 283 | */ |
michael@0 | 284 | void writeInt64Value(in AString name, in unsigned long long data); |
michael@0 | 285 | |
michael@0 | 286 | /** |
michael@0 | 287 | * This method writes the binary contents of the named value. The value will |
michael@0 | 288 | * be created if it does not already exist. |
michael@0 | 289 | * |
michael@0 | 290 | * JavaScript callers should take care with the value passed to this method |
michael@0 | 291 | * since it will be truncated from a JS string (unicode) to a ISO-Latin-1 |
michael@0 | 292 | * string. (The binary data will be treated as an ISO-Latin-1 character |
michael@0 | 293 | * string, which it is not). So, JavaScript callers should only pass |
michael@0 | 294 | * character values in the range \u0000 to \u00FF, or else data loss will |
michael@0 | 295 | * occur. |
michael@0 | 296 | * |
michael@0 | 297 | * @param name |
michael@0 | 298 | * The name of the value to modify. |
michael@0 | 299 | * @param data |
michael@0 | 300 | * The data for the value to modify. |
michael@0 | 301 | */ |
michael@0 | 302 | void writeBinaryValue(in AString name, in ACString data); |
michael@0 | 303 | |
michael@0 | 304 | /** |
michael@0 | 305 | * This method starts watching the key to see if any of its values have |
michael@0 | 306 | * changed. The key must have been opened with mode including ACCESS_NOTIFY. |
michael@0 | 307 | * If recurse is true, then this key and any of its descendant keys are |
michael@0 | 308 | * watched. Otherwise, only this key is watched. |
michael@0 | 309 | * |
michael@0 | 310 | * @param recurse |
michael@0 | 311 | * Indicates whether or not to also watch child keys. |
michael@0 | 312 | */ |
michael@0 | 313 | void startWatching(in boolean recurse); |
michael@0 | 314 | |
michael@0 | 315 | /** |
michael@0 | 316 | * This method stops any watching of the key initiated by a call to |
michael@0 | 317 | * startWatching. This method does nothing if the key is not being watched. |
michael@0 | 318 | */ |
michael@0 | 319 | void stopWatching(); |
michael@0 | 320 | |
michael@0 | 321 | /** |
michael@0 | 322 | * This method returns true if the key is being watched for changes (i.e., |
michael@0 | 323 | * if startWatching() was called). |
michael@0 | 324 | */ |
michael@0 | 325 | boolean isWatching(); |
michael@0 | 326 | |
michael@0 | 327 | /** |
michael@0 | 328 | * This method returns true if the key has changed and false otherwise. |
michael@0 | 329 | * This method will always return false if startWatching was not called. |
michael@0 | 330 | */ |
michael@0 | 331 | boolean hasChanged(); |
michael@0 | 332 | }; |