toolkit/modules/RemoteController.jsm

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial