OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 507 } |
508 | 508 |
509 // Get the directory from preference. | 509 // Get the directory from preference. |
510 *website_save_dir = prefs->GetFilePath(prefs::kSaveFileDefaultDirectory); | 510 *website_save_dir = prefs->GetFilePath(prefs::kSaveFileDefaultDirectory); |
511 DCHECK(!website_save_dir->empty()); | 511 DCHECK(!website_save_dir->empty()); |
512 | 512 |
513 *download_save_dir = prefs->GetFilePath(prefs::kDownloadDefaultDirectory); | 513 *download_save_dir = prefs->GetFilePath(prefs::kDownloadDefaultDirectory); |
514 | 514 |
515 *skip_dir_check = false; | 515 *skip_dir_check = false; |
516 #if defined(OS_CHROMEOS) | 516 #if defined(OS_CHROMEOS) |
517 *skip_dir_check = gdata::util::IsUnderGDataMountPoint(*website_save_dir); | 517 *skip_dir_check = gdata::util::IsUnderDriveMountPoint(*website_save_dir); |
518 #endif | 518 #endif |
519 } | 519 } |
520 | 520 |
521 void ChromeDownloadManagerDelegate::ChooseSavePath( | 521 void ChromeDownloadManagerDelegate::ChooseSavePath( |
522 WebContents* web_contents, | 522 WebContents* web_contents, |
523 const FilePath& suggested_path, | 523 const FilePath& suggested_path, |
524 const FilePath::StringType& default_extension, | 524 const FilePath::StringType& default_extension, |
525 bool can_save_as_complete, | 525 bool can_save_as_complete, |
526 const content::SavePackagePathPickedCallback& callback) { | 526 const content::SavePackagePathPickedCallback& callback) { |
527 // Deletes itself. | 527 // Deletes itself. |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 return; | 835 return; |
836 | 836 |
837 // If |target_path| is empty, then that means that the user wants to cancel | 837 // If |target_path| is empty, then that means that the user wants to cancel |
838 // the download. | 838 // the download. |
839 if (!target_path.empty()) { | 839 if (!target_path.empty()) { |
840 intermediate_path = GetIntermediatePath(target_path, danger_type); | 840 intermediate_path = GetIntermediatePath(target_path, danger_type); |
841 | 841 |
842 // Retain the last directory. Exclude temporary downloads since the path | 842 // Retain the last directory. Exclude temporary downloads since the path |
843 // likely points at the location of a temporary file. | 843 // likely points at the location of a temporary file. |
844 // TODO(asanka): This logic is a hack. DownloadFilePicker should give us a | 844 // TODO(asanka): This logic is a hack. DownloadFilePicker should give us a |
845 // directory to persist. Or perhaps, if the GData path | 845 // directory to persist. Or perhaps, if the Drive path |
846 // substitution logic is moved here, then we would have a | 846 // substitution logic is moved here, then we would have a |
847 // persistable path after the DownloadFilePicker is done. | 847 // persistable path after the DownloadFilePicker is done. |
848 if (disposition == DownloadItem::TARGET_DISPOSITION_PROMPT && | 848 if (disposition == DownloadItem::TARGET_DISPOSITION_PROMPT && |
849 !download->IsTemporary()) | 849 !download->IsTemporary()) |
850 last_download_path_ = target_path.DirName(); | 850 last_download_path_ = target_path.DirName(); |
851 } | 851 } |
852 callback.Run(target_path, disposition, danger_type, intermediate_path); | 852 callback.Run(target_path, disposition, danger_type, intermediate_path); |
853 } | 853 } |
854 | 854 |
855 void ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore( | 855 void ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore( |
856 int32 download_id, int64 db_handle) { | 856 int32 download_id, int64 db_handle) { |
857 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 857 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
858 // call this function with an invalid |db_handle|. For instance, this can | 858 // call this function with an invalid |db_handle|. For instance, this can |
859 // happen when the history database is offline. We cannot have multiple | 859 // happen when the history database is offline. We cannot have multiple |
860 // DownloadItems with the same invalid db_handle, so we need to assign a | 860 // DownloadItems with the same invalid db_handle, so we need to assign a |
861 // unique |db_handle| here. | 861 // unique |db_handle| here. |
862 if (db_handle == DownloadItem::kUninitializedHandle) | 862 if (db_handle == DownloadItem::kUninitializedHandle) |
863 db_handle = download_history_->GetNextFakeDbHandle(); | 863 db_handle = download_history_->GetNextFakeDbHandle(); |
864 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 864 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
865 } | 865 } |
OLD | NEW |