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: const Cc = Components.classes; 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: // BlocklistPrompt Service michael@0: // ----------------------------------------------------------------------- michael@0: michael@0: michael@0: function BlocklistPrompt() { } michael@0: michael@0: BlocklistPrompt.prototype = { michael@0: prompt: function(aAddons, aCount) { michael@0: let win = Services.wm.getMostRecentWindow("navigator:browser"); michael@0: if (win.ExtensionsView.visible) { michael@0: win.ExtensionsView.showRestart("blocked"); michael@0: } else { michael@0: let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); michael@0: let notifyBox = win.getNotificationBox(); michael@0: let restartCallback = function(aNotification, aDescription) { michael@0: // Notify all windows that an application quit has been requested michael@0: var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool); michael@0: Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); michael@0: michael@0: // If nothing aborted, quit the app michael@0: if (cancelQuit.data == false) { michael@0: let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); michael@0: appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit); michael@0: } michael@0: }; michael@0: michael@0: let buttons = [{accessKey: null, michael@0: label: bundle.GetStringFromName("notificationRestart.button"), michael@0: callback: restartCallback}]; michael@0: notifyBox.appendNotification(bundle.GetStringFromName("notificationRestart.blocked"), michael@0: "blocked-add-on", michael@0: "", michael@0: "PRIORITY_CRITICAL_HIGH", michael@0: buttons); michael@0: } michael@0: // Disable softblocked items automatically michael@0: for (let i = 0; i < aAddons.length; i++) { michael@0: if (aAddons[i].item instanceof Ci.nsIPluginTag) michael@0: addonList[i].item.disabled = true; michael@0: else michael@0: aAddons[i].item.userDisabled = true; michael@0: } michael@0: }, michael@0: classID: Components.ID("{4e6ea350-b09a-11df-94e2-0800200c9a66}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIBlocklistPrompt]) michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([BlocklistPrompt]); michael@0: