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

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

Issue 14947007: [Downloads] Allow acquiring dangerous download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and get rid of Delete() Created 7 years, 7 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Go through all downloads in downloads_. Dangerous ones we need to 337 // Go through all downloads in downloads_. Dangerous ones we need to
338 // remove on disk, and in progress ones we need to cancel. 338 // remove on disk, and in progress ones we need to cancel.
339 for (DownloadMap::iterator it = downloads_.begin(); it != downloads_.end();) { 339 for (DownloadMap::iterator it = downloads_.begin(); it != downloads_.end();) {
340 DownloadItemImpl* download = it->second; 340 DownloadItemImpl* download = it->second;
341 341
342 // Save iterator from potential erases in this set done by called code. 342 // Save iterator from potential erases in this set done by called code.
343 // Iterators after an erasure point are still valid for lists and 343 // Iterators after an erasure point are still valid for lists and
344 // associative containers such as sets. 344 // associative containers such as sets.
345 it++; 345 it++;
346 346
347 if (download->IsDangerous() && download->IsPartialDownload()) { 347 download->Cancel(false);
348 // The user hasn't accepted it, so we need to remove it
349 // from the disk. This may or may not result in it being
350 // removed from the DownloadManager queues and deleted
351 // (specifically, DownloadManager::DownloadRemoved only
352 // removes and deletes it if it's known to the history service)
353 // so the only thing we know after calling this function is that
354 // the download was deleted if-and-only-if it was removed
355 // from all queues.
356 download->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN);
357 } else if (download->IsPartialDownload()) {
358 download->Cancel(false);
359 }
360 } 348 }
361 349
362 // At this point, all dangerous downloads have had their files removed 350 // At this point, all dangerous downloads have had their files removed
363 // and all in progress downloads have been cancelled. We can now delete 351 // and all in progress downloads have been cancelled. We can now delete
364 // anything left. 352 // anything left.
365 353
366 STLDeleteValues(&downloads_); 354 STLDeleteValues(&downloads_);
367 downloads_.clear(); 355 downloads_.clear();
368 356
369 // We'll have nothing more to report to the observers after this point. 357 // We'll have nothing more to report to the observers after this point.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 if (delegate_) 651 if (delegate_)
664 delegate_->OpenDownload(download); 652 delegate_->OpenDownload(download);
665 } 653 }
666 654
667 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 655 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
668 if (delegate_) 656 if (delegate_)
669 delegate_->ShowDownloadInShell(download); 657 delegate_->ShowDownloadInShell(download);
670 } 658 }
671 659
672 } // namespace content 660 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698