1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/components/XPIDialogService.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const Ci = Components.interfaces; 1.9 +const Cu = Components.utils; 1.10 + 1.11 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.12 +Cu.import("resource://gre/modules/Services.jsm"); 1.13 + 1.14 +// ----------------------------------------------------------------------- 1.15 +// Web Install Prompt service 1.16 +// ----------------------------------------------------------------------- 1.17 + 1.18 +function WebInstallPrompt() { } 1.19 + 1.20 +WebInstallPrompt.prototype = { 1.21 + classID: Components.ID("{c1242012-27d8-477e-a0f1-0b098ffc329b}"), 1.22 + QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallPrompt]), 1.23 + 1.24 + confirm: function(aWindow, aURL, aInstalls) { 1.25 + let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); 1.26 + 1.27 + let prompt = Services.prompt; 1.28 + let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_IS_STRING + prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL; 1.29 + let title = bundle.GetStringFromName("addonsConfirmInstall.title"); 1.30 + let button = bundle.GetStringFromName("addonsConfirmInstall.install"); 1.31 + 1.32 + aInstalls.forEach(function(install) { 1.33 + let result = (prompt.confirmEx(aWindow, title, install.name, flags, button, null, null, null, {value: false}) == 0); 1.34 + if (result) 1.35 + install.install(); 1.36 + else 1.37 + install.cancel(); 1.38 + }); 1.39 + } 1.40 +}; 1.41 + 1.42 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WebInstallPrompt]);