| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if (!suggested_path.empty()) { | 262 if (!suggested_path.empty()) { |
| 263 // If an extension overrides the filename, then the target directory will be | 263 // If an extension overrides the filename, then the target directory will be |
| 264 // forced to download_prefs_->DownloadPath() since extensions cannot place | 264 // forced to download_prefs_->DownloadPath() since extensions cannot place |
| 265 // downloaded files anywhere except there. This prevents subdirectories from | 265 // downloaded files anywhere except there. This prevents subdirectories from |
| 266 // accumulating: if an extension is allowed to say that a file should go in | 266 // accumulating: if an extension is allowed to say that a file should go in |
| 267 // last_download_path/music/foo.mp3, then last_download_path will accumulate | 267 // last_download_path/music/foo.mp3, then last_download_path will accumulate |
| 268 // the subdirectory /music/ so that the next download may end up in | 268 // the subdirectory /music/ so that the next download may end up in |
| 269 // Downloads/music/music/music/bar.mp3. | 269 // Downloads/music/music/music/bar.mp3. |
| 270 base::FilePath new_path(download_prefs_->DownloadPath().Append( | 270 base::FilePath new_path(download_prefs_->DownloadPath().Append( |
| 271 suggested_path).NormalizePathSeparators()); | 271 suggested_path).NormalizePathSeparators()); |
| 272 // Do not pass a mime type to GenerateSafeFileName so that it does not force | 272 net::EnsureSafePortableFileName( |
| 273 // the filename to have an extension if the (Chrome) extension does not | 273 std::string(), net::EXTENSION_OPTION_KEEP_EXISTING, &new_path); |
| 274 // suggest it. | |
| 275 net::GenerateSafeFileName(std::string(), false, &new_path); | |
| 276 virtual_path_ = new_path; | 274 virtual_path_ = new_path; |
| 277 create_target_directory_ = true; | 275 create_target_directory_ = true; |
| 278 } | 276 } |
| 279 // An extension may set conflictAction without setting filename. | 277 // An extension may set conflictAction without setting filename. |
| 280 if (conflict_action != DownloadPathReservationTracker::UNIQUIFY) | 278 if (conflict_action != DownloadPathReservationTracker::UNIQUIFY) |
| 281 conflict_action_ = conflict_action; | 279 conflict_action_ = conflict_action; |
| 282 | 280 |
| 283 DoLoop(); | 281 DoLoop(); |
| 284 } | 282 } |
| 285 | 283 |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 const base::FilePath& suggested_path) { | 884 const base::FilePath& suggested_path) { |
| 887 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); | 885 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); |
| 888 } | 886 } |
| 889 | 887 |
| 890 #if defined(OS_WIN) | 888 #if defined(OS_WIN) |
| 891 // static | 889 // static |
| 892 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { | 890 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { |
| 893 return g_is_adobe_reader_up_to_date_; | 891 return g_is_adobe_reader_up_to_date_; |
| 894 } | 892 } |
| 895 #endif | 893 #endif |
| OLD | NEW |