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 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | module.metadata = { |
michael@0 | 8 | "stability": "stable" |
michael@0 | 9 | }; |
michael@0 | 10 | |
michael@0 | 11 | const INVALID_HOTKEY = "Hotkey must have at least one modifier."; |
michael@0 | 12 | |
michael@0 | 13 | const { toJSON: jsonify, toString: stringify, |
michael@0 | 14 | isFunctionKey } = require("./keyboard/utils"); |
michael@0 | 15 | const { register, unregister } = require("./keyboard/hotkeys"); |
michael@0 | 16 | |
michael@0 | 17 | const Hotkey = exports.Hotkey = function Hotkey(options) { |
michael@0 | 18 | if (!(this instanceof Hotkey)) |
michael@0 | 19 | return new Hotkey(options); |
michael@0 | 20 | |
michael@0 | 21 | // Parsing key combination string. |
michael@0 | 22 | let hotkey = jsonify(options.combo); |
michael@0 | 23 | if (!isFunctionKey(hotkey.key) && !hotkey.modifiers.length) { |
michael@0 | 24 | throw new TypeError(INVALID_HOTKEY); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | this.onPress = options.onPress && options.onPress.bind(this); |
michael@0 | 28 | this.toString = stringify.bind(null, hotkey); |
michael@0 | 29 | // Registering listener on keyboard combination enclosed by this hotkey. |
michael@0 | 30 | // Please note that `this.toString()` is a normalized version of |
michael@0 | 31 | // `options.combination` where order of modifiers is sorted and `accel` is |
michael@0 | 32 | // replaced with platform specific key. |
michael@0 | 33 | register(this.toString(), this.onPress); |
michael@0 | 34 | // We freeze instance before returning it in order to make it's properties |
michael@0 | 35 | // read-only. |
michael@0 | 36 | return Object.freeze(this); |
michael@0 | 37 | }; |
michael@0 | 38 | Hotkey.prototype.destroy = function destroy() { |
michael@0 | 39 | unregister(this.toString(), this.onPress); |
michael@0 | 40 | }; |