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

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

Issue 2618743006: Use previous target path when resuming a download after crash (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/download/download_target_determiner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e1e55f68cf9b29a995847aa6dfcacdb459530cc0 100644
--- a/chrome/browser/download/download_target_determiner.cc
+++ b/chrome/browser/download/download_target_determiner.cc
@@ -191,16 +191,18 @@ 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_->GetForcedFilePath().empty()
+ || !download_->GetTargetFilePath().empty();
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 +242,8 @@ DownloadTargetDeterminer::Result
#endif
should_notify_extensions_ = true;
} else {
- virtual_path_ = download_->GetForcedFilePath();
+ virtual_path_ = download_->GetForcedFilePath().empty() ?
David Trainor- moved to gerrit 2017/01/06 23:26:41 Since we're using this logic a lot, would it be cl
qinmin 2017/01/09 22:17:27 Done.
+ download_->GetTargetFilePath() : download_->GetForcedFilePath();
// 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
« no previous file with comments | « no previous file | chrome/browser/download/download_target_determiner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698