Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: chrome/browser/ui/webui/sync_internals_message_handler.h

Issue 210233005: sync: Display protocol events on about:sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit + unrelated bug Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/DEPS ('k') | chrome/browser/ui/webui/sync_internals_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/sync/profile_sync_service_observer.h" 15 #include "chrome/browser/sync/profile_sync_service_observer.h"
16 #include "chrome/browser/sync/protocol_event_observer.h"
16 #include "content/public/browser/web_ui_message_handler.h" 17 #include "content/public/browser/web_ui_message_handler.h"
17 #include "sync/js/js_controller.h" 18 #include "sync/js/js_controller.h"
18 #include "sync/js/js_event_handler.h" 19 #include "sync/js/js_event_handler.h"
19 #include "sync/js/js_reply_handler.h" 20 #include "sync/js/js_reply_handler.h"
20 21
21 class ProfileSyncService; 22 class ProfileSyncService;
22 23
23 // The implementation for the chrome://sync-internals page. 24 // The implementation for the chrome://sync-internals page.
24 class SyncInternalsMessageHandler 25 class SyncInternalsMessageHandler
25 : public content::WebUIMessageHandler, 26 : public content::WebUIMessageHandler,
26 public syncer::JsEventHandler, 27 public syncer::JsEventHandler,
27 public syncer::JsReplyHandler, 28 public syncer::JsReplyHandler,
28 public ProfileSyncServiceObserver { 29 public ProfileSyncServiceObserver,
30 public browser_sync::ProtocolEventObserver {
29 public: 31 public:
30 SyncInternalsMessageHandler(); 32 SyncInternalsMessageHandler();
31 virtual ~SyncInternalsMessageHandler(); 33 virtual ~SyncInternalsMessageHandler();
32 34
33 virtual void RegisterMessages() OVERRIDE; 35 virtual void RegisterMessages() OVERRIDE;
34 36
35 // Forwards requests to the JsController. 37 // Forwards requests to the JsController.
36 void ForwardToJsController(const std::string& name, const base::ListValue*); 38 void ForwardToJsController(const std::string& name, const base::ListValue*);
37 39
38 // Fires an event to send updated info back to the page. 40 // Fires an event to send updated info back to the page.
39 void HandleRequestUpdatedAboutInfo(const base::ListValue* args); 41 void HandleRequestUpdatedAboutInfo(const base::ListValue* args);
40 42
41 // Fires and event to send the list of types back to the page. 43 // Fires and event to send the list of types back to the page.
42 void HandleRequestListOfTypes(const base::ListValue* args); 44 void HandleRequestListOfTypes(const base::ListValue* args);
43 45
44 // syncer::JsEventHandler implementation. 46 // syncer::JsEventHandler implementation.
45 virtual void HandleJsEvent( 47 virtual void HandleJsEvent(
46 const std::string& name, 48 const std::string& name,
47 const syncer::JsEventDetails& details) OVERRIDE; 49 const syncer::JsEventDetails& details) OVERRIDE;
48 50
49 // syncer::JsReplyHandler implementation. 51 // syncer::JsReplyHandler implementation.
50 virtual void HandleJsReply( 52 virtual void HandleJsReply(
51 const std::string& name, 53 const std::string& name,
52 const syncer::JsArgList& args) OVERRIDE; 54 const syncer::JsArgList& args) OVERRIDE;
53 55
54 // ProfileSyncServiceObserver implementation. 56 // ProfileSyncServiceObserver implementation.
55 virtual void OnStateChanged() OVERRIDE; 57 virtual void OnStateChanged() OVERRIDE;
56 58
59 // ProtocolEventObserver implementation.
60 virtual void OnProtocolEvent(const syncer::ProtocolEvent& e) OVERRIDE;
61
57 private: 62 private:
58 // Helper function to register JsController function callbacks. 63 // Helper function to register JsController function callbacks.
59 void RegisterJsControllerCallback(const std::string& name); 64 void RegisterJsControllerCallback(const std::string& name);
60 65
61 // Fetches updated aboutInfo and sends it to the page in the form of an 66 // Fetches updated aboutInfo and sends it to the page in the form of an
62 // onAboutInfoUpdated event. 67 // onAboutInfoUpdated event.
63 void SendAboutInfo(); 68 void SendAboutInfo();
64 69
65 ProfileSyncService* GetProfileSyncService(); 70 ProfileSyncService* GetProfileSyncService();
66 71
67 ScopedObserver<ProfileSyncService, SyncInternalsMessageHandler>
68 scoped_observer_;
69
70 base::WeakPtr<syncer::JsController> js_controller_; 72 base::WeakPtr<syncer::JsController> js_controller_;
71 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; 73 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_;
72 74
73 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); 75 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler);
74 }; 76 };
75 77
76 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ 78 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/DEPS ('k') | chrome/browser/ui/webui/sync_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698