michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: // ----------------------------------------------------------------------- michael@0: // Web Install Prompt service michael@0: // ----------------------------------------------------------------------- michael@0: michael@0: function WebInstallPrompt() { } michael@0: michael@0: WebInstallPrompt.prototype = { michael@0: classID: Components.ID("{c1242012-27d8-477e-a0f1-0b098ffc329b}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallPrompt]), michael@0: michael@0: confirm: function(aWindow, aURL, aInstalls) { michael@0: let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); michael@0: michael@0: let prompt = Services.prompt; michael@0: let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_IS_STRING + prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL; michael@0: let title = bundle.GetStringFromName("addonsConfirmInstall.title"); michael@0: let button = bundle.GetStringFromName("addonsConfirmInstall.install"); michael@0: michael@0: aInstalls.forEach(function(install) { michael@0: let result = (prompt.confirmEx(aWindow, title, install.name, flags, button, null, null, null, {value: false}) == 0); michael@0: if (result) michael@0: install.install(); michael@0: else michael@0: install.cancel(); michael@0: }); michael@0: } michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WebInstallPrompt]);