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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/keyed_service/core/keyed_service.h"
11 class ChromeDownloadManagerDelegate
;
12 class DownloadHistory
;
13 class ExtensionDownloadsEventRouter
;
17 class DownloadManager
;
20 namespace extensions
{
21 class ExtensionDownloadsEventRouter
;
24 // Abstract base class for the download service; see DownloadServiceImpl for
26 class DownloadService
: public KeyedService
{
29 ~DownloadService() override
;
31 // Get the download manager delegate, creating it if it doesn't already exist.
32 virtual ChromeDownloadManagerDelegate
* GetDownloadManagerDelegate() = 0;
34 // Get the interface to the history system. Returns NULL if profile is
35 // incognito or if the DownloadManager hasn't been created yet or if there is
36 // no HistoryService for profile. Virtual for testing.
37 virtual DownloadHistory
* GetDownloadHistory() = 0;
39 #if defined(ENABLE_EXTENSIONS)
40 virtual extensions::ExtensionDownloadsEventRouter
*
41 GetExtensionEventRouter() = 0;
44 // Has a download manager been created?
45 virtual bool HasCreatedDownloadManager() = 0;
47 // Number of non-malicious downloads associated with this instance of the
49 virtual int NonMaliciousDownloadCount() const = 0;
51 // Cancels all in-progress downloads for this profile.
52 virtual void CancelDownloads() = 0;
54 // Number of non-malicious downloads associated with all profiles.
55 static int NonMaliciousDownloadCountAllProfiles();
57 // Cancels all in-progress downloads for all profiles.
58 static void CancelAllDownloads();
60 // Sets the DownloadManagerDelegate associated with this object and
61 // its DownloadManager. Takes ownership of |delegate|, and destroys
62 // the previous delegate. For testing.
63 virtual void SetDownloadManagerDelegateForTesting(
64 scoped_ptr
<ChromeDownloadManagerDelegate
> delegate
) = 0;
66 // Returns false if at least one extension has disabled the shelf, true
68 virtual bool IsShelfEnabled() = 0;
71 DISALLOW_COPY_AND_ASSIGN(DownloadService
);
74 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_