BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / download / download_service_impl.h
blob21eb63500b75dd28f46cc962142f89140663abdb
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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/download/download_service.h"
12 #include "components/keyed_service/core/keyed_service.h"
14 class ChromeDownloadManagerDelegate;
15 class DownloadHistory;
16 class DownloadUIController;
17 class ExtensionDownloadsEventRouter;
18 class Profile;
20 namespace content {
21 class DownloadManager;
24 namespace extensions {
25 class ExtensionDownloadsEventRouter;
28 // Owning class for ChromeDownloadManagerDelegate.
29 class DownloadServiceImpl : public DownloadService {
30 public:
31 explicit DownloadServiceImpl(Profile* profile);
32 ~DownloadServiceImpl() override;
34 // DownloadService
35 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() override;
36 DownloadHistory* GetDownloadHistory() override;
37 #if defined(ENABLE_EXTENSIONS)
38 extensions::ExtensionDownloadsEventRouter* GetExtensionEventRouter() override;
39 #endif
40 bool HasCreatedDownloadManager() override;
41 int NonMaliciousDownloadCount() const override;
42 void CancelDownloads() override;
43 void SetDownloadManagerDelegateForTesting(
44 scoped_ptr<ChromeDownloadManagerDelegate> delegate) override;
45 bool IsShelfEnabled() override;
47 // KeyedService
48 void Shutdown() override;
50 private:
51 bool download_manager_created_;
52 Profile* profile_;
54 // ChromeDownloadManagerDelegate may be the target of callbacks from
55 // the history service/DB thread and must be kept alive for those
56 // callbacks.
57 scoped_ptr<ChromeDownloadManagerDelegate> manager_delegate_;
59 scoped_ptr<DownloadHistory> download_history_;
61 // The UI controller is responsible for observing the download manager and
62 // notifying the UI of any new downloads. Its lifetime matches that of the
63 // associated download manager.
64 // Note on destruction order: download_ui_ depends on download_history_ and
65 // should be destroyed before the latter.
66 scoped_ptr<DownloadUIController> download_ui_;
68 // On Android, GET downloads are not handled by the DownloadManager.
69 // Once we have extensions on android, we probably need the EventRouter
70 // in ContentViewDownloadDelegate which knows about both GET and POST
71 // downloads.
72 #if defined(ENABLE_EXTENSIONS)
73 // The ExtensionDownloadsEventRouter dispatches download creation, change, and
74 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a
75 // chrome-level concept and its lifetime should match DownloadManager. There
76 // should be a separate EDER for on-record and off-record managers.
77 // There does not appear to be a separate ExtensionSystem for on-record and
78 // off-record profiles, so ExtensionSystem cannot own the EDER.
79 scoped_ptr<extensions::ExtensionDownloadsEventRouter> extension_event_router_;
80 #endif
82 DISALLOW_COPY_AND_ASSIGN(DownloadServiceImpl);
85 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_