blob: e41f6aefc51d2643c5b33d41c58a5a22c52f30b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/download/download_service.h"
#include "components/keyed_service/core/keyed_service.h"
class ChromeDownloadManagerDelegate;
class DownloadHistory;
class DownloadUIController;
class ExtensionDownloadsEventRouter;
class Profile;
namespace content {
class DownloadManager;
}
namespace extensions {
class ExtensionDownloadsEventRouter;
}
// Owning class for ChromeDownloadManagerDelegate.
class DownloadServiceImpl : public DownloadService {
public:
explicit DownloadServiceImpl(Profile* profile);
~DownloadServiceImpl() override;
// DownloadService
ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() override;
DownloadHistory* GetDownloadHistory() override;
#if defined(ENABLE_EXTENSIONS)
extensions::ExtensionDownloadsEventRouter* GetExtensionEventRouter() override;
#endif
bool HasCreatedDownloadManager() override;
int NonMaliciousDownloadCount() const override;
void CancelDownloads() override;
void SetDownloadManagerDelegateForTesting(
scoped_ptr<ChromeDownloadManagerDelegate> delegate) override;
bool IsShelfEnabled() override;
// KeyedService
void Shutdown() override;
private:
bool download_manager_created_;
Profile* profile_;
// ChromeDownloadManagerDelegate may be the target of callbacks from
// the history service/DB thread and must be kept alive for those
// callbacks.
scoped_ptr<ChromeDownloadManagerDelegate> manager_delegate_;
scoped_ptr<DownloadHistory> download_history_;
// The UI controller is responsible for observing the download manager and
// notifying the UI of any new downloads. Its lifetime matches that of the
// associated download manager.
// Note on destruction order: download_ui_ depends on download_history_ and
// should be destroyed before the latter.
scoped_ptr<DownloadUIController> download_ui_;
// On Android, GET downloads are not handled by the DownloadManager.
// Once we have extensions on android, we probably need the EventRouter
// in ContentViewDownloadDelegate which knows about both GET and POST
// downloads.
#if defined(ENABLE_EXTENSIONS)
// The ExtensionDownloadsEventRouter dispatches download creation, change, and
// erase events to extensions. Like ChromeDownloadManagerDelegate, it's a
// chrome-level concept and its lifetime should match DownloadManager. There
// should be a separate EDER for on-record and off-record managers.
// There does not appear to be a separate ExtensionSystem for on-record and
// off-record profiles, so ExtensionSystem cannot own the EDER.
scoped_ptr<extensions::ExtensionDownloadsEventRouter> extension_event_router_;
#endif
DISALLOW_COPY_AND_ASSIGN(DownloadServiceImpl);
};
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
|