diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-06-26 15:15:09 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-06-26 15:15:09 -0400 |
commit | bde02587cd2733f0e423c46989e6574fd2cf0d35 (patch) | |
tree | 0d210e60b4eef024067f32e461eb8bbf442726e2 /toolkit/mozapps/extensions | |
parent | 51279224505ac236d3e4307de1407f889e15c7b0 (diff) | |
download | uxp-bde02587cd2733f0e423c46989e6574fd2cf0d35.tar.gz |
[AllAM] De-duplicate blocklist.js, list.js, newaddon.js, and xpinstallConfirm.js
Diffstat (limited to 'toolkit/mozapps/extensions')
-rw-r--r-- | toolkit/mozapps/extensions/content/blocklist.js | 2 | ||||
-rw-r--r-- | toolkit/mozapps/extensions/content/list.js | 8 | ||||
-rw-r--r-- | toolkit/mozapps/extensions/content/newaddon.js | 20 | ||||
-rw-r--r-- | toolkit/mozapps/extensions/content/xpinstallConfirm.js | 14 |
4 files changed, 26 insertions, 18 deletions
diff --git a/toolkit/mozapps/extensions/content/blocklist.js b/toolkit/mozapps/extensions/content/blocklist.js index 6b47fd6529..6d524e6eee 100644 --- a/toolkit/mozapps/extensions/content/blocklist.js +++ b/toolkit/mozapps/extensions/content/blocklist.js @@ -26,7 +26,7 @@ function init() { var richlist = document.getElementById("addonList"); var list = gArgs.list; - list.sort(function listSort(a, b) { return String.localeCompare(a.name, b.name); }); + list.sort(function(a, b) { return String.localeCompare(a.name, b.name); }); for (let listItem of list) { let item = document.createElement("richlistitem"); item.setAttribute("name", listItem.name); diff --git a/toolkit/mozapps/extensions/content/list.js b/toolkit/mozapps/extensions/content/list.js index aac87911ed..a31922703e 100644 --- a/toolkit/mozapps/extensions/content/list.js +++ b/toolkit/mozapps/extensions/content/list.js @@ -16,11 +16,11 @@ const kDialog = "dialog"; * caller can inspect the user action after the dialog closes by inspecting the * value of the |result| parameter on this object which is set to the dlgtype * of the button used to close the dialog. - * + * * window.arguments[0] is an array of strings to display in the tree. If the * array is empty the tree will not be displayed. * window.arguments[1] a JS Object with the following properties: - * + * * title: A title string, to be displayed in the title bar of the dialog. * message1: A message string, displayed above the addon list * message2: A message string, displayed below the addon list @@ -39,7 +39,7 @@ const kDialog = "dialog"; * ... * }, * - * result: The dlgtype of button that was used to dismiss the dialog. + * result: The dlgtype of button that was used to dismiss the dialog. */ "use strict"; @@ -113,7 +113,7 @@ function init() { message.appendChild(document.createTextNode(params[messageEntry])); } } - + document.getElementById("infoIcon").className = params["iconClass"] ? "spaced " + params["iconClass"] : "spaced alert-icon"; diff --git a/toolkit/mozapps/extensions/content/newaddon.js b/toolkit/mozapps/extensions/content/newaddon.js index e45b3c1ccd..b1ad5631b5 100644 --- a/toolkit/mozapps/extensions/content/newaddon.js +++ b/toolkit/mozapps/extensions/content/newaddon.js @@ -13,7 +13,7 @@ var gAddon = null; // If the user enables the add-on through some other UI close this window var EnableListener = { - onEnabling: function EnableListener_onEnabling(aAddon) { + onEnabling: function(aAddon) { if (aAddon.id == gAddon.id) window.close(); } @@ -38,11 +38,11 @@ function initialize() { let bundle = Services.strings.createBundle("chrome://mozapps/locale/extensions/newaddon.properties"); - AddonManager.getAddonByID(id, function initialize_getAddonByID(aAddon) { - // If the add-on doesn't exist or it is already enabled or it cannot be - // enabled then this UI is useless, just close it. This shouldn't normally - // happen unless session restore restores the tab - if (!aAddon || !aAddon.userDisabled || + AddonManager.getAddonByID(id, function(aAddon) { + // If the add-on doesn't exist or it is already enabled or it has already + // been seen or it cannot be enabled then this UI is useless, just close it. + // This shouldn't normally happen unless session restore restores the tab. + if (!aAddon || !aAddon.userDisabled || aAddon.seen || !(aAddon.permissions & AddonManager.PERM_CAN_ENABLE)) { window.close(); return; @@ -79,6 +79,14 @@ function initialize() { document.getElementById("location").hidden = true; } + // Only mark the add-on as seen if the page actually gets focus + if (document.hasFocus()) { + aAddon.markAsSeen(); + } + else { + document.addEventListener("focus", () => aAddon.markAsSeen(), false); + } + var event = document.createEvent("Events"); event.initEvent("AddonDisplayed", true, true); document.dispatchEvent(event); diff --git a/toolkit/mozapps/extensions/content/xpinstallConfirm.js b/toolkit/mozapps/extensions/content/xpinstallConfirm.js index 678e37001e..5660cdaaf7 100644 --- a/toolkit/mozapps/extensions/content/xpinstallConfirm.js +++ b/toolkit/mozapps/extensions/content/xpinstallConfirm.js @@ -6,7 +6,7 @@ var XPInstallConfirm = {}; -XPInstallConfirm.init = function XPInstallConfirm_init() +XPInstallConfirm.init = function() { Components.utils.import("resource://gre/modules/AddonManager.jsm"); @@ -36,7 +36,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init() var delay_in_milliseconds = prefs.getIntPref("security.dialog_enable_delay"); _installCountdownLength = Math.round(delay_in_milliseconds / 500); } catch (ex) { } - + var itemList = document.getElementById("itemList"); let installMap = new WeakMap(); @@ -47,7 +47,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init() window.close(); } }; - + var numItemsToInstall = args.installs.length; for (let install of args.installs) { var installItem = document.createElement("installitem"); @@ -72,7 +72,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init() installMap.set(install, installItem); install.addListener(installListener); } - + var introString = bundle.getString("itemWarnIntroSingle"); if (numItemsToInstall > 4) introString = bundle.getFormattedString("itemWarnIntroMultiple", [numItemsToInstall]); @@ -81,7 +81,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init() while (introNode.hasChildNodes()) introNode.removeChild(introNode.firstChild); introNode.appendChild(textNode); - + var okButton = document.documentElement.getButton("accept"); okButton.focus(); @@ -177,7 +177,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init() okButton.label = bundle.getString("installButtonLabel"); } -XPInstallConfirm.onOK = function XPInstallConfirm_onOk() +XPInstallConfirm.onOK = function() { Components.classes["@mozilla.org/base/telemetry;1"]. getService(Components.interfaces.nsITelemetry). @@ -188,7 +188,7 @@ XPInstallConfirm.onOK = function XPInstallConfirm_onOk() return true; } -XPInstallConfirm.onCancel = function XPInstallConfirm_onCancel() +XPInstallConfirm.onCancel = function() { // Perform the install or cancel after the window has unloaded XPInstallConfirm._installOK = false; |