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

Side by Side Diff: chrome/browser/download/download_target_determiner.cc

Issue 1423663012: Removing x-x509-user-cert mime handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding tests. Created 4 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 unified diff | Download patch
OLDNEW
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
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 (suggested_filename.empty() &&
200 download_->GetMimeType() == "application/x-x509-user-cert") {
201 suggested_filename = "user.crt";
202 }
203
197 std::string default_filename( 204 std::string default_filename(
198 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 205 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
199 base::FilePath generated_filename = net::GenerateFileName( 206 base::FilePath generated_filename = net::GenerateFileName(
200 download_->GetURL(), 207 download_->GetURL(),
201 download_->GetContentDisposition(), 208 download_->GetContentDisposition(),
202 GetProfile()->GetPrefs()->GetString(prefs::kDefaultCharset), 209 GetProfile()->GetPrefs()->GetString(prefs::kDefaultCharset),
203 download_->GetSuggestedFilename(), 210 suggested_filename,
204 download_->GetMimeType(), 211 download_->GetMimeType(),
205 default_filename); 212 default_filename);
206 should_prompt_ = ShouldPromptForDownload(generated_filename); 213 should_prompt_ = ShouldPromptForDownload(generated_filename);
207 base::FilePath target_directory; 214 base::FilePath target_directory;
208 if (should_prompt_) { 215 if (should_prompt_) {
209 DCHECK(!download_prefs_->IsDownloadPathManaged()); 216 DCHECK(!download_prefs_->IsDownloadPathManaged());
210 // If the user is going to be prompted and the user has been prompted 217 // 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. 218 // before, then always prefer the last directory that the user selected.
212 target_directory = download_prefs_->SaveFilePath(); 219 target_directory = download_prefs_->SaveFilePath();
213 } else { 220 } else {
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 const base::FilePath& suggested_path) { 903 const base::FilePath& suggested_path) {
897 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); 904 return base::FilePath(suggested_path.value() + kCrdownloadSuffix);
898 } 905 }
899 906
900 #if defined(OS_WIN) 907 #if defined(OS_WIN)
901 // static 908 // static
902 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { 909 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() {
903 return g_is_adobe_reader_up_to_date_; 910 return g_is_adobe_reader_up_to_date_;
904 } 911 }
905 #endif 912 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698