Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 10805020: Kill DownloadItem::IsOtr() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 next_download_id_(0), 125 next_download_id_(0),
126 download_prefs_(new DownloadPrefs(profile)) { 126 download_prefs_(new DownloadPrefs(profile)) {
127 } 127 }
128 128
129 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { 129 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
130 } 130 }
131 131
132 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { 132 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
133 download_manager_ = dm; 133 download_manager_ = dm;
134 download_history_.reset(new DownloadHistory(profile_)); 134 download_history_.reset(new DownloadHistory(profile_));
135 download_history_->Load( 135 if (profile_->GetOriginalProfile() == profile_) {
136 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, 136 download_history_->Load(
137 base::Unretained(dm))); 137 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete,
138 download_manager_));
139 }
138 #if !defined(OS_ANDROID) 140 #if !defined(OS_ANDROID)
139 extension_event_router_.reset(new ExtensionDownloadsEventRouter( 141 extension_event_router_.reset(new ExtensionDownloadsEventRouter(
140 profile_, download_manager_)); 142 profile_, download_manager_));
141 #endif 143 #endif
142 } 144 }
143 145
144 void ChromeDownloadManagerDelegate::Shutdown() { 146 void ChromeDownloadManagerDelegate::Shutdown() {
145 download_history_.reset(); 147 download_history_.reset();
146 download_prefs_.reset(); 148 download_prefs_.reset();
147 #if !defined(OS_ANDROID) 149 #if !defined(OS_ANDROID)
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 #if defined(ENABLE_SAFE_BROWSING) 419 #if defined(ENABLE_SAFE_BROWSING)
418 return profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && 420 return profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) &&
419 g_browser_process->safe_browsing_service()->DownloadBinHashNeeded(); 421 g_browser_process->safe_browsing_service()->DownloadBinHashNeeded();
420 #else 422 #else
421 return false; 423 return false;
422 #endif 424 #endif
423 } 425 }
424 426
425 void ChromeDownloadManagerDelegate::AddItemToPersistentStore( 427 void ChromeDownloadManagerDelegate::AddItemToPersistentStore(
426 DownloadItem* item) { 428 DownloadItem* item) {
429 if (profile_->HasOffTheRecordProfile() &&
430 (profile_ == profile_->GetOffTheRecordProfile())) {
asanka 2012/08/01 17:11:35 Why not profile_->IsOffTheRecord() ?
benjhayden 2012/08/01 18:51:55 Done.
431 OnItemAddedToPersistentStore(
432 item->GetId(), download_history_->GetNextFakeDbHandle());
433 return;
434 }
427 download_history_->AddEntry(item, 435 download_history_->AddEntry(item,
428 base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore, 436 base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore,
429 base::Unretained(this))); 437 this));
430 } 438 }
431 439
432 void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore( 440 void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore(
433 DownloadItem* item) { 441 DownloadItem* item) {
434 download_history_->UpdateEntry(item); 442 download_history_->UpdateEntry(item);
435 } 443 }
436 444
437 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( 445 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore(
438 DownloadItem* item, 446 DownloadItem* item,
439 const FilePath& new_path) { 447 const FilePath& new_path) {
440 download_history_->UpdateDownloadPath(item, new_path); 448 download_history_->UpdateDownloadPath(item, new_path);
441 } 449 }
442 450
443 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( 451 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore(
444 DownloadItem* item) { 452 DownloadItem* item) {
445 download_history_->RemoveEntry(item); 453 download_history_->RemoveEntry(item);
446 } 454 }
447 455
448 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( 456 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween(
449 base::Time remove_begin, 457 base::Time remove_begin,
450 base::Time remove_end) { 458 base::Time remove_end) {
459 if (profile_->HasOffTheRecordProfile() &&
460 (profile_ == profile_->GetOffTheRecordProfile()))
461 return;
451 download_history_->RemoveEntriesBetween(remove_begin, remove_end); 462 download_history_->RemoveEntriesBetween(remove_begin, remove_end);
452 } 463 }
453 464
454 void ChromeDownloadManagerDelegate::GetSaveDir(WebContents* web_contents, 465 void ChromeDownloadManagerDelegate::GetSaveDir(WebContents* web_contents,
455 FilePath* website_save_dir, 466 FilePath* website_save_dir,
456 FilePath* download_save_dir, 467 FilePath* download_save_dir,
457 bool* skip_dir_check) { 468 bool* skip_dir_check) {
458 Profile* profile = 469 Profile* profile =
459 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 470 Profile::FromBrowserContext(web_contents->GetBrowserContext());
460 PrefService* prefs = profile->GetPrefs(); 471 PrefService* prefs = profile->GetPrefs();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 582
572 VLOG(2) << __FUNCTION__ << "() download = " << download->DebugString(false) 583 VLOG(2) << __FUNCTION__ << "() download = " << download->DebugString(false)
573 << " verdict = " << result; 584 << " verdict = " << result;
574 content::DownloadDangerType danger_type = download->GetDangerType(); 585 content::DownloadDangerType danger_type = download->GetDangerType();
575 if (result != DownloadProtectionService::SAFE) 586 if (result != DownloadProtectionService::SAFE)
576 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL; 587 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL;
577 588
578 download_history_->CheckVisitedReferrerBefore( 589 download_history_->CheckVisitedReferrerBefore(
579 download_id, download->GetReferrerUrl(), 590 download_id, download->GetReferrerUrl(),
580 base::Bind(&ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone, 591 base::Bind(&ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone,
581 base::Unretained(this), download_id, callback, danger_type)); 592 this, download_id, callback, danger_type));
582 } 593 }
583 594
584 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( 595 void ChromeDownloadManagerDelegate::CheckClientDownloadDone(
585 int32 download_id, 596 int32 download_id,
586 DownloadProtectionService::DownloadCheckResult result) { 597 DownloadProtectionService::DownloadCheckResult result) {
587 DownloadItem* item = download_manager_->GetActiveDownloadItem(download_id); 598 DownloadItem* item = download_manager_->GetActiveDownloadItem(download_id);
588 if (!item) 599 if (!item)
589 return; 600 return;
590 601
591 VLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) 602 VLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false)
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 int32 download_id, int64 db_handle) { 831 int32 download_id, int64 db_handle) {
821 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 832 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
822 // call this function with an invalid |db_handle|. For instance, this can 833 // call this function with an invalid |db_handle|. For instance, this can
823 // happen when the history database is offline. We cannot have multiple 834 // happen when the history database is offline. We cannot have multiple
824 // DownloadItems with the same invalid db_handle, so we need to assign a 835 // DownloadItems with the same invalid db_handle, so we need to assign a
825 // unique |db_handle| here. 836 // unique |db_handle| here.
826 if (db_handle == DownloadItem::kUninitializedHandle) 837 if (db_handle == DownloadItem::kUninitializedHandle)
827 db_handle = download_history_->GetNextFakeDbHandle(); 838 db_handle = download_history_->GetNextFakeDbHandle();
828 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 839 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
829 } 840 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698