| 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 f1d1845138c9e82acb617c042c178e5ba0136088..6b0b7c46a2217764bbb822ef831ef55618311cbe 100644
|
| --- a/chrome/browser/download/download_target_determiner.cc
|
| +++ b/chrome/browser/download/download_target_determiner.cc
|
| @@ -201,44 +201,52 @@ DownloadTargetDeterminer::Result
|
| // and reuse the selection.
|
| should_prompt_ = ShouldPromptForDownload(virtual_path_);
|
| } else if (!is_forced_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
|
| - // eventually determine whether this is a local path and if not, figure out
|
| - // a local path.
|
| -
|
| - std::string suggested_filename = download_->GetSuggestedFilename();
|
| - if (suggested_filename.empty() &&
|
| - download_->GetMimeType() == "application/x-x509-user-cert") {
|
| - suggested_filename = "user.crt";
|
| - }
|
| -
|
| - std::string default_filename(
|
| - l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
|
| - base::FilePath generated_filename = net::GenerateFileName(
|
| - download_->GetURL(),
|
| - download_->GetContentDisposition(),
|
| - GetProfile()->GetPrefs()->GetString(prefs::kDefaultCharset),
|
| - suggested_filename,
|
| - download_->GetMimeType(),
|
| - default_filename);
|
| - should_prompt_ = ShouldPromptForDownload(generated_filename);
|
| - base::FilePath target_directory;
|
| - if (should_prompt_) {
|
| - DCHECK(!download_prefs_->IsDownloadPathManaged());
|
| - // If the user is going to be prompted and the user has been prompted
|
| - // before, then always prefer the last directory that the user selected.
|
| - target_directory = download_prefs_->SaveFilePath();
|
| + // If the download already has a target path, use it.
|
| + if (!download_->GetTargetFilePath().empty()) {
|
| + virtual_path_ = download_->GetTargetFilePath();
|
| + // If the download is interrupted due to file errors, prompt user for
|
| + // a new path.
|
| + should_prompt_ = ShouldPromptForDownload(virtual_path_);
|
| } else {
|
| - target_directory = download_prefs_->DownloadPath();
|
| + // 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
|
| + // eventually determine whether this is a local path and if not, figure
|
| + // out a local path.
|
| +
|
| + std::string suggested_filename = download_->GetSuggestedFilename();
|
| + if (suggested_filename.empty() &&
|
| + download_->GetMimeType() == "application/x-x509-user-cert") {
|
| + suggested_filename = "user.crt";
|
| + }
|
| +
|
| + std::string default_filename(
|
| + l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
|
| + base::FilePath generated_filename = net::GenerateFileName(
|
| + download_->GetURL(),
|
| + download_->GetContentDisposition(),
|
| + GetProfile()->GetPrefs()->GetString(prefs::kDefaultCharset),
|
| + suggested_filename,
|
| + download_->GetMimeType(),
|
| + default_filename);
|
| + should_prompt_ = ShouldPromptForDownload(generated_filename);
|
| + base::FilePath target_directory;
|
| + if (should_prompt_) {
|
| + DCHECK(!download_prefs_->IsDownloadPathManaged());
|
| + // If the user is going to be prompted and the user has been prompted
|
| + // before, then always prefer the last directory that the user selected.
|
| + target_directory = download_prefs_->SaveFilePath();
|
| + } else {
|
| + target_directory = download_prefs_->DownloadPath();
|
| + }
|
| + virtual_path_ = target_directory.Append(generated_filename);
|
| + should_notify_extensions_ = true;
|
| }
|
| - virtual_path_ = target_directory.Append(generated_filename);
|
| #if defined(OS_ANDROID)
|
| conflict_action_ = DownloadPathReservationTracker::PROMPT;
|
| #else
|
| conflict_action_ = DownloadPathReservationTracker::UNIQUIFY;
|
| #endif
|
| - should_notify_extensions_ = true;
|
| } else {
|
| virtual_path_ = download_->GetForcedFilePath();
|
| // If this is a resumed download which was previously interrupted due to an
|
|
|