2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2009-04-22 07:19:48 -07:00
|
|
|
|
|
|
|
const Ci = Components.interfaces;
|
2010-07-13 07:36:09 -07:00
|
|
|
const Cu = Components.utils;
|
2009-04-22 07:19:48 -07:00
|
|
|
|
2010-07-13 07:36:09 -07:00
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2009-04-22 07:19:48 -07:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2010-05-19 19:43:02 -07:00
|
|
|
// Web Install Prompt service
|
2009-04-22 07:19:48 -07:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-05-19 19:43:02 -07:00
|
|
|
function WebInstallPrompt() { }
|
2009-04-22 07:19:48 -07:00
|
|
|
|
2010-05-19 19:43:02 -07:00
|
|
|
WebInstallPrompt.prototype = {
|
2009-04-22 07:19:48 -07:00
|
|
|
classID: Components.ID("{c1242012-27d8-477e-a0f1-0b098ffc329b}"),
|
2010-05-19 19:43:02 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallPrompt]),
|
2009-04-22 07:19:48 -07:00
|
|
|
|
2010-05-19 19:43:02 -07:00
|
|
|
confirm: function(aWindow, aURL, aInstalls) {
|
2010-07-13 07:36:09 -07:00
|
|
|
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
2009-09-02 10:54:25 -07:00
|
|
|
|
2010-07-13 07:36:09 -07:00
|
|
|
let prompt = Services.prompt;
|
2009-09-02 10:54:25 -07:00
|
|
|
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");
|
|
|
|
|
2010-05-19 19:43:02 -07:00
|
|
|
aInstalls.forEach(function(install) {
|
|
|
|
let result = (prompt.confirmEx(aWindow, title, install.name, flags, button, null, null, null, {value: false}) == 0);
|
|
|
|
if (result)
|
|
|
|
install.install();
|
|
|
|
else
|
|
|
|
install.cancel();
|
|
|
|
});
|
|
|
|
}
|
2009-04-22 07:19:48 -07:00
|
|
|
};
|
|
|
|
|
2010-06-29 14:02:25 -07:00
|
|
|
const NSGetFactory = XPCOMUtils.generateNSGetFactory([WebInstallPrompt]);
|