Chromium Code Reviews| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 #if defined(ENABLE_SAFE_BROWSING) | 402 #if defined(ENABLE_SAFE_BROWSING) |
| 403 return profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && | 403 return profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && |
| 404 g_browser_process->safe_browsing_service()->DownloadBinHashNeeded(); | 404 g_browser_process->safe_browsing_service()->DownloadBinHashNeeded(); |
| 405 #else | 405 #else |
| 406 return false; | 406 return false; |
| 407 #endif | 407 #endif |
| 408 } | 408 } |
| 409 | 409 |
| 410 void ChromeDownloadManagerDelegate::AddItemToPersistentStore( | 410 void ChromeDownloadManagerDelegate::AddItemToPersistentStore( |
| 411 DownloadItem* item) { | 411 DownloadItem* item) { |
| 412 if (profile_->HasOffTheRecordProfile() && | |
| 413 (profile_ == profile_->GetOffTheRecordProfile())) { | |
| 414 OnItemAddedToPersistentStore( | |
| 415 item->GetId(), download_history_->GetNextFakeDbHandle()); | |
| 416 return; | |
| 417 } | |
|
Randy Smith (Not in Mondays)
2012/07/23 18:19:26
Why not in DownloadHistory? That feels like a cla
| |
| 412 download_history_->AddEntry(item, | 418 download_history_->AddEntry(item, |
| 413 base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore, | 419 base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore, |
| 414 base::Unretained(this))); | 420 base::Unretained(this))); |
| 415 } | 421 } |
| 416 | 422 |
| 417 void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore( | 423 void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore( |
| 418 DownloadItem* item) { | 424 DownloadItem* item) { |
| 419 download_history_->UpdateEntry(item); | 425 download_history_->UpdateEntry(item); |
| 420 } | 426 } |
| 421 | 427 |
| 422 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( | 428 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( |
| 423 DownloadItem* item, | 429 DownloadItem* item, |
| 424 const FilePath& new_path) { | 430 const FilePath& new_path) { |
| 425 download_history_->UpdateDownloadPath(item, new_path); | 431 download_history_->UpdateDownloadPath(item, new_path); |
| 426 } | 432 } |
| 427 | 433 |
| 428 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( | 434 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( |
| 429 DownloadItem* item) { | 435 DownloadItem* item) { |
| 430 download_history_->RemoveEntry(item); | 436 download_history_->RemoveEntry(item); |
| 431 } | 437 } |
| 432 | 438 |
| 433 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( | 439 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( |
| 434 base::Time remove_begin, | 440 base::Time remove_begin, |
| 435 base::Time remove_end) { | 441 base::Time remove_end) { |
| 442 if (profile_->HasOffTheRecordProfile() && | |
| 443 (profile_ == profile_->GetOffTheRecordProfile())) | |
| 444 return; | |
| 436 download_history_->RemoveEntriesBetween(remove_begin, remove_end); | 445 download_history_->RemoveEntriesBetween(remove_begin, remove_end); |
| 437 } | 446 } |
| 438 | 447 |
| 439 void ChromeDownloadManagerDelegate::GetSaveDir(WebContents* web_contents, | 448 void ChromeDownloadManagerDelegate::GetSaveDir(WebContents* web_contents, |
| 440 FilePath* website_save_dir, | 449 FilePath* website_save_dir, |
| 441 FilePath* download_save_dir, | 450 FilePath* download_save_dir, |
| 442 bool* skip_dir_check) { | 451 bool* skip_dir_check) { |
| 443 Profile* profile = | 452 Profile* profile = |
| 444 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 453 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 445 PrefService* prefs = profile->GetPrefs(); | 454 PrefService* prefs = profile->GetPrefs(); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 int32 download_id, int64 db_handle) { | 767 int32 download_id, int64 db_handle) { |
| 759 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 768 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 760 // call this function with an invalid |db_handle|. For instance, this can | 769 // call this function with an invalid |db_handle|. For instance, this can |
| 761 // happen when the history database is offline. We cannot have multiple | 770 // happen when the history database is offline. We cannot have multiple |
| 762 // DownloadItems with the same invalid db_handle, so we need to assign a | 771 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 763 // unique |db_handle| here. | 772 // unique |db_handle| here. |
| 764 if (db_handle == DownloadItem::kUninitializedHandle) | 773 if (db_handle == DownloadItem::kUninitializedHandle) |
| 765 db_handle = download_history_->GetNextFakeDbHandle(); | 774 db_handle = download_history_->GetNextFakeDbHandle(); |
| 766 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 775 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 767 } | 776 } |
| OLD | NEW |