toolkit/mozapps/extensions/content/blocklist.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 // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 "use strict";
michael@0 8
michael@0 9 Components.utils.import("resource://gre/modules/Services.jsm");
michael@0 10
michael@0 11 var gArgs;
michael@0 12
michael@0 13 function init() {
michael@0 14 var hasHardBlocks = false;
michael@0 15 var hasSoftBlocks = false;
michael@0 16 gArgs = window.arguments[0].wrappedJSObject;
michael@0 17
michael@0 18 // NOTE: We use strings from the "updates.properties" bundleset to change the
michael@0 19 // text on the "Cancel" button to "Restart Later". (bug 523784)
michael@0 20 let bundle = Services.strings.
michael@0 21 createBundle("chrome://mozapps/locale/update/updates.properties");
michael@0 22 let cancelButton = document.documentElement.getButton("cancel");
michael@0 23 cancelButton.setAttribute("label", bundle.GetStringFromName("restartLaterButton"));
michael@0 24 cancelButton.setAttribute("accesskey",
michael@0 25 bundle.GetStringFromName("restartLaterButton.accesskey"));
michael@0 26
michael@0 27 var richlist = document.getElementById("addonList");
michael@0 28 var list = gArgs.list;
michael@0 29 list.sort(function listSort(a, b) { return String.localeCompare(a.name, b.name); });
michael@0 30 for (let listItem of list) {
michael@0 31 let item = document.createElement("richlistitem");
michael@0 32 item.setAttribute("name", listItem.name);
michael@0 33 item.setAttribute("version", listItem.version);
michael@0 34 item.setAttribute("icon", listItem.icon);
michael@0 35 if (listItem.blocked) {
michael@0 36 item.setAttribute("class", "hardBlockedAddon");
michael@0 37 hasHardBlocks = true;
michael@0 38 }
michael@0 39 else {
michael@0 40 item.setAttribute("class", "softBlockedAddon");
michael@0 41 hasSoftBlocks = true;
michael@0 42 }
michael@0 43 richlist.appendChild(item);
michael@0 44 }
michael@0 45
michael@0 46 if (hasHardBlocks && hasSoftBlocks)
michael@0 47 document.getElementById("bothMessage").hidden = false;
michael@0 48 else if (hasHardBlocks)
michael@0 49 document.getElementById("hardBlockMessage").hidden = false;
michael@0 50 else
michael@0 51 document.getElementById("softBlockMessage").hidden = false;
michael@0 52
michael@0 53 var link = document.getElementById("moreInfo");
michael@0 54 if (list.length == 1 && list[0].url) {
michael@0 55 link.setAttribute("href", list[0].url);
michael@0 56 }
michael@0 57 else {
michael@0 58 var url = Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL");
michael@0 59 link.setAttribute("href", url);
michael@0 60 }
michael@0 61 }
michael@0 62
michael@0 63 function finish(shouldRestartNow) {
michael@0 64 gArgs.restart = shouldRestartNow;
michael@0 65 var list = gArgs.list;
michael@0 66 var items = document.getElementById("addonList").childNodes;
michael@0 67 for (let i = 0; i < list.length; i++) {
michael@0 68 if (!list[i].blocked)
michael@0 69 list[i].disable = items[i].checked;
michael@0 70 }
michael@0 71 return true;
michael@0 72 }

mercurial