| 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 "chrome/browser/download/download_service.h" | 5 #include "chrome/browser/download/download_service.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 9 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 10 #include "chrome/browser/download/download_history.h" | 10 #include "chrome/browser/download/download_history.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 GetDownloadManagerDelegate(); | 81 GetDownloadManagerDelegate(); |
| 82 } | 82 } |
| 83 DCHECK(download_manager_created_); | 83 DCHECK(download_manager_created_); |
| 84 return download_history_.get(); | 84 return download_history_.get(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool DownloadService::HasCreatedDownloadManager() { | 87 bool DownloadService::HasCreatedDownloadManager() { |
| 88 return download_manager_created_; | 88 return download_manager_created_; |
| 89 } | 89 } |
| 90 | 90 |
| 91 int DownloadService::DownloadCount() const { | 91 int DownloadService::NonMaliciousDownloadCount() const { |
| 92 if (!download_manager_created_) | 92 if (!download_manager_created_) |
| 93 return 0; | 93 return 0; |
| 94 return BrowserContext::GetDownloadManager(profile_)->InProgressCount(); | 94 return BrowserContext::GetDownloadManager(profile_)-> |
| 95 NonMaliciousInProgressCount(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 // static | 98 // static |
| 98 int DownloadService::DownloadCountAllProfiles() { | 99 int DownloadService::NonMaliciousDownloadCountAllProfiles() { |
| 99 std::vector<Profile*> profiles( | 100 std::vector<Profile*> profiles( |
| 100 g_browser_process->profile_manager()->GetLoadedProfiles()); | 101 g_browser_process->profile_manager()->GetLoadedProfiles()); |
| 101 | 102 |
| 102 int count = 0; | 103 int count = 0; |
| 103 for (std::vector<Profile*>::iterator it = profiles.begin(); | 104 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 104 it < profiles.end(); ++it) { | 105 it < profiles.end(); ++it) { |
| 105 count += DownloadServiceFactory::GetForBrowserContext(*it)->DownloadCount(); | 106 count += DownloadServiceFactory::GetForBrowserContext(*it)-> |
| 107 NonMaliciousDownloadCount(); |
| 106 if ((*it)->HasOffTheRecordProfile()) | 108 if ((*it)->HasOffTheRecordProfile()) |
| 107 count += DownloadServiceFactory::GetForBrowserContext( | 109 count += DownloadServiceFactory::GetForBrowserContext( |
| 108 (*it)->GetOffTheRecordProfile())->DownloadCount(); | 110 (*it)->GetOffTheRecordProfile())->NonMaliciousDownloadCount(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 return count; | 113 return count; |
| 112 } | 114 } |
| 113 | 115 |
| 114 void DownloadService::SetDownloadManagerDelegateForTesting( | 116 void DownloadService::SetDownloadManagerDelegateForTesting( |
| 115 ChromeDownloadManagerDelegate* new_delegate) { | 117 ChromeDownloadManagerDelegate* new_delegate) { |
| 116 // Set the new delegate first so that if BrowserContext::GetDownloadManager() | 118 // Set the new delegate first so that if BrowserContext::GetDownloadManager() |
| 117 // causes a new download manager to be created, we won't create a redundant | 119 // causes a new download manager to be created, we won't create a redundant |
| 118 // ChromeDownloadManagerDelegate(). | 120 // ChromeDownloadManagerDelegate(). |
| (...skipping 23 matching lines...) Expand all Loading... |
| 142 // code) when the DownloadManager is shutting down. So we shut it down | 144 // code) when the DownloadManager is shutting down. So we shut it down |
| 143 // manually earlier. See http://crbug.com/131692 | 145 // manually earlier. See http://crbug.com/131692 |
| 144 BrowserContext::GetDownloadManager(profile_)->Shutdown(); | 146 BrowserContext::GetDownloadManager(profile_)->Shutdown(); |
| 145 } | 147 } |
| 146 #if !defined(OS_ANDROID) | 148 #if !defined(OS_ANDROID) |
| 147 extension_event_router_.reset(); | 149 extension_event_router_.reset(); |
| 148 #endif | 150 #endif |
| 149 manager_delegate_ = NULL; | 151 manager_delegate_ = NULL; |
| 150 download_history_.reset(); | 152 download_history_.reset(); |
| 151 } | 153 } |
| OLD | NEW |