| 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 "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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 int DownloadManagerImpl::InProgressCount() const { | 666 int DownloadManagerImpl::InProgressCount() const { |
| 667 int count = 0; | 667 int count = 0; |
| 668 for (DownloadMap::const_iterator it = downloads_.begin(); | 668 for (DownloadMap::const_iterator it = downloads_.begin(); |
| 669 it != downloads_.end(); ++it) { | 669 it != downloads_.end(); ++it) { |
| 670 if (it->second->GetState() == DownloadItem::IN_PROGRESS) | 670 if (it->second->GetState() == DownloadItem::IN_PROGRESS) |
| 671 ++count; | 671 ++count; |
| 672 } | 672 } |
| 673 return count; | 673 return count; |
| 674 } | 674 } |
| 675 | 675 |
| 676 int DownloadManagerImpl::NonDangerousInProgressCount() const { |
| 677 int count = 0; |
| 678 for (DownloadMap::const_iterator it = downloads_.begin(); |
| 679 it != downloads_.end(); ++it) { |
| 680 // Exclude dangerous items, unless they are |
| 681 // DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE |
| 682 if ((it->second->GetState() == DownloadItem::IN_PROGRESS) && |
| 683 !(it->second->IsDangerous() && |
| 684 (it->second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE))) { |
| 685 ++count; |
| 686 } |
| 687 } |
| 688 return count; |
| 689 } |
| 690 |
| 676 DownloadItem* DownloadManagerImpl::GetDownload(uint32 download_id) { | 691 DownloadItem* DownloadManagerImpl::GetDownload(uint32 download_id) { |
| 677 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; | 692 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; |
| 678 } | 693 } |
| 679 | 694 |
| 680 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { | 695 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { |
| 681 for (DownloadMap::iterator it = downloads_.begin(); | 696 for (DownloadMap::iterator it = downloads_.begin(); |
| 682 it != downloads_.end(); ++it) { | 697 it != downloads_.end(); ++it) { |
| 683 downloads->push_back(it->second); | 698 downloads->push_back(it->second); |
| 684 } | 699 } |
| 685 } | 700 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 698 if (delegate_) | 713 if (delegate_) |
| 699 delegate_->OpenDownload(download); | 714 delegate_->OpenDownload(download); |
| 700 } | 715 } |
| 701 | 716 |
| 702 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 717 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
| 703 if (delegate_) | 718 if (delegate_) |
| 704 delegate_->ShowDownloadInShell(download); | 719 delegate_->ShowDownloadInShell(download); |
| 705 } | 720 } |
| 706 | 721 |
| 707 } // namespace content | 722 } // namespace content |
| OLD | NEW |