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

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

Issue 2618743006: Use previous target path when resuming a download after crash (Closed)
Patch Set: adding a helper function to get last used target path Created 3 years, 11 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 fbc35cfeef8854132e5eca8142f25ca88397ccbe..6d830a31cd2b0afdef2ff6915ae4f070813af3c9 100644
--- a/chrome/browser/download/download_target_determiner.cc
+++ b/chrome/browser/download/download_target_determiner.cc
@@ -191,16 +191,17 @@ DownloadTargetDeterminer::Result
DCHECK(!should_prompt_);
DCHECK(!should_notify_extensions_);
DCHECK_EQ(DownloadPathReservationTracker::OVERWRITE, conflict_action_);
- bool is_forced_path = !download_->GetForcedFilePath().empty();
+ // If the download already has a forced path or a target path, use it.
+ bool has_target_path = !download_->GetLastUsedTargetPath().empty();
asanka 2017/01/10 19:34:19 Implement the GetForcedFilePath() || GetTargetFile
qinmin 2017/01/10 22:06:29 Done.
next_state_ = STATE_NOTIFY_EXTENSIONS;
- if (!virtual_path_.empty() && HasPromptedForPath() && !is_forced_path) {
+ if (!virtual_path_.empty() && HasPromptedForPath() && !has_target_path) {
// The download is being resumed and the user has already been prompted for
// a path. Assume that it's okay to overwrite the file if there's a conflict
// and reuse the selection.
should_prompt_ = ShouldPromptForDownload(virtual_path_);
- } else if (!is_forced_path) {
+ } else if (!has_target_path) {
// If we don't have a forced path, we should construct a path for the
// download. Forced paths are only specified for programmatic downloads
// (WebStore, Drag&Drop). Treat the path as a virtual path. We will
@@ -240,7 +241,7 @@ DownloadTargetDeterminer::Result
#endif
should_notify_extensions_ = true;
} else {
- virtual_path_ = download_->GetForcedFilePath();
+ virtual_path_ = download_->GetLastUsedTargetPath();
// If this is a resumed download which was previously interrupted due to an
// issue with the forced path, the user is still not prompted. If the path
// supplied to a programmatic download is invalid, then the caller needs to

Powered by Google App Engine
This is Rietveld 408576698