OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 COMPONENTS_OFFLINE_PAGES_DOWNLOADS_DOWNLOAD_NOTIFYING_OBSERVER_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_DOWNLOADS_DOWNLOAD_NOTIFYING_OBSERVER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/guid.h" | |
11 #include "base/macros.h" | |
12 #include "components/offline_pages/background/request_coordinator.h" | |
13 #include "components/offline_pages/client_policy_controller.h" | |
14 | |
15 namespace offline_pages { | |
16 | |
17 struct ClientId; | |
18 struct OfflinePageDownloadNotifier; | |
19 class ClientPolicyController; | |
20 class SavePageRequest; | |
21 | |
22 // Class observing the save page requests and issuing corresponding user | |
23 // notifications as requests are added or updated. | |
24 class DownloadNotifyingObserver : public RequestCoordinator::Observer, | |
25 public base::SupportsUserData::Data { | |
26 public: | |
27 ~DownloadNotifyingObserver() override; | |
28 | |
29 static DownloadNotifyingObserver* GetFromRequestCoordinator( | |
30 RequestCoordinator* request_coordinator); | |
31 static void CreateAndStartObserving( | |
32 RequestCoordinator* request_coordinator, | |
33 std::unique_ptr<OfflinePageDownloadNotifier> notifier); | |
34 | |
35 // RequestCoordinator::Observer implementation: | |
36 void OnAdded(const SavePageRequest& request) override; | |
37 void OnChanged(const SavePageRequest& request) override; | |
38 void OnCompleted( | |
39 const SavePageRequest& request, | |
40 RequestCoordinator::BackgroundSavePageResult status) override; | |
41 | |
42 private: | |
43 friend class DownloadNotifyingObserverTest; | |
44 | |
45 DownloadNotifyingObserver( | |
46 std::unique_ptr<OfflinePageDownloadNotifier> notifier, | |
47 ClientPolicyController* policy_controller); | |
48 | |
49 bool IsVisibleInUI(const ClientId& id); | |
50 | |
51 // Used to issue notifications related to save page requests. | |
52 std::unique_ptr<OfflinePageDownloadNotifier> notifier_; | |
53 // Used to determine policy-related permissions. Not owned. | |
54 ClientPolicyController* policy_controller_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(DownloadNotifyingObserver); | |
57 }; | |
58 | |
59 } // namespace offline_pages | |
60 | |
61 #endif // COMPONENTS_OFFLINE_PAGES_DOWNLOADS_DOWNLOAD_NOTIFYING_OBSERVER_H_ | |
OLD | NEW |