Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: chrome/browser/download/download_target_determiner.cc

Issue 2117343007: Show download error message if sdcard is not available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_target_determiner.cc
diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc
index 12c75b00e971e50af33bc1282f8030d50465746a..07f13da57e43d0dcaf49177520702e5ac59969e8 100644
--- a/chrome/browser/download/download_target_determiner.cc
+++ b/chrome/browser/download/download_target_determiner.cc
@@ -40,6 +40,11 @@
#include "content/public/common/webplugininfo.h"
#endif
+#if defined(OS_ANDROID)
+#include "chrome/browser/android/download/download_controller.h"
+#include "chrome/browser/android/download/download_manager_service.h"
+#endif
+
#if defined(OS_WIN)
#include "chrome/browser/ui/pdf/adobe_reader_info_win.h"
#endif
@@ -317,13 +322,24 @@ void DownloadTargetDeterminer::ReserveVirtualPathDone(
<< " Verified:" << verified;
DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_);
#if BUILDFLAG(ANDROID_JAVA_UI)
- // If we cannot reserve the path and the WebContent is already gone, there is
- // no way to prompt user for an infobar. This could happen when user try to
- // resume a download after another process has overwritten the same file.
- // TODO(qinmin): show an error toast to the user. http://crbug.com/581106.
- if (!verified && !download_->GetWebContents()) {
- CancelOnFailureAndDeleteSelf();
- return;
+ if (!verified) {
+ if (path.empty()) {
+ CancelOnFailureAndDeleteSelf();
+ DownloadManagerService::OnDownloadCanceled(
+ download_, DownloadController::CANCEL_REASON_NO_EXTERNAL_STORAGE);
+ return;
+ }
+ if (!download_->GetWebContents()) {
+ // If we cannot reserve the path and the WebContent is already gone, there
+ // is no way to prompt user for an infobar. This could happen after chrome
+ // gets killed, and user tries to resume a download while another app has
+ // created the target file (not the temporary .crdownload file).
+ CancelOnFailureAndDeleteSelf();
+ DownloadManagerService::OnDownloadCanceled(
+ download_,
+ DownloadController::CANCEL_REASON_CANNOT_DETERMINE_DOWNLOAD_TARGET);
+ return;
+ }
}
#endif
should_prompt_ = (should_prompt_ || !verified);
« no previous file with comments | « chrome/browser/download/download_path_reservation_tracker_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698