diff options
Diffstat (limited to 'toolkit/components/jsdownloads/src')
4 files changed, 23 insertions, 56 deletions
diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm index a6875ec48..7656128d2 100644 --- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm +++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm @@ -28,8 +28,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown", "resource://gre/modules/AsyncShutdown.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", - "resource://gre/modules/AppConstants.jsm"); + XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Downloads", @@ -71,10 +70,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gMIMEService", XPCOMUtils.defineLazyServiceGetter(this, "gExternalProtocolService", "@mozilla.org/uriloader/external-protocol-service;1", "nsIExternalProtocolService"); -#ifdef MOZ_WIDGET_ANDROID -XPCOMUtils.defineLazyModuleGetter(this, "RuntimePermissions", - "resource://gre/modules/RuntimePermissions.jsm"); -#endif XPCOMUtils.defineLazyGetter(this, "gParentalControlsService", function() { if ("@mozilla.org/parental-controls-service;1" in Cc) { @@ -300,14 +295,10 @@ this.DownloadIntegration = { aDownload.hasBlockedData) { return true; } -#if defined(MOZ_WIDGET_ANDROID) - // On Android we store all history. - return true; -#else + // On Desktop, stopped downloads for which we don't need to track the // presence of a ".part" file are only retained in the browser history. return false; -#endif }, /** @@ -333,16 +324,8 @@ this.DownloadIntegration = { } else { directoryPath = this._getDirectory("DfltDwnld"); } + #elifdef XP_UNIX -#ifdef MOZ_WIDGET_ANDROID - // Android doesn't have a $HOME directory, and by default we only have - // write access to /data/data/org.mozilla.{$APP} and /sdcard - directoryPath = gEnvironment.get("DOWNLOADS_DIRECTORY"); - if (!directoryPath) { - throw new Components.Exception("DOWNLOADS_DIRECTORY is not set.", - Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH); - } -#else // For Linux, use XDG download dir, with a fallback to Home/Downloads // if the XDG user dirs are disabled. try { @@ -350,7 +333,6 @@ this.DownloadIntegration = { } catch(e) { directoryPath = yield this._createDownloadsDirectory("Home"); } -#endif #else directoryPath = yield this._createDownloadsDirectory("Home"); #endif @@ -404,8 +386,6 @@ this.DownloadIntegration = { let directoryPath = null; #ifdef XP_MACOSX directoryPath = yield this.getPreferredDownloadsDirectory(); -#elifdef MOZ_WIDGET_ANDROID - directoryPath = yield this.getSystemDownloadsDirectory(); #else directoryPath = this._getDirectory("TmpD"); #endif @@ -444,12 +424,7 @@ this.DownloadIntegration = { * @resolves The boolean indicates to block downloads or not. */ shouldBlockForRuntimePermissions() { -#ifdef MOZ_WIDGET_ANDROID - return RuntimePermissions.waitForPermissions(RuntimePermissions.WRITE_EXTERNAL_STORAGE) - .then(permissionGranted => !permissionGranted); -#else return Promise.resolve(false); -#endif }, /** @@ -696,8 +671,11 @@ this.DownloadIntegration = { fileExtension = match[1]; } - let isWindowsExe = AppConstants.platform == "win" && - fileExtension.toLowerCase() == "exe"; +#ifdef XP_WIN + let isWindowsExe = fileExtension.toLowerCase() == "exe"; +#else + let isWindowsExe = false; +#endif // Ask for confirmation if the file is executable, except for .exe on // Windows where the operating system will show the prompt based on the diff --git a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp index d91124ee6..66ad2b8fa 100644 --- a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp +++ b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp @@ -30,10 +30,6 @@ #include "../../../../xpcom/io/CocoaFileUtils.h" #endif -#ifdef MOZ_WIDGET_ANDROID -#include "FennecJNIWrappers.h" -#endif - #ifdef MOZ_WIDGET_GTK #include <gtk/gtk.h> #endif @@ -101,21 +97,15 @@ CFURLRef CreateCFURLFromNSIURI(nsIURI *aURI) { nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIURI* aReferrer, nsIFile* aTarget, const nsACString& aContentType, bool aIsPrivate) { -#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) \ - || defined(MOZ_WIDGET_GTK) +#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK) nsAutoString path; if (aTarget && NS_SUCCEEDED(aTarget->GetPath(path))) { -#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_ANDROID) +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) // On Windows and Gtk, add the download to the system's "recent documents" // list, with a pref to disable. { bool addToRecentDocs = Preferences::GetBool(PREF_BDM_ADDTORECENTDOCS); -#ifdef MOZ_WIDGET_ANDROID - if (jni::IsFennec() && addToRecentDocs) { - java::DownloadsIntegration::ScanMedia(path, aContentType); - } -#else if (addToRecentDocs && !aIsPrivate) { #ifdef XP_WIN ::SHAddToRecentDocs(SHARD_PATHW, path.get()); @@ -130,7 +120,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIURI* aReferrer, nsIF } #endif } -#endif + #ifdef MOZ_ENABLE_GIO // Use GIO to store the source URI for later display in the file manager. GFile* gio_file = g_file_new_for_path(NS_ConvertUTF16toUTF8(path).get()); diff --git a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm index ce165205b..d4ce248e3 100644 --- a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm +++ b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm @@ -22,7 +22,6 @@ const Cu = Components.utils; const Cr = Components.results; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); @@ -186,17 +185,17 @@ this.DownloadPrompter.prototype = { switch (aPromptType) { case this.ON_QUIT: title = s.quitCancelDownloadsAlertTitle; - if (AppConstants.platform != "macosx") { - message = aDownloadsCount > 1 - ? s.quitCancelDownloadsAlertMsgMultiple(aDownloadsCount) - : s.quitCancelDownloadsAlertMsg; - cancelButton = s.dontQuitButtonWin; - } else { - message = aDownloadsCount > 1 - ? s.quitCancelDownloadsAlertMsgMacMultiple(aDownloadsCount) - : s.quitCancelDownloadsAlertMsgMac; - cancelButton = s.dontQuitButtonMac; - } +#ifdef XP_MACOSX + message = aDownloadsCount > 1 + ? s.quitCancelDownloadsAlertMsgMacMultiple(aDownloadsCount) + : s.quitCancelDownloadsAlertMsgMac; + cancelButton = s.dontQuitButtonMac; +#else + message = aDownloadsCount > 1 + ? s.quitCancelDownloadsAlertMsgMultiple(aDownloadsCount) + : s.quitCancelDownloadsAlertMsg; + cancelButton = s.dontQuitButtonWin; +#endif break; case this.ON_OFFLINE: title = s.offlineCancelDownloadsAlertTitle; diff --git a/toolkit/components/jsdownloads/src/moz.build b/toolkit/components/jsdownloads/src/moz.build index 87abed62e..ac3768208 100644 --- a/toolkit/components/jsdownloads/src/moz.build +++ b/toolkit/components/jsdownloads/src/moz.build @@ -19,11 +19,11 @@ EXTRA_JS_MODULES += [ 'DownloadList.jsm', 'Downloads.jsm', 'DownloadStore.jsm', - 'DownloadUIHelper.jsm', ] EXTRA_PP_JS_MODULES += [ 'DownloadIntegration.jsm', + 'DownloadUIHelper.jsm', ] FINAL_LIBRARY = 'xul' |