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

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 10805020: Kill DownloadItem::IsOtr() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . 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 "content/browser/download/download_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 content::DownloadId download_id, 171 content::DownloadId download_id,
172 const content::DownloadPersistentStoreInfo& info, 172 const content::DownloadPersistentStoreInfo& info,
173 const net::BoundNetLog& bound_net_log) OVERRIDE { 173 const net::BoundNetLog& bound_net_log) OVERRIDE {
174 return new DownloadItemImpl(delegate, download_id, info, bound_net_log); 174 return new DownloadItemImpl(delegate, download_id, info, bound_net_log);
175 } 175 }
176 176
177 virtual DownloadItemImpl* CreateActiveItem( 177 virtual DownloadItemImpl* CreateActiveItem(
178 DownloadItemImplDelegate* delegate, 178 DownloadItemImplDelegate* delegate,
179 const DownloadCreateInfo& info, 179 const DownloadCreateInfo& info,
180 scoped_ptr<DownloadRequestHandleInterface> request_handle, 180 scoped_ptr<DownloadRequestHandleInterface> request_handle,
181 bool is_otr,
182 const net::BoundNetLog& bound_net_log) OVERRIDE { 181 const net::BoundNetLog& bound_net_log) OVERRIDE {
183 return new DownloadItemImpl(delegate, info, request_handle.Pass(), 182 return new DownloadItemImpl(delegate, info, request_handle.Pass(),
184 is_otr, bound_net_log); 183 bound_net_log);
185 } 184 }
186 185
187 virtual DownloadItemImpl* CreateSavePageItem( 186 virtual DownloadItemImpl* CreateSavePageItem(
188 DownloadItemImplDelegate* delegate, 187 DownloadItemImplDelegate* delegate,
189 const FilePath& path, 188 const FilePath& path,
190 const GURL& url, 189 const GURL& url,
191 bool is_otr,
192 content::DownloadId download_id, 190 content::DownloadId download_id,
193 const std::string& mime_type, 191 const std::string& mime_type,
194 const net::BoundNetLog& bound_net_log) OVERRIDE { 192 const net::BoundNetLog& bound_net_log) OVERRIDE {
195 return new DownloadItemImpl(delegate, path, url, is_otr, download_id, 193 return new DownloadItemImpl(delegate, path, url, download_id,
196 mime_type, bound_net_log); 194 mime_type, bound_net_log);
197 } 195 }
198 }; 196 };
199 197
200 } // namespace 198 } // namespace
201 199
202 namespace content { 200 namespace content {
203 201
204 bool DownloadManager::EnsureNoPendingDownloadsForTesting() { 202 bool DownloadManager::EnsureNoPendingDownloadsForTesting() {
205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 365 }
368 } 366 }
369 367
370 void DownloadManagerImpl::SearchDownloads(const string16& query, 368 void DownloadManagerImpl::SearchDownloads(const string16& query,
371 DownloadVector* result) { 369 DownloadVector* result) {
372 string16 query_lower(base::i18n::ToLower(query)); 370 string16 query_lower(base::i18n::ToLower(query));
373 371
374 for (DownloadMap::iterator it = downloads_.begin(); 372 for (DownloadMap::iterator it = downloads_.begin();
375 it != downloads_.end(); ++it) { 373 it != downloads_.end(); ++it) {
376 DownloadItemImpl* download_item = it->second; 374 DownloadItemImpl* download_item = it->second;
377 // Display Incognito downloads only in Incognito window, and vice versa.
378 // The Incognito Downloads page will get the list of non-Incognito downloads
379 // from its parent profile.
380 // TODO(benjhayden): Don't check IsPersisted(). 375 // TODO(benjhayden): Don't check IsPersisted().
381 if (!download_item->IsTemporary() && 376 if (!download_item->IsTemporary() &&
382 download_item->IsPersisted() && 377 download_item->IsPersisted() &&
383 (browser_context_->IsOffTheRecord() == download_item->IsOtr()) &&
384 download_item->MatchesQuery(query_lower)) { 378 download_item->MatchesQuery(query_lower)) {
385 result->push_back(download_item); 379 result->push_back(download_item);
386 } 380 }
387 } 381 }
388 } 382 }
389 383
390 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { 384 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) {
391 DCHECK(browser_context); 385 DCHECK(browser_context);
392 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; 386 DCHECK(!shutdown_needed_) << "DownloadManager already initialized.";
393 shutdown_needed_ = true; 387 shutdown_needed_ = true;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 518 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
525 519
526 net::BoundNetLog bound_net_log = 520 net::BoundNetLog bound_net_log =
527 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 521 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
528 if (!info->download_id.IsValid()) 522 if (!info->download_id.IsValid())
529 info->download_id = GetNextId(); 523 info->download_id = GetNextId();
530 DownloadItemImpl* download = factory_->CreateActiveItem( 524 DownloadItemImpl* download = factory_->CreateActiveItem(
531 this, *info, 525 this, *info,
532 scoped_ptr<DownloadRequestHandleInterface>( 526 scoped_ptr<DownloadRequestHandleInterface>(
533 new DownloadRequestHandle(info->request_handle)).Pass(), 527 new DownloadRequestHandle(info->request_handle)).Pass(),
534 browser_context_->IsOffTheRecord(), bound_net_log); 528 bound_net_log);
535 529
536 DCHECK(!ContainsKey(downloads_, download->GetId())); 530 DCHECK(!ContainsKey(downloads_, download->GetId()));
537 downloads_[download->GetId()] = download; 531 downloads_[download->GetId()] = download;
538 DCHECK(!ContainsKey(active_downloads_, download->GetId())); 532 DCHECK(!ContainsKey(active_downloads_, download->GetId()));
539 active_downloads_[download->GetId()] = download; 533 active_downloads_[download->GetId()] = download;
540 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download)); 534 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download));
541 535
542 return bound_net_log; 536 return bound_net_log;
543 } 537 }
544 538
545 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem( 539 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem(
546 const FilePath& main_file_path, 540 const FilePath& main_file_path,
547 const GURL& page_url, 541 const GURL& page_url,
548 bool is_otr,
549 const std::string& mime_type, 542 const std::string& mime_type,
550 DownloadItem::Observer* observer) { 543 DownloadItem::Observer* observer) {
551 net::BoundNetLog bound_net_log = 544 net::BoundNetLog bound_net_log =
552 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 545 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
553 DownloadItemImpl* download = factory_->CreateSavePageItem( 546 DownloadItemImpl* download = factory_->CreateSavePageItem(
554 this, 547 this,
555 main_file_path, 548 main_file_path,
556 page_url, 549 page_url,
557 is_otr,
558 GetNextId(), 550 GetNextId(),
559 mime_type, 551 mime_type,
560 bound_net_log); 552 bound_net_log);
561 553
562 download->AddObserver(observer); 554 download->AddObserver(observer);
563 555
564 DCHECK(!ContainsKey(downloads_, download->GetId())); 556 DCHECK(!ContainsKey(downloads_, download->GetId()));
565 downloads_[download->GetId()] = download; 557 downloads_[download->GetId()] = download;
566 DCHECK(!SavePageData::Get(download)); 558 DCHECK(!SavePageData::Get(download));
567 new SavePageData(download); 559 new SavePageData(download);
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 void DownloadManagerImpl::DownloadRenamedToFinalName( 1092 void DownloadManagerImpl::DownloadRenamedToFinalName(
1101 DownloadItemImpl* download) { 1093 DownloadItemImpl* download) {
1102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1103 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1095 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1104 // receive the DownloadRenamedToFinalName() call. 1096 // receive the DownloadRenamedToFinalName() call.
1105 if (delegate_) { 1097 if (delegate_) {
1106 delegate_->UpdatePathForItemInPersistentStore( 1098 delegate_->UpdatePathForItemInPersistentStore(
1107 download, download->GetFullPath()); 1099 download, download->GetFullPath());
1108 } 1100 }
1109 } 1101 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698