Bug 566020 - Add support for custom confirmation UI [r=dtownsend]
--- a/toolkit/mozapps/extensions/amIWebInstallListener.idl
+++ b/toolkit/mozapps/extensions/amIWebInstallListener.idl
@@ -98,8 +98,33 @@ interface amIWebInstallListener : nsISup
* @param aCount
* The number of AddonInstalls
* @return true if the caller should start the installs
*/
boolean onWebInstallRequested(in nsIDOMWindowInternal aWindow, in nsIURI aUri,
[array, size_is(aCount)] in nsIVariant aInstalls,
[optional] in PRUint32 aCount);
};
+
+/**
+ * amIWebInstallPrompt is used, if available, by the default implementation of
+ * amIWebInstallInfo to display a confirmation UI to the user before running
+ * installs.
+ */
+[scriptable, uuid(c5529918-4291-4b56-bd46-e9268900f2a3)]
+interface amIWebInstallPrompt : nsISupports
+{
+ /**
+ * Get a confirmation that the user wants to start the installs.
+ *
+ * @param aWindow
+ * The window that triggered the installs
+ * @param aUri
+ * The URI of the site that triggered the installs
+ * @param aInstalls
+ * The AddonInstalls that were requested
+ * @param aCount
+ * The number of AddonInstalls
+ */
+ void confirm(in nsIDOMWindowInternal aWindow, in nsIURI aUri,
+ [array, size_is(aCount)] in nsIVariant aInstalls,
+ [optional] in PRUint32 aCount);
+};
--- a/toolkit/mozapps/extensions/amWebInstallListener.js
+++ b/toolkit/mozapps/extensions/amWebInstallListener.js
@@ -106,16 +106,26 @@ Installer.prototype = {
checkAllDownloaded: function() {
if (--this.count > 0)
return;
// Maybe none of the downloads were sucessful
if (this.installs.length == 0)
return;
+ if ("@mozilla.org/addons/web-install-prompt;1" in Cc) {
+ try {
+ let prompt = Cc["@mozilla.org/addons/web-install-prompt;1"].
+ getService(Ci.amIWebInstallPrompt);
+ prompt.confirm(this.window, this.url, this.installs, this.installs.length);
+ return;
+ }
+ catch (e) {}
+ }
+
let args = {};
args.url = this.url;
args.installs = this.installs;
args.wrappedJSObject = args;
Services.ww.openWindow(this.window, "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul",
null, "chrome,modal,centerscreen", args);
},