Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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/save_package.h" | 5 #include "chrome/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/i18n/file_util_icu.h" | 11 #include "base/i18n/file_util_icu.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/path_service.h" | |
| 14 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 15 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
| 16 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 17 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
| 18 #include "base/task.h" | 19 #include "base/task.h" |
| 19 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
| 20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/download/download_item.h" | 23 #include "chrome/browser/download/download_item.h" |
| 23 #include "chrome/browser/download/download_item_model.h" | 24 #include "chrome/browser/download/download_item_model.h" |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 website_save_dir, download_save_dir, mime_type)); | 1269 website_save_dir, download_save_dir, mime_type)); |
| 1269 } | 1270 } |
| 1270 | 1271 |
| 1271 void SavePackage::CreateDirectoryOnFileThread( | 1272 void SavePackage::CreateDirectoryOnFileThread( |
| 1272 const FilePath& website_save_dir, | 1273 const FilePath& website_save_dir, |
| 1273 const FilePath& download_save_dir, | 1274 const FilePath& download_save_dir, |
| 1274 const std::string& mime_type) { | 1275 const std::string& mime_type) { |
| 1275 FilePath save_dir; | 1276 FilePath save_dir; |
| 1276 // If the default html/websites save folder doesn't exist... | 1277 // If the default html/websites save folder doesn't exist... |
| 1277 if (!file_util::DirectoryExists(website_save_dir)) { | 1278 if (!file_util::DirectoryExists(website_save_dir)) { |
| 1278 // If the default download dir doesn't exist, create it. | 1279 // If the default download folder doesn't exist, |
| 1280 // default to the user's "My Documents" folder. | |
| 1279 if (!file_util::DirectoryExists(download_save_dir)) | 1281 if (!file_util::DirectoryExists(download_save_dir)) |
| 1280 file_util::CreateDirectory(download_save_dir); | 1282 PathService::Get(chrome::DIR_USER_DOCUMENTS, &save_dir); |
|
Paweł Hajdan Jr.
2011/05/13 09:16:22
Please check the return value.
haraken1
2011/05/17 04:29:05
Done.
| |
| 1281 save_dir = download_save_dir; | 1283 else |
|
Paweł Hajdan Jr.
2011/05/13 09:16:22
Now this is a double-negation. Please put the "tru
haraken1
2011/05/17 04:29:05
Done.
| |
| 1284 save_dir = download_save_dir; | |
| 1282 } else { | 1285 } else { |
| 1283 // If it does exist, use the default save dir param. | 1286 // If it does exist, use the default save dir param. |
| 1284 save_dir = website_save_dir; | 1287 save_dir = website_save_dir; |
| 1285 } | 1288 } |
| 1286 | 1289 |
| 1287 bool can_save_as_complete = CanSaveAsComplete(mime_type); | 1290 bool can_save_as_complete = CanSaveAsComplete(mime_type); |
| 1288 FilePath suggested_filename = GetSuggestedNameForSaveAs(can_save_as_complete, | 1291 FilePath suggested_filename = GetSuggestedNameForSaveAs(can_save_as_complete, |
| 1289 mime_type); | 1292 mime_type); |
| 1290 FilePath::StringType pure_file_name = | 1293 FilePath::StringType pure_file_name = |
| 1291 suggested_filename.RemoveExtension().BaseName().value(); | 1294 suggested_filename.RemoveExtension().BaseName().value(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1464 } | 1467 } |
| 1465 | 1468 |
| 1466 // SelectFileDialog::Listener interface. | 1469 // SelectFileDialog::Listener interface. |
| 1467 void SavePackage::FileSelected(const FilePath& path, | 1470 void SavePackage::FileSelected(const FilePath& path, |
| 1468 int index, void* params) { | 1471 int index, void* params) { |
| 1469 ContinueSave(path, index); | 1472 ContinueSave(path, index); |
| 1470 } | 1473 } |
| 1471 | 1474 |
| 1472 void SavePackage::FileSelectionCanceled(void* params) { | 1475 void SavePackage::FileSelectionCanceled(void* params) { |
| 1473 } | 1476 } |
| OLD | NEW |