OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "components/sync/driver/protocol_event_observer.h" | 16 #include "components/sync/driver/protocol_event_observer.h" |
17 #include "components/sync/driver/sync_service_observer.h" | 17 #include "components/sync/driver/sync_service_observer.h" |
18 #include "components/sync/engine/cycle/type_debug_info_observer.h" | 18 #include "components/sync/engine/cycle/type_debug_info_observer.h" |
19 #include "components/sync/js/js_controller.h" | 19 #include "components/sync/js/js_controller.h" |
20 #include "components/sync/js/js_event_handler.h" | 20 #include "components/sync/js/js_event_handler.h" |
21 #include "content/public/browser/web_ui_message_handler.h" | 21 #include "content/public/browser/web_ui_message_handler.h" |
22 | 22 |
23 class SigninManagerBase; | 23 class SigninManagerBase; |
24 | 24 |
25 namespace browser_sync { | 25 namespace browser_sync { |
26 class ProfileSyncService; | 26 class ProfileSyncService; |
27 } // namespace browser_sync | 27 } // namespace browser_sync |
28 | 28 |
29 namespace sync_driver { | 29 namespace syncer { |
30 class SyncService; | 30 class SyncService; |
31 } // namespace sync_driver | 31 } // namespace syncer |
32 | 32 |
33 // Interface to abstract away the creation of the about-sync value dictionary. | 33 // Interface to abstract away the creation of the about-sync value dictionary. |
34 class AboutSyncDataExtractor { | 34 class AboutSyncDataExtractor { |
35 public: | 35 public: |
36 // Given state about sync, extracts various interesting fields and populates | 36 // Given state about sync, extracts various interesting fields and populates |
37 // a tree of base::Value objects. | 37 // a tree of base::Value objects. |
38 virtual std::unique_ptr<base::DictionaryValue> ConstructAboutInformation( | 38 virtual std::unique_ptr<base::DictionaryValue> ConstructAboutInformation( |
39 sync_driver::SyncService* service, | 39 syncer::SyncService* service, |
40 SigninManagerBase* signin) = 0; | 40 SigninManagerBase* signin) = 0; |
41 virtual ~AboutSyncDataExtractor() {} | 41 virtual ~AboutSyncDataExtractor() {} |
42 }; | 42 }; |
43 | 43 |
44 // The implementation for the chrome://sync-internals page. | 44 // The implementation for the chrome://sync-internals page. |
45 class SyncInternalsMessageHandler : public content::WebUIMessageHandler, | 45 class SyncInternalsMessageHandler : public content::WebUIMessageHandler, |
46 public syncer::JsEventHandler, | 46 public syncer::JsEventHandler, |
47 public sync_driver::SyncServiceObserver, | 47 public syncer::SyncServiceObserver, |
48 public browser_sync::ProtocolEventObserver, | 48 public syncer::ProtocolEventObserver, |
49 public syncer::TypeDebugInfoObserver { | 49 public syncer::TypeDebugInfoObserver { |
50 public: | 50 public: |
51 SyncInternalsMessageHandler(); | 51 SyncInternalsMessageHandler(); |
52 ~SyncInternalsMessageHandler() override; | 52 ~SyncInternalsMessageHandler() override; |
53 | 53 |
54 void RegisterMessages() override; | 54 void RegisterMessages() override; |
55 | 55 |
56 // Sets up observers to receive events and forward them to the UI. | 56 // Sets up observers to receive events and forward them to the UI. |
57 void HandleRegisterForEvents(const base::ListValue* args); | 57 void HandleRegisterForEvents(const base::ListValue* args); |
58 | 58 |
(...skipping 10 matching lines...) Expand all Loading... |
69 void HandleGetAllNodes(const base::ListValue* args); | 69 void HandleGetAllNodes(const base::ListValue* args); |
70 | 70 |
71 // syncer::JsEventHandler implementation. | 71 // syncer::JsEventHandler implementation. |
72 void HandleJsEvent(const std::string& name, | 72 void HandleJsEvent(const std::string& name, |
73 const syncer::JsEventDetails& details) override; | 73 const syncer::JsEventDetails& details) override; |
74 | 74 |
75 // Callback used in GetAllNodes. | 75 // Callback used in GetAllNodes. |
76 void OnReceivedAllNodes(int request_id, | 76 void OnReceivedAllNodes(int request_id, |
77 std::unique_ptr<base::ListValue> nodes); | 77 std::unique_ptr<base::ListValue> nodes); |
78 | 78 |
79 // sync_driver::SyncServiceObserver implementation. | 79 // syncer::SyncServiceObserver implementation. |
80 void OnStateChanged() override; | 80 void OnStateChanged() override; |
81 | 81 |
82 // ProtocolEventObserver implementation. | 82 // ProtocolEventObserver implementation. |
83 void OnProtocolEvent(const syncer::ProtocolEvent& e) override; | 83 void OnProtocolEvent(const syncer::ProtocolEvent& e) override; |
84 | 84 |
85 // TypeDebugInfoObserver implementation. | 85 // TypeDebugInfoObserver implementation. |
86 void OnCommitCountersUpdated(syncer::ModelType type, | 86 void OnCommitCountersUpdated(syncer::ModelType type, |
87 const syncer::CommitCounters& counters) override; | 87 const syncer::CommitCounters& counters) override; |
88 void OnUpdateCountersUpdated(syncer::ModelType type, | 88 void OnUpdateCountersUpdated(syncer::ModelType type, |
89 const syncer::UpdateCounters& counters) override; | 89 const syncer::UpdateCounters& counters) override; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 // An abstraction of who creates the about sync info value map. | 123 // An abstraction of who creates the about sync info value map. |
124 std::unique_ptr<AboutSyncDataExtractor> about_sync_data_extractor_; | 124 std::unique_ptr<AboutSyncDataExtractor> about_sync_data_extractor_; |
125 | 125 |
126 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; | 126 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); | 128 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); |
129 }; | 129 }; |
130 | 130 |
131 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ | 131 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ |
OLD | NEW |