Bug 1544489 use separate strings to localize install prompt for unknown sites. r=flod,aswan
authorShane Caraveo <scaraveo@mozilla.com>
Mon, 29 Apr 2019 19:00:55 +0000
changeset 471790 d7f798e98a7577980d1ab8985f1886cbd09fbcaa
parent 471789 87f038262ac3d4431a569c1fad9bee5668a332de
child 471791 9b16812e723e3dff41c118cd9bcd1f7535452f36
push id35935
push usershindli@mozilla.com
push dateTue, 30 Apr 2019 03:46:04 +0000
treeherdermozilla-central@f3c2a7206699 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflod, aswan
bugs1544489
milestone68.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 1544489 use separate strings to localize install prompt for unknown sites. r=flod,aswan Differential Revision: https://phabricator.services.mozilla.com/D27606
browser/base/content/browser-addons.js
browser/locales/en-US/chrome/browser/browser.properties
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -409,38 +409,46 @@ var gXPInstallObserver = {
       let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
       secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_ADDON_ASKING_PREVENTED);
       let popup = PopupNotifications.show(browser, notificationID,
                                           messageString, anchorID,
                                           null, null, options);
       removeNotificationOnEnd(popup, installInfo.installs);
       break; }
     case "addon-install-blocked": {
-      messageString = gNavigatorBundle.getFormattedString("xpinstallPromptMessage.header", ["<>"]);
-      let unknown = gNavigatorBundle.getString("xpinstallPromptMessage.unknown");
-      options.name = options.displayURI && options.displayURI.displayHost || unknown;
+      let hasHost = !!options.displayURI;
+      if (hasHost) {
+        messageString = gNavigatorBundle.getFormattedString("xpinstallPromptMessage.header", ["<>"]);
+        options.name = options.displayURI.displayHost;
+      } else {
+        messageString = gNavigatorBundle.getString("xpinstallPromptMessage.header.unknown");
+      }
       // displayURI becomes it's own label, so we unset it for this panel. It will become part of the
       // messageString above.
       options.displayURI = undefined;
 
       options.eventCallback = (topic) => {
         if (topic !== "showing") {
           return;
         }
         let doc = browser.ownerDocument;
         let message = doc.getElementById("addon-install-blocked-message");
         // We must remove any prior use of this panel message in this window.
         while (message.firstChild) {
           message.firstChild.remove();
         }
-        let text = gNavigatorBundle.getString("xpinstallPromptMessage.message");
-        let b = doc.createElementNS("http://www.w3.org/1999/xhtml", "b");
-        b.textContent = options.name;
-        let fragment = BrowserUtils.getLocalizedFragment(doc, text, b);
-        message.appendChild(fragment);
+        if (hasHost) {
+          let text = gNavigatorBundle.getString("xpinstallPromptMessage.message");
+          let b = doc.createElementNS("http://www.w3.org/1999/xhtml", "b");
+          b.textContent = options.name;
+          let fragment = BrowserUtils.getLocalizedFragment(doc, text, b);
+          message.appendChild(fragment);
+        } else {
+          message.textContent = gNavigatorBundle.getString("xpinstallPromptMessage.message.unknown");
+        }
         let learnMore = doc.getElementById("addon-install-blocked-info");
         learnMore.textContent = gNavigatorBundle.getString("xpinstallPromptMessage.learnMore");
         learnMore.setAttribute("href", Services.urlFormatter.formatURLPref("app.support.baseURL") + "unlisted-extensions-risks");
       };
 
       let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
       action = {
         label: gNavigatorBundle.getString("xpinstallPromptMessage.install"),
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -20,20 +20,18 @@ contextMenuSearch.accesskey=S
 
 bookmarkAllTabsDefault=[Folder Name]
 
 xpinstallPromptMessage=%S prevented this site from asking you to install software on your computer.
 # LOCALIZATION NOTE (xpinstallPromptMessage.header)
 # The string contains the hostname of the site the add-on is being installed from.
 xpinstallPromptMessage.header=Allow %S to install an add-on?
 xpinstallPromptMessage.message=You are attempting to install an add-on from %S. Make sure you trust this site before continuing.
-# LOCALIZATION NOTE (xpinstallPromptMessage.unknown)
-# This string is used in xpinstallPromptMessage.header and xpinstallPromptMessage.message when the domain is not available,
-# for example in case of local installs with drag and drop.
-xpinstallPromptMessage.unknown=an unknown site
+xpinstallPromptMessage.header.unknown=Allow an unknown site to install an add-on?
+xpinstallPromptMessage.message.unknown=You are attempting to install an add-on from an unknown site. Make sure you trust this site before continuing.
 xpinstallPromptMessage.learnMore=Learn more about installing add-ons safely
 xpinstallPromptMessage.dontAllow=Don’t Allow
 xpinstallPromptMessage.dontAllow.accesskey=D
 # Accessibility Note:
 # Be sure you do not choose an accesskey that is used elsewhere in the active context (e.g. main menu bar, submenu of the warning popup button)
 # See https://website-archive.mozilla.org/www.mozilla.org/access/access/keyboard/ for details
 xpinstallPromptMessage.install=Continue to Installation
 xpinstallPromptMessage.install.accesskey=C