Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 };