mobile/android/components/BlocklistPrompt.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 const Ci = Components.interfaces;
michael@0 6 const Cu = Components.utils;
michael@0 7 const Cc = Components.classes;
michael@0 8
michael@0 9 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 10 Cu.import("resource://gre/modules/Services.jsm");
michael@0 11
michael@0 12 // -----------------------------------------------------------------------
michael@0 13 // BlocklistPrompt Service
michael@0 14 // -----------------------------------------------------------------------
michael@0 15
michael@0 16
michael@0 17 function BlocklistPrompt() { }
michael@0 18
michael@0 19 BlocklistPrompt.prototype = {
michael@0 20 prompt: function(aAddons, aCount) {
michael@0 21 let win = Services.wm.getMostRecentWindow("navigator:browser");
michael@0 22 if (win.ExtensionsView.visible) {
michael@0 23 win.ExtensionsView.showRestart("blocked");
michael@0 24 } else {
michael@0 25 let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
michael@0 26 let notifyBox = win.getNotificationBox();
michael@0 27 let restartCallback = function(aNotification, aDescription) {
michael@0 28 // Notify all windows that an application quit has been requested
michael@0 29 var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
michael@0 30 Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
michael@0 31
michael@0 32 // If nothing aborted, quit the app
michael@0 33 if (cancelQuit.data == false) {
michael@0 34 let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
michael@0 35 appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
michael@0 36 }
michael@0 37 };
michael@0 38
michael@0 39 let buttons = [{accessKey: null,
michael@0 40 label: bundle.GetStringFromName("notificationRestart.button"),
michael@0 41 callback: restartCallback}];
michael@0 42 notifyBox.appendNotification(bundle.GetStringFromName("notificationRestart.blocked"),
michael@0 43 "blocked-add-on",
michael@0 44 "",
michael@0 45 "PRIORITY_CRITICAL_HIGH",
michael@0 46 buttons);
michael@0 47 }
michael@0 48 // Disable softblocked items automatically
michael@0 49 for (let i = 0; i < aAddons.length; i++) {
michael@0 50 if (aAddons[i].item instanceof Ci.nsIPluginTag)
michael@0 51 addonList[i].item.disabled = true;
michael@0 52 else
michael@0 53 aAddons[i].item.userDisabled = true;
michael@0 54 }
michael@0 55 },
michael@0 56 classID: Components.ID("{4e6ea350-b09a-11df-94e2-0800200c9a66}"),
michael@0 57 QueryInterface: XPCOMUtils.generateQI([Ci.nsIBlocklistPrompt])
michael@0 58 };
michael@0 59
michael@0 60 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([BlocklistPrompt]);
michael@0 61

mercurial