Bug 1538546 - Check AddonManager PERM_CAN_CHANGE_PRIVATEBROWSING_ACCESS permission instead of the incognito manifest property. r=kmag,mixedpuppy a=pascalc
authorLuca Greco <lgreco@mozilla.com>
Tue, 26 Mar 2019 19:04:01 +0000
changeset 525822 381133904780a376d4991883a605457b2faecc86
parent 525821 8935c8db2301fb744209e76212a4222bd0d4ede7
child 525823 cb8b50a3dc6addd0e25b0de62802bbbcbaa8bd8a
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, mixedpuppy, pascalc
bugs1538546
milestone67.0
Bug 1538546 - Check AddonManager PERM_CAN_CHANGE_PRIVATEBROWSING_ACCESS permission instead of the incognito manifest property. r=kmag,mixedpuppy a=pascalc Depends on D24719 Differential Revision: https://phabricator.services.mozilla.com/D24720
browser/modules/ExtensionsUI.jsm
toolkit/mozapps/extensions/content/extensions.js
--- a/browser/modules/ExtensionsUI.jsm
+++ b/browser/modules/ExtensionsUI.jsm
@@ -138,21 +138,20 @@ var ExtensionsUI = {
 
     this.showAddonsManager(browser, strings, addon.iconURL, "sideload")
         .then(async answer => {
           if (answer) {
             await addon.enable();
 
             this._updateNotifications();
 
-            // If private browsing access is not allowed by default,
-            // show the post-install doorhanger notification to
-            // allow the user to give the extension access from the
-            // checkbox included in the doorhanger.
-            if (!allowPrivateBrowsingByDefault && addon.incognito !== "not_allowed") {
+            // The user has just enabled a sideloaded extension, if the permission
+            // can be changed for the extension, show the post-install panel to
+            // give the user that opportunity.
+            if (addon.permissions & AddonManager.PERM_CAN_CHANGE_PRIVATEBROWSING_ACCESS) {
               this.showInstallNotification(browser, addon);
             }
           }
           this.emit("sideload-response");
         });
   },
 
   showUpdate(browser, info) {
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1280,21 +1280,20 @@ var gViewController = {
                 info: {
                   type: "sideload",
                   addon: aAddon,
                   icon: aAddon.iconURL,
                   permissions: perms,
                   resolve() {
                     aAddon.markAsSeen();
                     aAddon.enable().then(() => {
-                      // If private browsing access is not allowed by default,
-                      // show the post-install doorhanger notification to
-                      // allow the user to give the extension access from the
-                      // checkbox included in the doorhanger.
-                      if (!allowPrivateBrowsingByDefault && aAddon.incognito !== "not_allowed") {
+                      // The user has just enabled a sideloaded extension, if the permission
+                      // can be changed for the extension, show the post-install panel to
+                      // give the user that opportunity.
+                      if (aAddon.permissions & AddonManager.PERM_CAN_CHANGE_PRIVATEBROWSING_ACCESS) {
                         Services.obs.notifyObservers({
                           addon: aAddon, target,
                         }, "webextension-install-notify");
                       }
                     });
                   },
                   reject() {},
                 },