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: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | // This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | // License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 5 | |
michael@0 | 6 | this.EXPORTED_SYMBOLS = ["RemoteController"]; |
michael@0 | 7 | |
michael@0 | 8 | const Ci = Components.interfaces; |
michael@0 | 9 | const Cc = Components.classes; |
michael@0 | 10 | const Cu = Components.utils; |
michael@0 | 11 | |
michael@0 | 12 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 13 | |
michael@0 | 14 | function RemoteController(browser) |
michael@0 | 15 | { |
michael@0 | 16 | this._browser = browser; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | RemoteController.prototype = { |
michael@0 | 20 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIController]), |
michael@0 | 21 | |
michael@0 | 22 | isCommandEnabled: function(aCommand) { |
michael@0 | 23 | // We can't synchronously ask content if a command is enabled, |
michael@0 | 24 | // so we always pretend is. |
michael@0 | 25 | // The right way forward would be to never use nsIController |
michael@0 | 26 | // to ask if something in content is enabled. Maybe even |
michael@0 | 27 | // by replacing the nsIController architecture by something else. |
michael@0 | 28 | // See bug 905768. |
michael@0 | 29 | return true; |
michael@0 | 30 | }, |
michael@0 | 31 | |
michael@0 | 32 | supportsCommand: function(aCommand) { |
michael@0 | 33 | // Optimize the lookup a bit. |
michael@0 | 34 | if (!aCommand.startsWith("cmd_")) |
michael@0 | 35 | return false; |
michael@0 | 36 | |
michael@0 | 37 | // For now only support the commands used in "browser-context.inc" |
michael@0 | 38 | let commands = [ |
michael@0 | 39 | "cmd_copyLink", |
michael@0 | 40 | "cmd_copyImage", |
michael@0 | 41 | "cmd_undo", |
michael@0 | 42 | "cmd_cut", |
michael@0 | 43 | "cmd_copy", |
michael@0 | 44 | "cmd_paste", |
michael@0 | 45 | "cmd_delete", |
michael@0 | 46 | "cmd_selectAll", |
michael@0 | 47 | "cmd_switchTextDirection" |
michael@0 | 48 | ]; |
michael@0 | 49 | |
michael@0 | 50 | return commands.indexOf(aCommand) >= 0; |
michael@0 | 51 | }, |
michael@0 | 52 | |
michael@0 | 53 | doCommand: function(aCommand) { |
michael@0 | 54 | this._browser.messageManager.sendAsyncMessage("ControllerCommands:Do", aCommand); |
michael@0 | 55 | }, |
michael@0 | 56 | |
michael@0 | 57 | onEvent: function () {} |
michael@0 | 58 | }; |