1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/download/download_service.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_service_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h"
12 DownloadService::DownloadService() {
15 DownloadService::~DownloadService() {}
18 int DownloadService::NonMaliciousDownloadCountAllProfiles() {
19 std::vector
<Profile
*> profiles(
20 g_browser_process
->profile_manager()->GetLoadedProfiles());
23 for (std::vector
<Profile
*>::iterator it
= profiles
.begin();
24 it
< profiles
.end(); ++it
) {
25 count
+= DownloadServiceFactory::GetForBrowserContext(*it
)->
26 NonMaliciousDownloadCount();
27 if ((*it
)->HasOffTheRecordProfile())
28 count
+= DownloadServiceFactory::GetForBrowserContext(
29 (*it
)->GetOffTheRecordProfile())->NonMaliciousDownloadCount();
36 void DownloadService::CancelAllDownloads() {
37 std::vector
<Profile
*> profiles(
38 g_browser_process
->profile_manager()->GetLoadedProfiles());
39 for (std::vector
<Profile
*>::iterator it
= profiles
.begin();
42 DownloadService
* service
=
43 DownloadServiceFactory::GetForBrowserContext(*it
);
44 service
->CancelDownloads();