| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 info->suggested_path = info->suggested_path.Append(filename); | 327 info->suggested_path = info->suggested_path.Append(filename); |
| 328 } | 328 } |
| 329 | 329 |
| 330 // If the download is deemed dangerous, we'll use a temporary name for it. | 330 // If the download is deemed dangerous, we'll use a temporary name for it. |
| 331 if (info->is_dangerous) { | 331 if (info->is_dangerous) { |
| 332 info->original_name = FilePath(info->suggested_path).BaseName(); | 332 info->original_name = FilePath(info->suggested_path).BaseName(); |
| 333 // Create a temporary file to hold the file until the user approves its | 333 // Create a temporary file to hold the file until the user approves its |
| 334 // download. | 334 // download. |
| 335 FilePath::StringType file_name; | 335 FilePath::StringType file_name; |
| 336 FilePath path; | 336 FilePath path; |
| 337 #if defined(OS_WIN) |
| 338 string16 unconfirmed_prefix = |
| 339 l10n_util::GetStringUTF16(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); |
| 340 #else |
| 341 std::string unconfirmed_prefix = |
| 342 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); |
| 343 #endif |
| 344 |
| 337 while (path.empty()) { | 345 while (path.empty()) { |
| 338 base::SStringPrintf( | 346 base::SStringPrintf( |
| 339 &file_name, | 347 &file_name, |
| 340 FILE_PATH_LITERAL("unconfirmed %d.crdownload"), | 348 unconfirmed_prefix.append( |
| 349 FILE_PATH_LITERAL(" %d.crdownload")).c_str(), |
| 341 base::RandInt(0, 100000)); | 350 base::RandInt(0, 100000)); |
| 342 path = dir.Append(file_name); | 351 path = dir.Append(file_name); |
| 343 if (file_util::PathExists(path)) | 352 if (file_util::PathExists(path)) |
| 344 path = FilePath(); | 353 path = FilePath(); |
| 345 } | 354 } |
| 346 info->suggested_path = path; | 355 info->suggested_path = path; |
| 347 } else { | 356 } else { |
| 348 // Do not add the path uniquifier if we are saving to a specific path as in | 357 // Do not add the path uniquifier if we are saving to a specific path as in |
| 349 // the drag-out case. | 358 // the drag-out case. |
| 350 if (info->save_info.file_path.empty()) { | 359 if (info->save_info.file_path.empty()) { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 observed_download_manager_->RemoveObserver(this); | 1119 observed_download_manager_->RemoveObserver(this); |
| 1111 } | 1120 } |
| 1112 | 1121 |
| 1113 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1122 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
| 1114 observing_download_manager_->NotifyModelChanged(); | 1123 observing_download_manager_->NotifyModelChanged(); |
| 1115 } | 1124 } |
| 1116 | 1125 |
| 1117 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1126 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
| 1118 observed_download_manager_ = NULL; | 1127 observed_download_manager_ = NULL; |
| 1119 } | 1128 } |
| OLD | NEW |