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