customizable-ui.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const { Cu } = require("chrome");
  6. // Because Firefox Holly, we still need to check if `CustomizableUI` is
  7. // available. Once Australis will officially land, we can safely remove it.
  8. // See Bug 959142
  9. try {
  10. Cu.import("resource:///modules/CustomizableUI.jsm", {});
  11. }
  12. catch (e) {
  13. throw Error("Unsupported Application: The module" + module.id +
  14. " does not support this application.");
  15. }
  16. const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
  17. const { receive } = require("../event/utils");
  18. const { InputPort } = require("./system");
  19. const { object} = require("../util/sequence");
  20. const { getOuterId } = require("../window/utils");
  21. const Input = function() {};
  22. Input.prototype = Object.create(InputPort.prototype);
  23. Input.prototype.onCustomizeStart = function (window) {
  24. receive(this, object([getOuterId(window), true]));
  25. }
  26. Input.prototype.onCustomizeEnd = function (window) {
  27. receive(this, object([getOuterId(window), null]));
  28. }
  29. Input.prototype.addListener = input => CustomizableUI.addListener(input);
  30. Input.prototype.removeListener = input => CustomizableUI.removeListener(input);
  31. exports.CustomizationInput = Input;