| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/download/download_service.h" | 12 #include "chrome/browser/download/download_service.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "extensions/features/features.h" |
| 14 | 15 |
| 15 class ChromeDownloadManagerDelegate; | 16 class ChromeDownloadManagerDelegate; |
| 16 class DownloadHistory; | 17 class DownloadHistory; |
| 17 class DownloadUIController; | 18 class DownloadUIController; |
| 18 class ExtensionDownloadsEventRouter; | 19 class ExtensionDownloadsEventRouter; |
| 19 class Profile; | 20 class Profile; |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class DownloadManager; | 23 class DownloadManager; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace extensions { | 26 namespace extensions { |
| 26 class ExtensionDownloadsEventRouter; | 27 class ExtensionDownloadsEventRouter; |
| 27 } | 28 } |
| 28 | 29 |
| 29 // Owning class for ChromeDownloadManagerDelegate. | 30 // Owning class for ChromeDownloadManagerDelegate. |
| 30 class DownloadServiceImpl : public DownloadService { | 31 class DownloadServiceImpl : public DownloadService { |
| 31 public: | 32 public: |
| 32 explicit DownloadServiceImpl(Profile* profile); | 33 explicit DownloadServiceImpl(Profile* profile); |
| 33 ~DownloadServiceImpl() override; | 34 ~DownloadServiceImpl() override; |
| 34 | 35 |
| 35 // DownloadService | 36 // DownloadService |
| 36 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() override; | 37 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() override; |
| 37 DownloadHistory* GetDownloadHistory() override; | 38 DownloadHistory* GetDownloadHistory() override; |
| 38 #if defined(ENABLE_EXTENSIONS) | 39 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 39 extensions::ExtensionDownloadsEventRouter* GetExtensionEventRouter() override; | 40 extensions::ExtensionDownloadsEventRouter* GetExtensionEventRouter() override; |
| 40 #endif | 41 #endif |
| 41 bool HasCreatedDownloadManager() override; | 42 bool HasCreatedDownloadManager() override; |
| 42 int NonMaliciousDownloadCount() const override; | 43 int NonMaliciousDownloadCount() const override; |
| 43 void CancelDownloads() override; | 44 void CancelDownloads() override; |
| 44 void SetDownloadManagerDelegateForTesting( | 45 void SetDownloadManagerDelegateForTesting( |
| 45 std::unique_ptr<ChromeDownloadManagerDelegate> delegate) override; | 46 std::unique_ptr<ChromeDownloadManagerDelegate> delegate) override; |
| 46 bool IsShelfEnabled() override; | 47 bool IsShelfEnabled() override; |
| 47 | 48 |
| 48 // KeyedService | 49 // KeyedService |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 // notifying the UI of any new downloads. Its lifetime matches that of the | 64 // notifying the UI of any new downloads. Its lifetime matches that of the |
| 64 // associated download manager. | 65 // associated download manager. |
| 65 // Note on destruction order: download_ui_ depends on download_history_ and | 66 // Note on destruction order: download_ui_ depends on download_history_ and |
| 66 // should be destroyed before the latter. | 67 // should be destroyed before the latter. |
| 67 std::unique_ptr<DownloadUIController> download_ui_; | 68 std::unique_ptr<DownloadUIController> download_ui_; |
| 68 | 69 |
| 69 // On Android, GET downloads are not handled by the DownloadManager. | 70 // On Android, GET downloads are not handled by the DownloadManager. |
| 70 // Once we have extensions on android, we probably need the EventRouter | 71 // Once we have extensions on android, we probably need the EventRouter |
| 71 // in ContentViewDownloadDelegate which knows about both GET and POST | 72 // in ContentViewDownloadDelegate which knows about both GET and POST |
| 72 // downloads. | 73 // downloads. |
| 73 #if defined(ENABLE_EXTENSIONS) | 74 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 74 // The ExtensionDownloadsEventRouter dispatches download creation, change, and | 75 // The ExtensionDownloadsEventRouter dispatches download creation, change, and |
| 75 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a | 76 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a |
| 76 // chrome-level concept and its lifetime should match DownloadManager. There | 77 // chrome-level concept and its lifetime should match DownloadManager. There |
| 77 // should be a separate EDER for on-record and off-record managers. | 78 // should be a separate EDER for on-record and off-record managers. |
| 78 // There does not appear to be a separate ExtensionSystem for on-record and | 79 // There does not appear to be a separate ExtensionSystem for on-record and |
| 79 // off-record profiles, so ExtensionSystem cannot own the EDER. | 80 // off-record profiles, so ExtensionSystem cannot own the EDER. |
| 80 std::unique_ptr<extensions::ExtensionDownloadsEventRouter> | 81 std::unique_ptr<extensions::ExtensionDownloadsEventRouter> |
| 81 extension_event_router_; | 82 extension_event_router_; |
| 82 #endif | 83 #endif |
| 83 | 84 |
| 84 DISALLOW_COPY_AND_ASSIGN(DownloadServiceImpl); | 85 DISALLOW_COPY_AND_ASSIGN(DownloadServiceImpl); |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_ | 88 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_ |
| OLD | NEW |