| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 extension += append_extension; | 1192 extension += append_extension; |
| 1193 } | 1193 } |
| 1194 } | 1194 } |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 generated_extension->swap(extension); | 1197 generated_extension->swap(extension); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 void DownloadManager::GenerateFilename(DownloadCreateInfo* info, | 1200 void DownloadManager::GenerateFilename(DownloadCreateInfo* info, |
| 1201 FilePath* generated_name) { | 1201 FilePath* generated_name) { |
| 1202 std::wstring default_name = |
| 1203 l10n_util::GetString(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 1204 #if defined(OS_WIN) |
| 1205 FilePath default_file_path(default_name); |
| 1206 #elif defined(OS_POSIX) |
| 1207 FilePath default_file_path(base::SysWideToNativeMB(default_name)); |
| 1208 #endif |
| 1209 |
| 1202 *generated_name = net::GetSuggestedFilename(GURL(info->url), | 1210 *generated_name = net::GetSuggestedFilename(GURL(info->url), |
| 1203 info->content_disposition, | 1211 info->content_disposition, |
| 1204 info->referrer_charset, | 1212 info->referrer_charset, |
| 1205 "download"); | 1213 default_file_path); |
| 1214 |
| 1206 DCHECK(!generated_name->empty()); | 1215 DCHECK(!generated_name->empty()); |
| 1207 | 1216 |
| 1208 GenerateSafeFilename(info->mime_type, generated_name); | 1217 GenerateSafeFilename(info->mime_type, generated_name); |
| 1209 } | 1218 } |
| 1210 | 1219 |
| 1211 void DownloadManager::AddObserver(Observer* observer) { | 1220 void DownloadManager::AddObserver(Observer* observer) { |
| 1212 observers_.AddObserver(observer); | 1221 observers_.AddObserver(observer); |
| 1213 observer->ModelChanged(); | 1222 observer->ModelChanged(); |
| 1214 } | 1223 } |
| 1215 | 1224 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 | 1544 |
| 1536 if (contents) | 1545 if (contents) |
| 1537 contents->OnStartDownload(download); | 1546 contents->OnStartDownload(download); |
| 1538 } | 1547 } |
| 1539 | 1548 |
| 1540 // Clears the last download path, used to initialize "save as" dialogs. | 1549 // Clears the last download path, used to initialize "save as" dialogs. |
| 1541 void DownloadManager::ClearLastDownloadPath() { | 1550 void DownloadManager::ClearLastDownloadPath() { |
| 1542 last_download_path_ = FilePath(); | 1551 last_download_path_ = FilePath(); |
| 1543 } | 1552 } |
| 1544 | 1553 |
| OLD | NEW |