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/content/newaddon.js | |
parent | 51279224505ac236d3e4307de1407f889e15c7b0 (diff) | |
download | UXP-bde02587cd2733f0e423c46989e6574fd2cf0d35.tar UXP-bde02587cd2733f0e423c46989e6574fd2cf0d35.tar.gz UXP-bde02587cd2733f0e423c46989e6574fd2cf0d35.tar.lz UXP-bde02587cd2733f0e423c46989e6574fd2cf0d35.tar.xz UXP-bde02587cd2733f0e423c46989e6574fd2cf0d35.zip |
[AllAM] De-duplicate blocklist.js, list.js, newaddon.js, and xpinstallConfirm.js
Diffstat (limited to 'toolkit/mozapps/extensions/content/newaddon.js')
-rw-r--r-- | toolkit/mozapps/extensions/content/newaddon.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/toolkit/mozapps/extensions/content/newaddon.js b/toolkit/mozapps/extensions/content/newaddon.js index e45b3c1cc..b1ad5631b 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); |