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