1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/public/browser/web_ui_controller.h"
14 #include "sync/js/js_event_handler.h"
15 #include "sync/js/js_reply_handler.h"
21 // The implementation for the chrome://sync-internals page.
22 class SyncInternalsUI : public content::WebUIController,
23 public syncer::JsEventHandler,
24 public syncer::JsReplyHandler {
26 explicit SyncInternalsUI(content::WebUI* web_ui);
27 virtual ~SyncInternalsUI();
29 // WebUIController implementation.
31 // The following messages are processed:
34 // Immediately fires a onGetAboutInfoFinished() event with a
35 // dictionary of sync-related stats and info.
37 // All other messages are routed to the sync service if it exists,
38 // and dropped otherwise.
40 // TODO(akalin): Add a simple isSyncEnabled() message and make
41 // getAboutInfo() be handled by the sync service.
42 virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
43 const std::string& name,
44 const base::ListValue& args) OVERRIDE;
46 // syncer::JsEventHandler implementation.
47 virtual void HandleJsEvent(
48 const std::string& name,
49 const syncer::JsEventDetails& details) OVERRIDE;
51 // syncer::JsReplyHandler implementation.
52 virtual void HandleJsReply(
53 const std::string& name,
54 const syncer::JsArgList& args) OVERRIDE;
57 base::WeakPtr<syncer::JsController> js_controller_;
58 base::WeakPtrFactory<SyncInternalsUI> weak_ptr_factory_;
60 DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI);
63 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_