| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 } | 504 } |
| 505 | 505 |
| 506 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( | 506 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( |
| 507 base::Time remove_begin, | 507 base::Time remove_begin, |
| 508 base::Time remove_end) { | 508 base::Time remove_end) { |
| 509 if (profile_->IsOffTheRecord()) | 509 if (profile_->IsOffTheRecord()) |
| 510 return; | 510 return; |
| 511 download_history_->RemoveEntriesBetween(remove_begin, remove_end); | 511 download_history_->RemoveEntriesBetween(remove_begin, remove_end); |
| 512 } | 512 } |
| 513 | 513 |
| 514 void ChromeDownloadManagerDelegate::GetSaveDir(WebContents* web_contents, | 514 void ChromeDownloadManagerDelegate::GetSaveDir(BrowserContext* browser_context, |
| 515 FilePath* website_save_dir, | 515 FilePath* website_save_dir, |
| 516 FilePath* download_save_dir, | 516 FilePath* download_save_dir, |
| 517 bool* skip_dir_check) { | 517 bool* skip_dir_check) { |
| 518 Profile* profile = | 518 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 519 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 520 PrefService* prefs = profile->GetPrefs(); | 519 PrefService* prefs = profile->GetPrefs(); |
| 521 | 520 |
| 522 // Check whether the preference has the preferred directory for saving file. | 521 // Check whether the preference has the preferred directory for saving file. |
| 523 // If not, initialize it with default directory. | 522 // If not, initialize it with default directory. |
| 524 if (!prefs->FindPreference(prefs::kSaveFileDefaultDirectory)) { | 523 if (!prefs->FindPreference(prefs::kSaveFileDefaultDirectory)) { |
| 525 DCHECK(prefs->FindPreference(prefs::kDownloadDefaultDirectory)); | 524 DCHECK(prefs->FindPreference(prefs::kDownloadDefaultDirectory)); |
| 526 FilePath default_save_path = prefs->GetFilePath( | 525 FilePath default_save_path = prefs->GetFilePath( |
| 527 prefs::kDownloadDefaultDirectory); | 526 prefs::kDownloadDefaultDirectory); |
| 528 prefs->RegisterFilePathPref(prefs::kSaveFileDefaultDirectory, | 527 prefs->RegisterFilePathPref(prefs::kSaveFileDefaultDirectory, |
| 529 default_save_path, | 528 default_save_path, |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 int32 download_id, int64 db_handle) { | 887 int32 download_id, int64 db_handle) { |
| 889 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 888 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 890 // call this function with an invalid |db_handle|. For instance, this can | 889 // call this function with an invalid |db_handle|. For instance, this can |
| 891 // happen when the history database is offline. We cannot have multiple | 890 // happen when the history database is offline. We cannot have multiple |
| 892 // DownloadItems with the same invalid db_handle, so we need to assign a | 891 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 893 // unique |db_handle| here. | 892 // unique |db_handle| here. |
| 894 if (db_handle == DownloadItem::kUninitializedHandle) | 893 if (db_handle == DownloadItem::kUninitializedHandle) |
| 895 db_handle = download_history_->GetNextFakeDbHandle(); | 894 db_handle = download_history_->GetNextFakeDbHandle(); |
| 896 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 895 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 897 } | 896 } |
| OLD | NEW |