fune/mobile/android/components/XPIDialogService.js
Kris Maglione a259026c9d Bug 1456035: Part 4 - Convert callers of XPCOMUtils.generateQI to ChromeUtils.generateQI. r=mccr8
This also removes any redundant Ci.nsISupports elements in the interface
lists.

This was done using the following script:

acecb401b7/processors/chromeutils-generateQI.jsm

MozReview-Commit-ID: AIx10P8GpZY

--HG--
extra : rebase_source : a29c07530586dc18ba040f19215475ac20fcfb3b
2018-04-22 20:55:06 -07:00

46 lines
1.9 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/. */
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
// -----------------------------------------------------------------------
// Web Install Prompt service
// -----------------------------------------------------------------------
function WebInstallPrompt() { }
WebInstallPrompt.prototype = {
classID: Components.ID("{c1242012-27d8-477e-a0f1-0b098ffc329b}"),
QueryInterface: ChromeUtils.generateQI([Ci.amIWebInstallPrompt]),
confirm: function(aBrowser, aURL, aInstalls) {
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
let prompt = Services.prompt;
let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_IS_STRING + prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL;
let title = bundle.GetStringFromName("addonsConfirmInstall.title");
let button = bundle.GetStringFromName("addonsConfirmInstall.install");
aInstalls.forEach(function(install) {
let message;
if (install.addon.signedState <= AddonManager.SIGNEDSTATE_MISSING) {
title = bundle.GetStringFromName("addonsConfirmInstallUnsigned.title");
message = bundle.GetStringFromName("addonsConfirmInstallUnsigned.message") + "\n\n" + install.name;
} else {
message = install.name;
}
let result = (prompt.confirmEx(aBrowser.contentWindow, title, message, flags, button, null, null, null, {value: false}) == 0);
if (result)
install.install();
else
install.cancel();
});
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WebInstallPrompt]);