diff options
Diffstat (limited to 'toolkit/mozapps/extensions/amInstallTrigger.js')
-rw-r--r-- | toolkit/mozapps/extensions/amInstallTrigger.js | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/toolkit/mozapps/extensions/amInstallTrigger.js b/toolkit/mozapps/extensions/amInstallTrigger.js index 382791d32..a18fe84c4 100644 --- a/toolkit/mozapps/extensions/amInstallTrigger.js +++ b/toolkit/mozapps/extensions/amInstallTrigger.js @@ -39,19 +39,13 @@ function CallbackObject(id, callback, urls, mediator) { }; } -function RemoteMediator(window) { - window.QueryInterface(Ci.nsIInterfaceRequestor); - let utils = window.getInterface(Ci.nsIDOMWindowUtils); - this._windowID = utils.currentInnerWindowID; - - this.mm = window - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIContentFrameMessageManager); - this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this); - +function RemoteMediator(windowID) { + this._windowID = windowID; this._lastCallbackID = 0; this._callbacks = new Map(); + this.mm = Cc["@mozilla.org/childprocessmessagemanager;1"] + .getService(Ci.nsISyncMessageSender); + this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this); } RemoteMediator.prototype = { @@ -142,13 +136,9 @@ InstallTrigger.prototype = { this._principal = window.document.nodePrincipal; this._url = window.document.documentURIObject; - try { - this._mediator = new RemoteMediator(window); - } catch (ex) { - // If we can't set up IPC (e.g., because this is a top-level window - // or something), then don't expose InstallTrigger. - return null; - } + window.QueryInterface(Components.interfaces.nsIInterfaceRequestor); + let utils = window.getInterface(Components.interfaces.nsIDOMWindowUtils); + this._mediator = new RemoteMediator(utils.currentInnerWindowID); return window.InstallTriggerImpl._create(window, this); }, @@ -175,12 +165,12 @@ InstallTrigger.prototype = { item = { URL: item }; } if (!item.URL) { - throw new this._window.Error("Missing URL property for '" + name + "'"); + throw new this._window.DOMError("Error", "Missing URL property for '" + name + "'"); } let url = this._resolveURL(item.URL); if (!this._checkLoadURIFromScript(url)) { - throw new this._window.Error("Insufficient permissions to install: " + url.spec); + throw new this._window.DOMError("SecurityError", "Insufficient permissions to install: " + url.spec); } let iconUrl = null; @@ -213,7 +203,7 @@ InstallTrigger.prototype = { return this.startSoftwareUpdate(url); }, - _resolveURL: function(url) { + _resolveURL: function (url) { return Services.io.newURI(url, null, this._url); }, @@ -225,7 +215,7 @@ InstallTrigger.prototype = { secman.DISALLOW_INHERIT_PRINCIPAL); return true; } - catch (e) { + catch(e) { return false; } }, |