Bug 1445630 - Don't show new tab message for distribution add-ons. r=aswan a=lizzard
authorMichael Kaply <mozilla@kaply.com>
Wed, 18 Apr 2018 16:44:41 -0500
changeset 463540 4153d533726099707951c23d69ae33cf0d56cbb8
parent 463539 60833cda57c29e3797f16332bdf6289cc4e930a9
child 463541 e30deae7bb9432539f3ab66be4c5517392d9cff6
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, lizzard
bugs1445630
milestone60.0
Bug 1445630 - Don't show new tab message for distribution add-ons. r=aswan a=lizzard MozReview-Commit-ID: HVVB13W59MU
browser/components/extensions/ext-url-overrides.js
--- 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);