Bug 951895 - Hook up SpecialPowers messagemanager correctly for B2G, r=ahal

This commit is contained in:
Jonathan Griffin 2013-12-19 17:04:20 -08:00
parent 23a675daa4
commit 53f340cae0
2 changed files with 15 additions and 3 deletions

View File

@ -55,9 +55,10 @@ if (outOfProcess) {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js", specialpowers);
let specialPowersObserver = new specialpowers.SpecialPowersObserver();
specialPowersObserver.init();
let mm = container.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
specialPowersObserver.init(mm);
mm.addMessageListener("SPPrefService", specialPowersObserver);
mm.addMessageListener("SPProcessCrashService", specialPowersObserver);
mm.addMessageListener("SPPingService", specialPowersObserver);

View File

@ -28,6 +28,7 @@ loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js
/* XPCOM gunk */
this.SpecialPowersObserver = function SpecialPowersObserver() {
this._isFrameScriptLoaded = false;
this._mmIsGlobal = true;
this._messageManager = Cc["@mozilla.org/globalmessagemanager;1"].
getService(Ci.nsIMessageBroadcaster);
}
@ -81,18 +82,28 @@ SpecialPowersObserver.prototype = new SpecialPowersObserverAPI();
SpecialPowersObserver.prototype._sendAsyncMessage = function(msgname, msg)
{
this._messageManager.broadcastAsyncMessage(msgname, msg);
if (this._mmIsGlobal) {
this._messageManager.broadcastAsyncMessage(msgname, msg);
}
else {
this._messageManager.sendAsyncMessage(msgname, msg);
}
};
SpecialPowersObserver.prototype._receiveMessage = function(aMessage) {
return this._receiveMessageAPI(aMessage);
};
SpecialPowersObserver.prototype.init = function()
SpecialPowersObserver.prototype.init = function(messageManager)
{
var obs = Services.obs;
obs.addObserver(this, "xpcom-shutdown", false);
obs.addObserver(this, "chrome-document-global-created", false);
if (messageManager) {
this._messageManager = messageManager;
this._mmIsGlobal = false;
}
};
SpecialPowersObserver.prototype.uninit = function()