Bug 1472635 - Prevent suppressing executable warnings using the "don't ask me this again" checkbox. r=Gijs draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 02 Jul 2018 15:42:58 +0100
changeset 813143 8211ad1c94894535b2b98dde0549d7ab52a879b0
parent 812962 3cfc350101967376909ad3c729f9779ae0ab7a94
push id114792
push userpaolo.mozmail@amadzone.org
push dateMon, 02 Jul 2018 14:47:22 +0000
reviewersGijs
bugs1472635
milestone63.0a1
Bug 1472635 - Prevent suppressing executable warnings using the "don't ask me this again" checkbox. r=Gijs A hidden preference matching "browser.download.manager.alertOnEXEOpen" is kept, but is renamed in order to recover cases where the checkbox was used accidentally. This also cleans up duplicate unused strings in the "browser" folder. MozReview-Commit-ID: GyccRiyoVGs
browser/components/downloads/DownloadsCommon.jsm
browser/locales/en-US/chrome/browser/downloads/downloads.properties
toolkit/components/downloads/DownloadUIHelper.jsm
toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties
toolkit/modules/Troubleshoot.jsm
--- a/browser/components/downloads/DownloadsCommon.jsm
+++ b/browser/components/downloads/DownloadsCommon.jsm
@@ -58,17 +58,16 @@ XPCOMUtils.defineLazyGetter(this, "Downl
 
 const kDownloadsStringBundleUrl =
   "chrome://browser/locale/downloads/downloads.properties";
 
 const kDownloadsStringsRequiringFormatting = {
   sizeWithUnits: true,
   statusSeparator: true,
   statusSeparatorBeforeNumber: true,
-  fileExecutableSecurityWarning: true
 };
 
 const kDownloadsStringsRequiringPluralForm = {
   otherDownloads3: true
 };
 
 const kMaxHistoryResultsForLimitedView = 42;
 
--- a/browser/locales/en-US/chrome/browser/downloads/downloads.properties
+++ b/browser/locales/en-US/chrome/browser/downloads/downloads.properties
@@ -87,20 +87,16 @@ sizeUnknown=Unknown size
 # that we use a wider space after the separator when it is followed by a number,
 # just to avoid visually confusing it with with a minus sign with some fonts.
 # If you use a different separator, this might not be necessary.  However, there
 # is usually no need to change the separator or the order of the substitutions,
 # even for right-to-left languages, unless the defaults are not suitable.
 statusSeparator=%1$S \u2014 %2$S
 statusSeparatorBeforeNumber=%1$S \u2014  %2$S
 
-fileExecutableSecurityWarning=“%S” is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch “%S”?
-fileExecutableSecurityWarningTitle=Open Executable File?
-fileExecutableSecurityWarningDontAsk=Don’t ask me this again
-
 # LOCALIZATION NOTE (otherDownloads3):
 # This is displayed in an item at the bottom of the Downloads Panel when
 # there are more downloads than can fit in the list in the panel. Use a
 # semi-colon list of plural forms.
 # See: http://developer.mozilla.org/en/Localization_and_Plurals
 otherDownloads3=%1$S file downloading;%1$S files downloading
 
 # LOCALIZATION NOTE (showLabel, showMacLabel):
--- a/toolkit/components/downloads/DownloadUIHelper.jsm
+++ b/toolkit/components/downloads/DownloadUIHelper.jsm
@@ -102,61 +102,45 @@ this.DownloadPrompter.prototype = {
 
   /**
    * nsIPrompt instance for displaying messages.
    */
   _prompter: null,
 
   /**
    * Displays a warning message box that informs that the specified file is
-   * executable, and asks whether the user wants to launch it.  The user is
-   * given the option of disabling future instances of this warning.
+   * executable, and asks whether the user wants to launch it.
    *
-   * @param aPath
+   * @param path
    *        String containing the full path to the file to be opened.
    *
-   * @return {Promise}
    * @resolves Boolean indicating whether the launch operation can continue.
-   * @rejects JavaScript exception.
    */
-  confirmLaunchExecutable(aPath) {
-    const kPrefAlertOnEXEOpen = "browser.download.manager.alertOnEXEOpen";
+  async confirmLaunchExecutable(path) {
+    const kPrefSkipConfirm = "browser.download.skipConfirmLaunchExecutable";
+
+    // Always launch in case we have no prompter implementation.
+    if (!this._prompter) {
+      return true;
+    }
 
     try {
-      // Always launch in case we have no prompter implementation.
-      if (!this._prompter) {
-        return Promise.resolve(true);
+      if (Services.prefs.getBoolPref(kPrefSkipConfirm)) {
+        return true;
       }
-
-      try {
-        if (!Services.prefs.getBoolPref(kPrefAlertOnEXEOpen)) {
-          return Promise.resolve(true);
-        }
-      } catch (ex) {
-        // If the preference does not exist, continue with the prompt.
-      }
-
-      let leafName = OS.Path.basename(aPath);
+    } catch (ex) {
+      // If the preference does not exist, continue with the prompt.
+    }
 
-      let s = DownloadUIHelper.strings;
-      let checkState = { value: false };
-      let shouldLaunch = this._prompter.confirmCheck(
-                           s.fileExecutableSecurityWarningTitle,
-                           s.fileExecutableSecurityWarning(leafName, leafName),
-                           s.fileExecutableSecurityWarningDontAsk,
-                           checkState);
+    let leafName = OS.Path.basename(path);
 
-      if (shouldLaunch) {
-        Services.prefs.setBoolPref(kPrefAlertOnEXEOpen, !checkState.value);
-      }
-
-      return Promise.resolve(shouldLaunch);
-    } catch (ex) {
-      return Promise.reject(ex);
-    }
+    let s = DownloadUIHelper.strings;
+    return this._prompter.confirm(s.fileExecutableSecurityWarningTitle,
+                                  s.fileExecutableSecurityWarning(leafName,
+                                                                  leafName));
   },
 
   /**
    * Displays a warning message box that informs that there are active
    * downloads, and asks whether the user wants to cancel them or not.
    *
    * @param aDownloadsCount
    *        The current downloads count.
--- a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties
@@ -101,12 +101,11 @@ doneScheme2=%1$S resource
 # This is used as an eTLD replacement for local files, so make it lower case
 doneFileScheme=local file
 
 # LOCALIZATION NOTE (yesterday): Displayed time for files finished yesterday
 yesterday=Yesterday
 
 fileExecutableSecurityWarning=“%S” is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch “%S”?
 fileExecutableSecurityWarningTitle=Open Executable File?
-fileExecutableSecurityWarningDontAsk=Don’t ask me this again
 
 # Desktop folder name for downloaded files
 downloadsFolder=Downloads
--- a/toolkit/modules/Troubleshoot.jsm
+++ b/toolkit/modules/Troubleshoot.jsm
@@ -20,19 +20,19 @@ const PREFS_WHITELIST = [
   "accessibility.",
   "apz.",
   "browser.cache.",
   "browser.display.",
   "browser.download.folderList",
   "browser.download.hide_plugins_without_extensions",
   "browser.download.lastDir.savePerSite",
   "browser.download.manager.addToRecentDocs",
-  "browser.download.manager.alertOnEXEOpen",
   "browser.download.manager.resumeOnWakeDelay",
   "browser.download.preferred.",
+  "browser.download.skipConfirmLaunchExecutable",
   "browser.download.useDownloadDir",
   "browser.fixup.",
   "browser.history_expire_",
   "browser.link.open_newwindow",
   "browser.places.",
   "browser.privatebrowsing.",
   "browser.search.context.loadInBackground",
   "browser.search.log",