1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/components/BlocklistPrompt.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 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 +const Cc = Components.classes; 1.11 + 1.12 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.13 +Cu.import("resource://gre/modules/Services.jsm"); 1.14 + 1.15 +// ----------------------------------------------------------------------- 1.16 +// BlocklistPrompt Service 1.17 +// ----------------------------------------------------------------------- 1.18 + 1.19 + 1.20 +function BlocklistPrompt() { } 1.21 + 1.22 +BlocklistPrompt.prototype = { 1.23 + prompt: function(aAddons, aCount) { 1.24 + let win = Services.wm.getMostRecentWindow("navigator:browser"); 1.25 + if (win.ExtensionsView.visible) { 1.26 + win.ExtensionsView.showRestart("blocked"); 1.27 + } else { 1.28 + let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); 1.29 + let notifyBox = win.getNotificationBox(); 1.30 + let restartCallback = function(aNotification, aDescription) { 1.31 + // Notify all windows that an application quit has been requested 1.32 + var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool); 1.33 + Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); 1.34 + 1.35 + // If nothing aborted, quit the app 1.36 + if (cancelQuit.data == false) { 1.37 + let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); 1.38 + appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit); 1.39 + } 1.40 + }; 1.41 + 1.42 + let buttons = [{accessKey: null, 1.43 + label: bundle.GetStringFromName("notificationRestart.button"), 1.44 + callback: restartCallback}]; 1.45 + notifyBox.appendNotification(bundle.GetStringFromName("notificationRestart.blocked"), 1.46 + "blocked-add-on", 1.47 + "", 1.48 + "PRIORITY_CRITICAL_HIGH", 1.49 + buttons); 1.50 + } 1.51 + // Disable softblocked items automatically 1.52 + for (let i = 0; i < aAddons.length; i++) { 1.53 + if (aAddons[i].item instanceof Ci.nsIPluginTag) 1.54 + addonList[i].item.disabled = true; 1.55 + else 1.56 + aAddons[i].item.userDisabled = true; 1.57 + } 1.58 + }, 1.59 + classID: Components.ID("{4e6ea350-b09a-11df-94e2-0800200c9a66}"), 1.60 + QueryInterface: XPCOMUtils.generateQI([Ci.nsIBlocklistPrompt]) 1.61 +}; 1.62 + 1.63 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([BlocklistPrompt]); 1.64 +