From 91d0ac111926a2afb2d229f82f4fe91333f6a1cc Mon Sep 17 00:00:00 2001 From: anonym Date: Tue, 28 Jun 2016 14:23:00 +0200 Subject: [PATCH] Bug 1281959 - Add a pref hiding the "Open with" option. r=dolske If browser.download.forbid_open_with is set to true (default: false) the download dialog will not ever show the "Open with" option for opening the file with an external application; only the "Save" and "Cancel" options will be available. This is very useful to enable when the browser is sandboxed (e.g. via AppArmor) in such a way that it is forbidden to run external applications, since users then are not presented with this choice which will not work and only cause confusion. See https://trac.torproject.org/17502 --- modules/libpref/init/all.js | 3 +++ toolkit/mozapps/downloads/nsHelperAppDlg.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index fc00960a3c4f..783e76e07877 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -112,6 +112,9 @@ pref("offline-apps.quota.warn", 51200); // cache compression turned off for now - see bug #715198 pref("browser.cache.compression_level", 0); +// Don't show "Open with" option on download dialog if true. +pref("browser.download.forbid_open_with", false); + // Whether or not testing features are enabled. pref("dom.quotaManager.testing", false); diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 80397c54b0cf..a8a41f88a7a4 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -472,7 +472,8 @@ nsUnknownContentTypeDialog.prototype = { var shouldntRememberChoice = (mimeType == "application/octet-stream" || mimeType == "application/x-msdownload" || this.mLauncher.targetFileIsExecutable); - if (shouldntRememberChoice && !this.openWithDefaultOK()) { + if ((shouldntRememberChoice && !this.openWithDefaultOK()) || + Services.prefs.getBoolPref("browser.download.forbid_open_with")) { // hide featured choice this.dialogElement("normalBox").collapsed = true; // show basic choice