michael@0: // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: 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: "use strict"; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: var gArgs; michael@0: michael@0: function init() { michael@0: var hasHardBlocks = false; michael@0: var hasSoftBlocks = false; michael@0: gArgs = window.arguments[0].wrappedJSObject; michael@0: michael@0: // NOTE: We use strings from the "updates.properties" bundleset to change the michael@0: // text on the "Cancel" button to "Restart Later". (bug 523784) michael@0: let bundle = Services.strings. michael@0: createBundle("chrome://mozapps/locale/update/updates.properties"); michael@0: let cancelButton = document.documentElement.getButton("cancel"); michael@0: cancelButton.setAttribute("label", bundle.GetStringFromName("restartLaterButton")); michael@0: cancelButton.setAttribute("accesskey", michael@0: bundle.GetStringFromName("restartLaterButton.accesskey")); michael@0: michael@0: var richlist = document.getElementById("addonList"); michael@0: var list = gArgs.list; michael@0: list.sort(function listSort(a, b) { return String.localeCompare(a.name, b.name); }); michael@0: for (let listItem of list) { michael@0: let item = document.createElement("richlistitem"); michael@0: item.setAttribute("name", listItem.name); michael@0: item.setAttribute("version", listItem.version); michael@0: item.setAttribute("icon", listItem.icon); michael@0: if (listItem.blocked) { michael@0: item.setAttribute("class", "hardBlockedAddon"); michael@0: hasHardBlocks = true; michael@0: } michael@0: else { michael@0: item.setAttribute("class", "softBlockedAddon"); michael@0: hasSoftBlocks = true; michael@0: } michael@0: richlist.appendChild(item); michael@0: } michael@0: michael@0: if (hasHardBlocks && hasSoftBlocks) michael@0: document.getElementById("bothMessage").hidden = false; michael@0: else if (hasHardBlocks) michael@0: document.getElementById("hardBlockMessage").hidden = false; michael@0: else michael@0: document.getElementById("softBlockMessage").hidden = false; michael@0: michael@0: var link = document.getElementById("moreInfo"); michael@0: if (list.length == 1 && list[0].url) { michael@0: link.setAttribute("href", list[0].url); michael@0: } michael@0: else { michael@0: var url = Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL"); michael@0: link.setAttribute("href", url); michael@0: } michael@0: } michael@0: michael@0: function finish(shouldRestartNow) { michael@0: gArgs.restart = shouldRestartNow; michael@0: var list = gArgs.list; michael@0: var items = document.getElementById("addonList").childNodes; michael@0: for (let i = 0; i < list.length; i++) { michael@0: if (!list[i].blocked) michael@0: list[i].disable = items[i].checked; michael@0: } michael@0: return true; michael@0: }