Bug 1170851 - Warn about add-ons detected as no longer signed. r=mfinkle,Mossop
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 10 Jun 2015 08:48:01 -0400
changeset 266934 e2566fef5f245cad3dad95b71db79b1578d22f5d
parent 266933 a33b99e5c8d3a29b00b5165fe17ca6ee54615432
child 266935 59d7a4a0bd32a87621c2ef23eb78507d0d6224c3
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, Mossop
bugs1170851
milestone41.0a1
Bug 1170851 - Warn about add-ons detected as no longer signed. r=mfinkle,Mossop
mobile/android/chrome/content/browser.js
mobile/android/locales/en-US/chrome/browser.properties
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -6184,29 +6184,31 @@ let HealthReportStatusListener = {
             prefs: jsonP,
           },
         });
       }.bind(this));
   },
 };
 
 var XPInstallObserver = {
-  init: function xpi_init() {
-    Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
-    Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
-
-    AddonManager.addInstallListener(XPInstallObserver);
-  },
-
-  observe: function xpi_observer(aSubject, aTopic, aData) {
+  init: function() {
+    Services.obs.addObserver(this, "addon-install-blocked", false);
+    Services.obs.addObserver(this, "addon-install-started", false);
+    Services.obs.addObserver(this, "xpi-signature-changed", false);
+    Services.obs.addObserver(this, "browser-delayed-startup-finished", false);
+
+    AddonManager.addInstallListener(this);
+  },
+
+  observe: function(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "addon-install-started":
         NativeWindow.toast.show(Strings.browser.GetStringFromName("alertAddonsDownloading"), "short");
         break;
-      case "addon-install-blocked":
+      case "addon-install-blocked": {
         let installInfo = aSubject.QueryInterface(Ci.amIWebInstallInfo);
         let tab = BrowserApp.getTabForBrowser(installInfo.browser);
         if (!tab)
           return;
 
         let host = null;
         if (installInfo.originatingURI) {
           host = installInfo.originatingURI.host;
@@ -6263,17 +6265,51 @@ var XPInstallObserver = {
               installInfo.install();
               return false;
             },
             positive: true
           }];
         }
         NativeWindow.doorhanger.show(message, aTopic, buttons, tab.id);
         break;
-    }
+      }
+      case "xpi-signature-changed": {
+        if (JSON.parse(aData).disabled.length) {
+          this._notifyUnsignedAddonsDisabled();
+        }
+        break;
+      }
+      case "browser-delayed-startup-finished": {
+        let disabledAddons = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
+        for (let id of disabledAddons) {
+          if (AddonManager.getAddonByID(id).signedState <= AddonManager.SIGNEDSTATE_MISSING) {
+            this._notifyUnsignedAddonsDisabled();
+            break;
+          }
+        }
+        break;
+      }
+    }
+  },
+
+  _notifyUnsignedAddonsDisabled: function() {
+    new Prompt({
+      window: window,
+      title: Strings.browser.GetStringFromName("unsignedAddonsDisabled.title"),
+      message: Strings.browser.GetStringFromName("unsignedAddonsDisabled.message"),
+      buttons: [
+        Strings.browser.GetStringFromName("unsignedAddonsDisabled.viewAddons"),
+        Strings.browser.GetStringFromName("unsignedAddonsDisabled.dismiss")
+      ]
+    }).show((data) => {
+      if (data.button === 0) {
+        // TODO: Open about:addons to show only unsigned add-ons?
+        BrowserApp.addTab("about:addons", { parentId: BrowserApp.selectedTab.id });
+      }
+    });
   },
 
   onInstallEnded: function(aInstall, aAddon) {
     // Don't create a notification for distribution add-ons.
     if (Distribution.pendingAddonInstalls.has(aInstall)) {
       Distribution.pendingAddonInstalls.delete(aInstall);
       return;
     }
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -40,16 +40,23 @@ alertSearchEngineDuplicateToast='%S' is 
 
 downloadCancelPromptTitle=Cancel Download
 downloadCancelPromptMessage=Do you want to cancel this download?
 
 addonError.titleError=Error
 addonError.titleBlocked=Blocked add-on
 addonError.learnMore=Learn more
 
+# LOCALIZATION NOTE (unsignedAddonsDisabled.title, unsignedAddonsDisabled.message):
+# These strings will appear in a dialog when Firefox detects that installed add-ons cannot be verified.
+unsignedAddonsDisabled.title=Unverified add-ons
+unsignedAddonsDisabled.message=One or more installed add-ons cannot be verified and have been disabled.
+unsignedAddonsDisabled.dismiss=Dismiss
+unsignedAddonsDisabled.viewAddons=View add-ons
+
 # LOCALIZATION NOTE (addonError-1, addonError-2, addonError-3, addonError-4, addonError-5):
 # #1 is the add-on name, #2 is the add-on host, #3 is the application name
 addonError-1=The add-on could not be downloaded because of a connection failure on #2.
 addonError-2=The add-on from #2 could not be installed because it does not match the add-on #3 expected.
 addonError-3=The add-on downloaded from #2 could not be installed because it appears to be corrupt.
 addonError-4=#1 could not be installed because #3 cannot modify the needed file.
 addonError-5=#3 has prevented #2 from installing an unverified add-on.