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