Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/download/download_target_determiner.h" | 5 #include "chrome/browser/download/download_target_determiner.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // The download is being resumed and the user has already been prompted for | 187 // The download is being resumed and the user has already been prompted for |
| 188 // a path. Assume that it's okay to overwrite the file if there's a conflict | 188 // a path. Assume that it's okay to overwrite the file if there's a conflict |
| 189 // and reuse the selection. | 189 // and reuse the selection. |
| 190 should_prompt_ = ShouldPromptForDownload(virtual_path_); | 190 should_prompt_ = ShouldPromptForDownload(virtual_path_); |
| 191 } else if (!is_forced_path) { | 191 } else if (!is_forced_path) { |
| 192 // If we don't have a forced path, we should construct a path for the | 192 // If we don't have a forced path, we should construct a path for the |
| 193 // download. Forced paths are only specified for programmatic downloads | 193 // download. Forced paths are only specified for programmatic downloads |
| 194 // (WebStore, Drag&Drop). Treat the path as a virtual path. We will | 194 // (WebStore, Drag&Drop). Treat the path as a virtual path. We will |
| 195 // eventually determine whether this is a local path and if not, figure out | 195 // eventually determine whether this is a local path and if not, figure out |
| 196 // a local path. | 196 // a local path. |
| 197 | |
| 198 std::string suggested_filename = download_->GetSuggestedFilename(); | |
| 199 if (download_->GetMimeType() == "application/x-x509-user-cert") | |
|
asanka
2016/01/11 21:52:42
How about conditionalizing this on suggested_filen
| |
| 200 suggested_filename = "user.crt"; | |
| 201 | |
| 197 std::string default_filename( | 202 std::string default_filename( |
| 198 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); | 203 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); |
| 199 base::FilePath generated_filename = net::GenerateFileName( | 204 base::FilePath generated_filename = net::GenerateFileName( |
| 200 download_->GetURL(), | 205 download_->GetURL(), |
| 201 download_->GetContentDisposition(), | 206 download_->GetContentDisposition(), |
| 202 GetProfile()->GetPrefs()->GetString(prefs::kDefaultCharset), | 207 GetProfile()->GetPrefs()->GetString(prefs::kDefaultCharset), |
| 203 download_->GetSuggestedFilename(), | 208 suggested_filename, |
| 204 download_->GetMimeType(), | 209 download_->GetMimeType(), |
| 205 default_filename); | 210 default_filename); |
| 206 should_prompt_ = ShouldPromptForDownload(generated_filename); | 211 should_prompt_ = ShouldPromptForDownload(generated_filename); |
| 207 base::FilePath target_directory; | 212 base::FilePath target_directory; |
| 208 if (should_prompt_) { | 213 if (should_prompt_) { |
| 209 DCHECK(!download_prefs_->IsDownloadPathManaged()); | 214 DCHECK(!download_prefs_->IsDownloadPathManaged()); |
| 210 // If the user is going to be prompted and the user has been prompted | 215 // If the user is going to be prompted and the user has been prompted |
| 211 // before, then always prefer the last directory that the user selected. | 216 // before, then always prefer the last directory that the user selected. |
| 212 target_directory = download_prefs_->SaveFilePath(); | 217 target_directory = download_prefs_->SaveFilePath(); |
| 213 } else { | 218 } else { |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 const base::FilePath& suggested_path) { | 901 const base::FilePath& suggested_path) { |
| 897 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); | 902 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); |
| 898 } | 903 } |
| 899 | 904 |
| 900 #if defined(OS_WIN) | 905 #if defined(OS_WIN) |
| 901 // static | 906 // static |
| 902 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { | 907 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { |
| 903 return g_is_adobe_reader_up_to_date_; | 908 return g_is_adobe_reader_up_to_date_; |
| 904 } | 909 } |
| 905 #endif | 910 #endif |
| OLD | NEW |