#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/values.h"
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/protocol_event_observer.h"
#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:
SyncInternalsMessageHandler();
virtual ~SyncInternalsMessageHandler();
virtual void RegisterMessages() OVERRIDE;
void ForwardToJsController(const std::string& name, const base::ListValue*);
void HandleRegisterForEvents(const base::ListValue* args);
void HandleRequestUpdatedAboutInfo(const base::ListValue* args);
void HandleRequestListOfTypes(const base::ListValue* args);
virtual void HandleJsEvent(
const std::string& name,
const syncer::JsEventDetails& details) OVERRIDE;
virtual void HandleJsReply(
const std::string& name,
const syncer::JsArgList& args) OVERRIDE;
virtual void OnStateChanged() OVERRIDE;
virtual void OnProtocolEvent(const syncer::ProtocolEvent& e) OVERRIDE;
private:
void RegisterJsControllerCallback(const std::string& name);
void SendAboutInfo();
ProfileSyncService* GetProfileSyncService();
base::WeakPtr<syncer::JsController> js_controller_;
base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler);
};
#endif