Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / toolkit / actors / ControllersParent.sys.mjs
blob05ea16611259da01dd27b087b1aae94348e4b5af
1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
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 export class ControllersParent extends JSWindowActorParent {
7   constructor() {
8     super();
10     // A map of commands that have had their enabled/disabled state assigned. The
11     // value of each key will be true if enabled, and false if disabled.
12     this.supportedCommands = {};
13   }
15   get browser() {
16     return this.browsingContext.top.embedderElement;
17   }
19   // Update the set of enabled and disabled commands.
20   enableDisableCommands(aAction, aEnabledCommands, aDisabledCommands) {
21     // Clear the list first
22     this.supportedCommands = {};
24     for (let command of aEnabledCommands) {
25       this.supportedCommands[command] = true;
26     }
28     for (let command of aDisabledCommands) {
29       this.supportedCommands[command] = false;
30     }
32     let browser = this.browser;
33     if (browser) {
34       browser.ownerGlobal.updateCommands(aAction);
35     }
36   }
38   isCommandEnabled(aCommand) {
39     return this.supportedCommands[aCommand] || false;
40   }
42   supportsCommand(aCommand) {
43     return aCommand in this.supportedCommands;
44   }
46   doCommand(aCommand) {
47     this.sendAsyncMessage("ControllerCommands:Do", aCommand);
48   }
50   getCommandStateWithParams(aCommand, aCommandParams) {
51     throw Components.Exception("Not implemented", Cr.NS_ERROR_NOT_IMPLEMENTED);
52   }
54   doCommandWithParams(aCommand, aCommandParams) {
55     let cmd = {
56       cmd: aCommand,
57       params: null,
58     };
59     if (aCommand == "cmd_lookUpDictionary") {
60       cmd.params = {
61         x: {
62           type: "long",
63           value: aCommandParams.getLongValue("x"),
64         },
65         y: {
66           type: "long",
67           value: aCommandParams.getLongValue("y"),
68         },
69       };
70     } else {
71       throw Components.Exception(
72         "Not implemented",
73         Cr.NS_ERROR_NOT_IMPLEMENTED
74       );
75     }
76     this.sendAsyncMessage("ControllerCommands:DoWithParams", cmd);
77   }
79   getSupportedCommands() {
80     throw Components.Exception("Not implemented", Cr.NS_ERROR_NOT_IMPLEMENTED);
81   }
83   onEvent() {}
86 ControllersParent.prototype.QueryInterface = ChromeUtils.generateQI([
87   "nsIBrowserController",
88   "nsIController",
89   "nsICommandController",
90 ]);