michael@0: // -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: // This Source Code Form is subject to the terms of the Mozilla Public michael@0: // License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: // file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: this.EXPORTED_SYMBOLS = ["RemoteController"]; michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cc = Components.classes; michael@0: const Cu = Components.utils; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: function RemoteController(browser) michael@0: { michael@0: this._browser = browser; michael@0: } michael@0: michael@0: RemoteController.prototype = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIController]), michael@0: michael@0: isCommandEnabled: function(aCommand) { michael@0: // We can't synchronously ask content if a command is enabled, michael@0: // so we always pretend is. michael@0: // The right way forward would be to never use nsIController michael@0: // to ask if something in content is enabled. Maybe even michael@0: // by replacing the nsIController architecture by something else. michael@0: // See bug 905768. michael@0: return true; michael@0: }, michael@0: michael@0: supportsCommand: function(aCommand) { michael@0: // Optimize the lookup a bit. michael@0: if (!aCommand.startsWith("cmd_")) michael@0: return false; michael@0: michael@0: // For now only support the commands used in "browser-context.inc" michael@0: let commands = [ michael@0: "cmd_copyLink", michael@0: "cmd_copyImage", michael@0: "cmd_undo", michael@0: "cmd_cut", michael@0: "cmd_copy", michael@0: "cmd_paste", michael@0: "cmd_delete", michael@0: "cmd_selectAll", michael@0: "cmd_switchTextDirection" michael@0: ]; michael@0: michael@0: return commands.indexOf(aCommand) >= 0; michael@0: }, michael@0: michael@0: doCommand: function(aCommand) { michael@0: this._browser.messageManager.sendAsyncMessage("ControllerCommands:Do", aCommand); michael@0: }, michael@0: michael@0: onEvent: function () {} michael@0: };