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

Unified Diff: chrome/browser/download/download_service.cc

Issue 7466033: Fix warning prompting on closing a window that will cancel downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make sure to use temporary download directory Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_service.h ('k') | chrome/browser/download/download_test_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_service.cc
diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc
index 659af4f50ad20a15bf2dea19607037eeb26bc615..6b5fcb26bfaa7bab5b1133a4a672bae07c52b400 100644
--- a/chrome/browser/download/download_service.cc
+++ b/chrome/browser/download/download_service.cc
@@ -6,7 +6,9 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
+#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "content/browser/download/download_manager.h"
DownloadService::DownloadService(Profile* profile)
@@ -34,6 +36,27 @@ bool DownloadService::HasCreatedDownloadManager() {
return download_manager_created_;
}
+int DownloadService::DownloadCount() const {
+ return download_manager_created_ ? manager_->in_progress_count() : 0;
+}
+
+// static
+int DownloadService::DownloadCountAllProfiles() {
+ std::vector<Profile*> profiles(
+ g_browser_process->profile_manager()->GetLoadedProfiles());
+
+ int count = 0;
+ for (std::vector<Profile*>::iterator it = profiles.begin();
+ it < profiles.end(); ++it) {
+ count += DownloadServiceFactory::GetForProfile(*it)->DownloadCount();
+ if ((*it)->HasOffTheRecordProfile())
+ count += DownloadServiceFactory::GetForProfile(
+ (*it)->GetOffTheRecordProfile())->DownloadCount();
+ }
+
+ return count;
+}
+
void DownloadService::SetDownloadManagerDelegateForTesting(
ChromeDownloadManagerDelegate* new_delegate) {
// Guarantee everything is properly initialized.
« no previous file with comments | « chrome/browser/download/download_service.h ('k') | chrome/browser/download/download_test_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698