Bug 1445630 - Don't show new tab message for distribution add-ons. r?aswan
MozReview-Commit-ID: HVVB13W59MU
--- a/browser/components/extensions/ext-url-overrides.js
+++ b/browser/components/extensions/ext-url-overrides.js
@@ -16,16 +16,17 @@ ChromeUtils.defineModuleGetter(this, "Ex
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
const STORE_TYPE = "url_overrides";
const NEW_TAB_SETTING_NAME = "newTabURL";
const NEW_TAB_CONFIRMED_TYPE = "newTabNotification";
+const PREF_BRANCH_INSTALLED_ADDON = "extensions.installedDistroAddon.";
XPCOMUtils.defineLazyGetter(this, "strBundle", function() {
return Services.strings.createBundle("chrome://global/locale/extensions.properties");
});
function userWasNotified(extensionId) {
let setting = ExtensionSettingsStore.getSetting(NEW_TAB_CONFIRMED_TYPE, extensionId);
return setting && setting.value;
@@ -58,24 +59,34 @@ function replaceUrlInTab(gBrowser, tab,
},
});
});
gBrowser.loadURIWithFlags(
url, {flags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY});
return loaded;
}
+let gDistributionAddonsList;
+
+function isDistributionAddon(id) {
+ if (!gDistributionAddonsList) {
+ gDistributionAddonsList = Services.prefs.getChildList(PREF_BRANCH_INSTALLED_ADDON)
+ .map(id => id.replace(PREF_BRANCH_INSTALLED_ADDON, ""));
+ }
+ return gDistributionAddonsList.includes(id);
+}
+
async function handleNewTabOpened() {
// We don't need to open the doorhanger again until the controlling add-on changes.
// eslint-disable-next-line no-use-before-define
removeNewTabObserver();
let item = ExtensionSettingsStore.getSetting(STORE_TYPE, NEW_TAB_SETTING_NAME);
- if (!item || !item.id || userWasNotified(item.id)) {
+ if (!item || !item.id || userWasNotified(item.id) || isDistributionAddon(item.id)) {
return;
}
// Find the elements we need.
let win = windowTracker.getCurrentWindow({});
let doc = win.document;
let panel = doc.getElementById("extension-notification-panel");
let addon = await AddonManager.getAddonByID(item.id);