#include "content/public/browser/web_ui_message_handler.h"
#include "sync/js/js_controller.h"
#include "sync/js/js_event_handler.h"
-#include "sync/js/js_reply_handler.h"
class ProfileSyncService;
class SyncInternalsMessageHandler
: public content::WebUIMessageHandler,
public syncer::JsEventHandler,
- public syncer::JsReplyHandler,
public ProfileSyncServiceObserver,
public browser_sync::ProtocolEventObserver {
public:
virtual void RegisterMessages() OVERRIDE;
- // Forwards requests to the JsController.
- void ForwardToJsController(const std::string& name, const base::ListValue*);
+ // Sets up observers to receive events and forward them to the UI.
+ void HandleRegisterForEvents(const base::ListValue* args);
// Fires an event to send updated info back to the page.
void HandleRequestUpdatedAboutInfo(const base::ListValue* args);
// Fires and event to send the list of types back to the page.
void HandleRequestListOfTypes(const base::ListValue* args);
+ // Handler for getAllNodes message. Needs a |request_id| argument.
+ void HandleGetAllNodes(const base::ListValue* args);
+
// syncer::JsEventHandler implementation.
virtual void HandleJsEvent(
const std::string& name,
const syncer::JsEventDetails& details) OVERRIDE;
- // syncer::JsReplyHandler implementation.
- virtual void HandleJsReply(
- const std::string& name,
- const syncer::JsArgList& args) OVERRIDE;
+ // Callback used in GetAllNodes.
+ void OnReceivedAllNodes(int request_id, scoped_ptr<base::ListValue> nodes);
// ProfileSyncServiceObserver implementation.
virtual void OnStateChanged() OVERRIDE;
virtual void OnProtocolEvent(const syncer::ProtocolEvent& e) OVERRIDE;
private:
- // Helper function to register JsController function callbacks.
- void RegisterJsControllerCallback(const std::string& name);
-
// Fetches updated aboutInfo and sends it to the page in the form of an
// onAboutInfoUpdated event.
void SendAboutInfo();
ProfileSyncService* GetProfileSyncService();
base::WeakPtr<syncer::JsController> js_controller_;
+
+ // A flag used to prevent double-registration with ProfileSyncService.
+ bool is_registered_;
+
base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler);