settings.js 927 B

123456789101112131415161718192021222324252627282930
  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 {settingsSpec} = require("devtools/shared/specs/settings");
  6. const protocol = require("devtools/shared/protocol");
  7. const SettingsFront = protocol.FrontClassWithSpec(settingsSpec, {
  8. initialize: function (client, form) {
  9. protocol.Front.prototype.initialize.call(this, client);
  10. this.actorID = form.settingsActor;
  11. this.manage(this);
  12. },
  13. });
  14. const _knownSettingsFronts = new WeakMap();
  15. exports.getSettingsFront = function (client, form) {
  16. if (!form.settingsActor) {
  17. return null;
  18. }
  19. if (_knownSettingsFronts.has(client)) {
  20. return _knownSettingsFronts.get(client);
  21. }
  22. let front = new SettingsFront(client, form);
  23. _knownSettingsFronts.set(client, front);
  24. return front;
  25. };