summaryrefslogtreecommitdiffstats
path: root/toolkit/components/jsdownloads
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/jsdownloads')
-rw-r--r--toolkit/components/jsdownloads/src/DownloadIntegration.jsm56
-rw-r--r--toolkit/components/jsdownloads/src/DownloadPlatform.cpp2
-rw-r--r--toolkit/components/jsdownloads/src/DownloadUIHelper.jsm58
3 files changed, 54 insertions, 62 deletions
diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
index 1c30599f5..305284749 100644
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -300,12 +300,7 @@ this.DownloadIntegration = {
aDownload.hasBlockedData) {
return true;
}
-#ifdef MOZ_B2G
- // On B2G we keep a few days of history.
- let maxTime = Date.now() -
- Services.prefs.getIntPref("dom.downloads.max_retention_days") * 24 * 60 * 60 * 1000;
- return aDownload.startTime > maxTime;
-#elif defined(MOZ_WIDGET_ANDROID)
+#if defined(MOZ_WIDGET_ANDROID)
// On Android we store all history.
return true;
#else
@@ -415,8 +410,6 @@ this.DownloadIntegration = {
directoryPath = yield this.getPreferredDownloadsDirectory();
#elifdef MOZ_WIDGET_ANDROID
directoryPath = yield this.getSystemDownloadsDirectory();
-#elifdef MOZ_WIDGET_GONK
- directoryPath = yield this.getSystemDownloadsDirectory();
#else
directoryPath = this._getDirectory("TmpD");
#endif
@@ -480,6 +473,12 @@ this.DownloadIntegration = {
* }
*/
shouldBlockForReputationCheck(aDownload) {
+#ifndef MOZ_URL_CLASSIFIER
+ return Promise.resolve({
+ shouldBlock: false,
+ verdict: "",
+ });
+#else
let hash;
let sigInfo;
let channelRedirects;
@@ -520,6 +519,7 @@ this.DownloadIntegration = {
});
});
return deferred.promise;
+#endif
},
#ifdef XP_WIN
@@ -530,20 +530,34 @@ this.DownloadIntegration = {
* @return true if files should be marked
*/
_shouldSaveZoneInformation() {
- let key = Cc["@mozilla.org/windows-registry-key;1"]
- .createInstance(Ci.nsIWindowsRegKey);
+ let zonePref = 2;
try {
- key.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Attachments",
- Ci.nsIWindowsRegKey.ACCESS_QUERY_VALUE);
- try {
- return key.readIntValue("SaveZoneInformation") != 1;
- } finally {
- key.close();
- }
- } catch (ex) {
- // If the key is not present, files should be marked by default.
- return true;
+ zonePref = Services.prefs.getIntPref("browser.download.saveZoneInformation");
+ } catch (ex) {}
+
+ switch (zonePref) {
+ case 0: // Never
+ return false;
+ case 1: // Always
+ return true;
+ case 2: // System-defined
+ let key = Cc["@mozilla.org/windows-registry-key;1"]
+ .createInstance(Ci.nsIWindowsRegKey);
+ try {
+ key.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Attachments",
+ Ci.nsIWindowsRegKey.ACCESS_QUERY_VALUE);
+ try {
+ return key.readIntValue("SaveZoneInformation") != 1;
+ } finally {
+ key.close();
+ }
+ } catch (ex) {
+ // If the key is not present, files should be marked by default.
+ return true;
+ }
+ default: // Invalid pref value defaults marking files.
+ return true;
}
},
#endif
diff --git a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp
index 1506b7c30..d91124ee6 100644
--- a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp
+++ b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp
@@ -102,7 +102,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIURI* aReferrer, nsIF
const nsACString& aContentType, bool aIsPrivate)
{
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) \
- || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GONK)
+ || defined(MOZ_WIDGET_GTK)
nsAutoString path;
if (aTarget && NS_SUCCEEDED(aTarget->GetPath(path))) {
diff --git a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm
index f5102b4a8..ce165205b 100644
--- a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm
@@ -106,12 +106,7 @@ XPCOMUtils.defineLazyGetter(DownloadUIHelper, "strings", function () {
*/
this.DownloadPrompter = function (aParent)
{
- if (AppConstants.MOZ_B2G) {
- // On B2G there is no prompter implementation.
- this._prompter = null;
- } else {
- this._prompter = Services.ww.getNewPrompter(aParent);
- }
+ this._prompter = Services.ww.getNewPrompter(aParent);
}
this.DownloadPrompter.prototype = {
@@ -129,52 +124,35 @@ this.DownloadPrompter.prototype = {
/**
* 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
* 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: function (aPath)
+ async confirmLaunchExecutable: function (aPath)
{
- const kPrefAlertOnEXEOpen = "browser.download.manager.alertOnEXEOpen";
-
- try {
- // Always launch in case we have no prompter implementation.
- if (!this._prompter) {
- return Promise.resolve(true);
- }
-
- try {
- if (!Services.prefs.getBoolPref(kPrefAlertOnEXEOpen)) {
- return Promise.resolve(true);
- }
- } catch (ex) {
- // If the preference does not exist, continue with the prompt.
- }
+ const kPrefConfirmOpenExe = "browser.download.confirmOpenExecutable";
- let leafName = OS.Path.basename(aPath);
-
- let s = DownloadUIHelper.strings;
- let checkState = { value: false };
- let shouldLaunch = this._prompter.confirmCheck(
- s.fileExecutableSecurityWarningTitle,
- s.fileExecutableSecurityWarning(leafName, leafName),
- s.fileExecutableSecurityWarningDontAsk,
- checkState);
+ // Always launch in case we have no prompter implementation.
+ if (!this._prompter) {
+ return true;
+ }
- if (shouldLaunch) {
- Services.prefs.setBoolPref(kPrefAlertOnEXEOpen, !checkState.value);
+ try {
+ if (!Services.prefs.getBoolPref(kPrefConfirmOpenExe)) {
+ return true;
}
-
- return Promise.resolve(shouldLaunch);
} catch (ex) {
- return Promise.reject(ex);
+ // If the preference does not exist, continue with the prompt.
}
+
+ let leafName = OS.Path.basename(aPath);
+
+ let s = DownloadUIHelper.strings;
+ return this._prompter.confirm(s.fileExecutableSecurityWarningTitle,
+ s.fileExecutableSecurityWarning(leafName, leafName));
},
/**