diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
commit | 39dac57259cff8b61db0b22cb2ad0a8adb02692e (patch) | |
tree | 52a026cc8c22793eb17fd0f5e22adce1ae08a1dd /toolkit/components/downloads/nsDownloadManager.cpp | |
parent | a1cce3b2b00bbd9f4983013ddd8934a7bccb9e99 (diff) | |
parent | c2d9ab62f3d097c9e0e00184cab1f546554f5eaa (diff) | |
download | UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.gz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.lz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.xz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.zip |
Merge branch 'redwood' into 28.9-platform
Diffstat (limited to 'toolkit/components/downloads/nsDownloadManager.cpp')
-rw-r--r-- | toolkit/components/downloads/nsDownloadManager.cpp | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp index ab984c5f2..587c1ac8a 100644 --- a/toolkit/components/downloads/nsDownloadManager.cpp +++ b/toolkit/components/downloads/nsDownloadManager.cpp @@ -61,10 +61,6 @@ #include <CoreFoundation/CoreFoundation.h> #endif -#ifdef MOZ_WIDGET_ANDROID -#include "FennecJNIWrappers.h" -#endif - #ifdef MOZ_WIDGET_GTK #include <gtk/gtk.h> #endif @@ -1421,19 +1417,6 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsIFile **aResult) } } #elif defined(XP_UNIX) -#if defined(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 - char* downloadDirPath = getenv("DOWNLOADS_DIRECTORY"); - if (downloadDirPath) { - rv = NS_NewNativeLocalFile(nsDependentCString(downloadDirPath), - true, getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - } - else { - rv = NS_ERROR_FAILURE; - } -#else rv = dirService->Get(NS_UNIX_DEFAULT_DOWNLOAD_DIR, NS_GET_IID(nsIFile), getter_AddRefs(downloadDir)); @@ -1446,7 +1429,6 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsIFile **aResult) rv = downloadDir->Append(folderName); NS_ENSURE_SUCCESS(rv, rv); } -#endif #else rv = dirService->Get(NS_OS_HOME_DIR, NS_GET_IID(nsIFile), @@ -1847,6 +1829,9 @@ nsDownloadManager::RetryDownload(nsDownload* dl) return rv; } + rv = NotifyDownloadRemoval(dl); + NS_ENSURE_SUCCESS(rv, rv); + // reset time and download progress dl->SetStartTime(PR_Now()); dl->SetProgressBytes(0, -1); @@ -2685,14 +2670,6 @@ nsDownload::SetState(DownloadState aState) case nsIDownloadManager::DOWNLOAD_DIRTY: case nsIDownloadManager::DOWNLOAD_CANCELED: case nsIDownloadManager::DOWNLOAD_FAILED: -#ifdef ANDROID - // If we still have a temp file, remove it - bool tempExists; - if (mTempFile && NS_SUCCEEDED(mTempFile->Exists(&tempExists)) && tempExists) { - nsresult rv = mTempFile->Remove(false); - NS_ENSURE_SUCCESS(rv, rv); - } -#endif // Transfers are finished, so break the reference cycle Finalize(); @@ -2770,7 +2747,7 @@ nsDownload::SetState(DownloadState aState) } } -#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) nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget); nsCOMPtr<nsIFile> file; nsAutoString path; @@ -2780,27 +2757,13 @@ nsDownload::SetState(DownloadState aState) file && NS_SUCCEEDED(file->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 = true; if (pref) pref->GetBoolPref(PREF_BDM_ADDTORECENTDOCS, &addToRecentDocs); -#ifdef MOZ_WIDGET_ANDROID - if (addToRecentDocs) { - nsCOMPtr<nsIMIMEInfo> mimeInfo; - nsAutoCString contentType; - GetMIMEInfo(getter_AddRefs(mimeInfo)); - - if (mimeInfo) - mimeInfo->GetMIMEType(contentType); - - if (jni::IsFennec()) { - java::DownloadsIntegration::ScanMedia(path, NS_ConvertUTF8toUTF16(contentType)); - } - } -#else if (addToRecentDocs && !mPrivate) { #ifdef XP_WIN ::SHAddToRecentDocs(SHARD_PATHW, path.get()); @@ -2815,7 +2778,6 @@ nsDownload::SetState(DownloadState aState) } #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()); @@ -3124,7 +3086,7 @@ nsDownload::OnStateChange(nsIWebProgress *aWebProgress, #else (void)SetState(nsIDownloadManager::DOWNLOAD_FINISHED); #endif - } else { + } else if (aStatus != NS_BINDING_ABORTED) { // We failed for some unknown reason -- fail with a generic message (void)FailDownload(aStatus, nullptr); } |