OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/keyed_service/core/keyed_service.h" | |
12 #include "extensions/features/features.h" | |
13 | |
14 class ChromeDownloadManagerDelegate; | |
15 class DownloadHistory; | |
16 class ExtensionDownloadsEventRouter; | |
17 | |
18 namespace content { | |
19 class DownloadManager; | |
20 } | |
21 | |
22 namespace extensions { | |
23 class ExtensionDownloadsEventRouter; | |
24 } | |
25 | |
26 // Abstract base class for the download service; see DownloadServiceImpl for | |
27 // implementation. | |
28 class DownloadService : public KeyedService { | |
29 public: | |
30 DownloadService(); | |
31 ~DownloadService() override; | |
32 | |
33 // Get the download manager delegate, creating it if it doesn't already exist. | |
34 virtual ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() = 0; | |
35 | |
36 // Get the interface to the history system. Returns NULL if profile is | |
37 // incognito or if the DownloadManager hasn't been created yet or if there is | |
38 // no HistoryService for profile. Virtual for testing. | |
39 virtual DownloadHistory* GetDownloadHistory() = 0; | |
40 | |
41 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
42 virtual extensions::ExtensionDownloadsEventRouter* | |
43 GetExtensionEventRouter() = 0; | |
44 #endif | |
45 | |
46 // Has a download manager been created? | |
47 virtual bool HasCreatedDownloadManager() = 0; | |
48 | |
49 // Number of non-malicious downloads associated with this instance of the | |
50 // service. | |
51 virtual int NonMaliciousDownloadCount() const = 0; | |
52 | |
53 // Cancels all in-progress downloads for this profile. | |
54 virtual void CancelDownloads() = 0; | |
55 | |
56 // Number of non-malicious downloads associated with all profiles. | |
57 static int NonMaliciousDownloadCountAllProfiles(); | |
58 | |
59 // Cancels all in-progress downloads for all profiles. | |
60 static void CancelAllDownloads(); | |
61 | |
62 // Sets the DownloadManagerDelegate associated with this object and | |
63 // its DownloadManager. Takes ownership of |delegate|, and destroys | |
64 // the previous delegate. For testing. | |
65 virtual void SetDownloadManagerDelegateForTesting( | |
66 std::unique_ptr<ChromeDownloadManagerDelegate> delegate) = 0; | |
67 | |
68 // Returns false if at least one extension has disabled the shelf, true | |
69 // otherwise. | |
70 virtual bool IsShelfEnabled() = 0; | |
71 | |
72 private: | |
73 DISALLOW_COPY_AND_ASSIGN(DownloadService); | |
74 }; | |
75 | |
76 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | |
OLD | NEW |