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

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, 5 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 content::DownloadId download_id, 170 content::DownloadId download_id,
171 const content::DownloadPersistentStoreInfo& info, 171 const content::DownloadPersistentStoreInfo& info,
172 const net::BoundNetLog& bound_net_log) OVERRIDE { 172 const net::BoundNetLog& bound_net_log) OVERRIDE {
173 return new DownloadItemImpl(delegate, download_id, info, bound_net_log); 173 return new DownloadItemImpl(delegate, download_id, info, bound_net_log);
174 } 174 }
175 175
176 virtual DownloadItemImpl* CreateActiveItem( 176 virtual DownloadItemImpl* CreateActiveItem(
177 DownloadItemImplDelegate* delegate, 177 DownloadItemImplDelegate* delegate,
178 const DownloadCreateInfo& info, 178 const DownloadCreateInfo& info,
179 scoped_ptr<DownloadRequestHandleInterface> request_handle, 179 scoped_ptr<DownloadRequestHandleInterface> request_handle,
180 bool is_otr,
181 const net::BoundNetLog& bound_net_log) OVERRIDE { 180 const net::BoundNetLog& bound_net_log) OVERRIDE {
182 return new DownloadItemImpl(delegate, info, request_handle.Pass(), 181 return new DownloadItemImpl(delegate, info, request_handle.Pass(),
183 is_otr, bound_net_log); 182 bound_net_log);
184 } 183 }
185 184
186 virtual DownloadItemImpl* CreateSavePageItem( 185 virtual DownloadItemImpl* CreateSavePageItem(
187 DownloadItemImplDelegate* delegate, 186 DownloadItemImplDelegate* delegate,
188 const FilePath& path, 187 const FilePath& path,
189 const GURL& url, 188 const GURL& url,
190 bool is_otr,
191 content::DownloadId download_id, 189 content::DownloadId download_id,
192 const std::string& mime_type, 190 const std::string& mime_type,
193 const net::BoundNetLog& bound_net_log) OVERRIDE { 191 const net::BoundNetLog& bound_net_log) OVERRIDE {
194 return new DownloadItemImpl(delegate, path, url, is_otr, download_id, 192 return new DownloadItemImpl(delegate, path, url, download_id,
195 mime_type, bound_net_log); 193 mime_type, bound_net_log);
196 } 194 }
197 }; 195 };
198 196
199 } // namespace 197 } // namespace
200 198
201 namespace content { 199 namespace content {
202 200
203 bool DownloadManager::EnsureNoPendingDownloadsForTesting() { 201 bool DownloadManager::EnsureNoPendingDownloadsForTesting() {
204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 363 }
366 } 364 }
367 365
368 void DownloadManagerImpl::SearchDownloads(const string16& query, 366 void DownloadManagerImpl::SearchDownloads(const string16& query,
369 DownloadVector* result) { 367 DownloadVector* result) {
370 string16 query_lower(base::i18n::ToLower(query)); 368 string16 query_lower(base::i18n::ToLower(query));
371 369
372 for (DownloadMap::iterator it = downloads_.begin(); 370 for (DownloadMap::iterator it = downloads_.begin();
373 it != downloads_.end(); ++it) { 371 it != downloads_.end(); ++it) {
374 DownloadItemImpl* download_item = it->second; 372 DownloadItemImpl* download_item = it->second;
375 // Display Incognito downloads only in Incognito window, and vice versa.
376 // The Incognito Downloads page will get the list of non-Incognito downloads
377 // from its parent profile.
378 // TODO(benjhayden): Don't check IsPersisted(). 373 // TODO(benjhayden): Don't check IsPersisted().
379 if (!download_item->IsTemporary() && 374 if (!download_item->IsTemporary() &&
380 download_item->IsPersisted() && 375 download_item->IsPersisted() &&
381 (browser_context_->IsOffTheRecord() == download_item->IsOtr()) &&
382 download_item->MatchesQuery(query_lower)) { 376 download_item->MatchesQuery(query_lower)) {
383 result->push_back(download_item); 377 result->push_back(download_item);
384 } 378 }
385 } 379 }
386 } 380 }
387 381
388 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { 382 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) {
389 DCHECK(browser_context); 383 DCHECK(browser_context);
390 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; 384 DCHECK(!shutdown_needed_) << "DownloadManager already initialized.";
391 shutdown_needed_ = true; 385 shutdown_needed_ = true;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
522 516
523 net::BoundNetLog bound_net_log = 517 net::BoundNetLog bound_net_log =
524 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 518 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
525 if (!info->download_id.IsValid()) 519 if (!info->download_id.IsValid())
526 info->download_id = GetNextId(); 520 info->download_id = GetNextId();
527 DownloadItemImpl* download = factory_->CreateActiveItem( 521 DownloadItemImpl* download = factory_->CreateActiveItem(
528 this, *info, 522 this, *info,
529 scoped_ptr<DownloadRequestHandleInterface>( 523 scoped_ptr<DownloadRequestHandleInterface>(
530 new DownloadRequestHandle(info->request_handle)).Pass(), 524 new DownloadRequestHandle(info->request_handle)).Pass(),
531 browser_context_->IsOffTheRecord(), bound_net_log); 525 bound_net_log);
532 526
533 DCHECK(!ContainsKey(downloads_, download->GetId())); 527 DCHECK(!ContainsKey(downloads_, download->GetId()));
534 downloads_[download->GetId()] = download; 528 downloads_[download->GetId()] = download;
535 DCHECK(!ContainsKey(active_downloads_, download->GetId())); 529 DCHECK(!ContainsKey(active_downloads_, download->GetId()));
536 active_downloads_[download->GetId()] = download; 530 active_downloads_[download->GetId()] = download;
537 531
538 return bound_net_log; 532 return bound_net_log;
539 } 533 }
540 534
541 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem( 535 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem(
542 const FilePath& main_file_path, 536 const FilePath& main_file_path,
543 const GURL& page_url, 537 const GURL& page_url,
544 bool is_otr,
545 const std::string& mime_type, 538 const std::string& mime_type,
546 DownloadItem::Observer* observer) { 539 DownloadItem::Observer* observer) {
547 net::BoundNetLog bound_net_log = 540 net::BoundNetLog bound_net_log =
548 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 541 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
549 DownloadItemImpl* download = factory_->CreateSavePageItem( 542 DownloadItemImpl* download = factory_->CreateSavePageItem(
550 this, 543 this,
551 main_file_path, 544 main_file_path,
552 page_url, 545 page_url,
553 is_otr,
554 GetNextId(), 546 GetNextId(),
555 mime_type, 547 mime_type,
556 bound_net_log); 548 bound_net_log);
557 549
558 download->AddObserver(observer); 550 download->AddObserver(observer);
559 551
560 DCHECK(!ContainsKey(downloads_, download->GetId())); 552 DCHECK(!ContainsKey(downloads_, download->GetId()));
561 downloads_[download->GetId()] = download; 553 downloads_[download->GetId()] = download;
562 DCHECK(!SavePageExternalData::Get(download)); 554 DCHECK(!SavePageExternalData::Get(download));
563 new SavePageExternalData(download); 555 new SavePageExternalData(download);
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 void DownloadManagerImpl::DownloadRenamedToFinalName( 1161 void DownloadManagerImpl::DownloadRenamedToFinalName(
1170 DownloadItemImpl* download) { 1162 DownloadItemImpl* download) {
1171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1172 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1164 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1173 // receive the DownloadRenamedToFinalName() call. 1165 // receive the DownloadRenamedToFinalName() call.
1174 if (delegate_) { 1166 if (delegate_) {
1175 delegate_->UpdatePathForItemInPersistentStore( 1167 delegate_->UpdatePathForItemInPersistentStore(
1176 download, download->GetFullPath()); 1168 download, download->GetFullPath());
1177 } 1169 }
1178 } 1170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698