Bug 1192926: Hide system add-ons from the add-ons manager. r=rhelmer
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 24 Sep 2015 11:36:40 -0700
changeset 264445 cc22ed2cafd3f850e00c3b16a45e6a24c1a190bc
parent 264444 9898e4c1387675ceff6e5c514b2b37dc782ae94a
child 264446 7344db584b26c5760582114f7a80e24a7b47aaaa
push id29443
push usercbook@mozilla.com
push dateMon, 28 Sep 2015 12:12:37 +0000
treeherdermozilla-central@3323f5c35ed3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1192926
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1192926: Hide system add-ons from the add-ons manager. r=rhelmer We've wanted a hidden property for add-ons for a while so we can do things like hide "uninstalled" sideloaded add-ons so this adds the basic version of it to hide system add-ons.
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/browser/browser_list.js
toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1675,17 +1675,17 @@ function sortList(aList, aSortBy, aAscen
     aList.appendChild(element);
 }
 
 function getAddonsAndInstalls(aType, aCallback) {
   let addons = null, installs = null;
   let types = (aType != null) ? [aType] : null;
 
   AddonManager.getAddonsByTypes(types, function getAddonsAndInstalls_getAddonsByTypes(aAddonsList) {
-    addons = aAddonsList;
+    addons = aAddonsList.filter(a => !a.hidden);
     if (installs != null)
       aCallback(addons, installs);
   });
 
   AddonManager.getInstallsByTypes(types, function getAddonsAndInstalls_getInstallsByTypes(aInstallsList) {
     // skip over upgrade installs and non-active installs
     installs = aInstallsList.filter(function installsFilter(aInstall) {
       return !(aInstall.existingAddon ||
@@ -2737,16 +2737,19 @@ var gListView = {
     sortList(this._listBox, aSortBy, aAscending);
   },
 
   onExternalInstall: function gListView_onExternalInstall(aAddon, aExistingAddon, aRequiresRestart) {
     // The existing list item will take care of upgrade installs
     if (aExistingAddon)
       return;
 
+    if (aAddon.hidden)
+      return;
+
     this.addItem(aAddon);
   },
 
   onDownloadStarted: function gListView_onDownloadStarted(aInstall) {
     this.addItem(aInstall, true);
   },
 
   onInstallStarted: function gListView_onInstallStarted(aInstall) {
@@ -3529,17 +3532,17 @@ var gUpdatesView = {
     var self = this;
     AddonManager.getAllAddons(function showRecentUpdates_getAllAddons(aAddonsList) {
       if (gViewController && aRequest != gViewController.currentViewRequest)
         return;
 
       var elements = [];
       let threshold = Date.now() - UPDATES_RECENT_TIMESPAN;
       for (let addon of aAddonsList) {
-        if (!addon.updateDate || addon.updateDate.getTime() < threshold)
+        if (addon.hidden || !addon.updateDate || addon.updateDate.getTime() < threshold)
           continue;
 
         elements.push(createItem(addon));
       }
 
       self.showEmptyNotice(elements.length == 0);
       if (elements.length > 0) {
         sortElements(elements, [self._sorters.sortBy], self._sorters.ascending);
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -6802,16 +6802,21 @@ function AddonWrapper(aAddon) {
       // Only set softDisabled if not already disabled
       if (!aAddon.userDisabled)
         aAddon.softDisabled = val;
     }
 
     return val;
   });
 
+  this.__defineGetter__("hidden", function AddonWrapper_hidden() {
+    return (aAddon._installLocation.name == KEY_APP_SYSTEM_DEFAULTS ||
+            aAddon._installLocation.name == KEY_APP_SYSTEM_ADDONS);
+  });
+
   this.isCompatibleWith = function AddonWrapper_isCompatiblewith(aAppVersion, aPlatformVersion) {
     return aAddon.isCompatibleWith(aAppVersion, aPlatformVersion);
   };
 
   this.uninstall = function AddonWrapper_uninstall() {
     if (!(aAddon.inDatabase))
       throw new Error("Cannot uninstall an add-on that isn't installed");
     if (aAddon.pendingUninstall)
--- a/toolkit/mozapps/extensions/test/browser/browser_list.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_list.js
@@ -113,16 +113,20 @@ add_task(function*() {
     isActive: false,
     appDisabled: true,
     foreignInstall: true,
   }, {
     id: "addon13@tests.mozilla.org",
     name: "Test add-on 13",
     signedState: AddonManager.SIGNEDSTATE_SIGNED,
     foreignInstall: true,
+  }, {
+    id: "addon15@tests.mozilla.org",
+    name: "Test add-on 15",
+    hidden: true,
   }]);
 
   gManagerWindow = yield open_manager(null);
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
 });
 
 function get_test_items() {
   var tests = "@tests.mozilla.org";
@@ -681,16 +685,20 @@ add_task(function*() {
 add_task(function*() {
   gProvider.createAddons([{
     id: "addon1@tests.mozilla.org",
     name: "Test add-on replacement",
     version: "2.0",
     description: "A test add-on with a new description",
     updateDate: gDate,
     operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
+  }, {
+    id: "addon14@tests.mozilla.org",
+    name: "Test add-on 14",
+    hidden: true,
   }]);
 
   let items = get_test_items();
   is(Object.keys(items).length, EXPECTED_ADDONS, "Should be the right number of add-ons installed");
 
   let addon = items["Test add-on replacement"];
   addon.parentNode.ensureElementIsVisible(addon);
   let { name, version } = yield get_tooltip_info(addon);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
@@ -48,16 +48,17 @@ function* check_installed(inProfile, ...
     if (versions[i]) {
       // Add-on should be installed
       do_check_neq(addon, null);
       do_check_eq(addon.version, versions[i]);
       do_check_true(addon.isActive);
       do_check_false(addon.foreignInstall);
       do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UPGRADE));
       do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UNINSTALL));
+      do_check_true(addon.hidden);
 
       // Verify the add-ons file is in the right place
       let file = expectedDir.clone();
       file.append(id + ".xpi");
       do_check_true(file.exists());
       do_check_true(file.isFile());
 
       let uri = addon.getResourceURI(null);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
@@ -133,16 +133,17 @@ function* check_installed(inProfile, ...
     let addon = yield promiseAddonByID(id);
 
     if (versions[i]) {
       // Add-on should be installed
       do_check_neq(addon, null);
       do_check_eq(addon.version, versions[i]);
       do_check_true(addon.isActive);
       do_check_false(addon.foreignInstall);
+      go_check_true(addon.hidden);
 
       // Verify the add-ons file is in the right place
       let uri = addon.getResourceURI(null);
       do_check_true(uri instanceof AM_Ci.nsIFileURL);
 
       let file = uri.file.parent;
       if (inProfile) {
         file = file.parent;