mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
f47e2a9937
--HG-- rename : content/base/public/nsIFrameMessageManager.idl => content/base/public/nsIMessageManager.idl
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict"
|
|
|
|
function debug(s) {
|
|
// dump("-*- SettingsChangeNotifier: " + s + "\n");
|
|
}
|
|
|
|
const Cu = Components.utils;
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
|
|
let EXPORTED_SYMBOLS = ["SettingsChangeNotifier"];
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
|
"@mozilla.org/parentprocessmessagemanager;1",
|
|
"nsIMessageBroadcaster");
|
|
|
|
|
|
let SettingsChangeNotifier = {
|
|
init: function() {
|
|
debug("init");
|
|
ppmm.addMessageListener("Settings:Changed", this);
|
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
|
},
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
|
debug("observe");
|
|
ppmm.removeMessageListener("Settings:Changed", this);
|
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
|
ppmm = null;
|
|
},
|
|
|
|
receiveMessage: function(aMessage) {
|
|
debug("receiveMessage");
|
|
let msg = aMessage.json;
|
|
switch (aMessage.name) {
|
|
case "Settings:Changed":
|
|
ppmm.broadcastAsyncMessage("Settings:Change:Return:OK", { key: msg.key, value: msg.value });
|
|
Services.obs.notifyObservers(this, "mozsettings-changed", JSON.stringify({
|
|
key: msg.key,
|
|
value: msg.value
|
|
}));
|
|
break;
|
|
default:
|
|
debug("Wrong message: " + aMessage.name);
|
|
}
|
|
}
|
|
}
|
|
|
|
SettingsChangeNotifier.init();
|