1// Copyright (c) 2011 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.
4
5#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
6#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
7#pragma once
8
9#include <string>
10
11#include "base/basictypes.h"
12#include "chrome/browser/sync/js_event_handler.h"
13#include "content/browser/webui/web_ui.h"
14
15namespace browser_sync {
16class JsFrontend;
17}  // namespace browser_sync
18
19// The implementation for the chrome://sync-internals page.
20class SyncInternalsUI : public WebUI, public browser_sync::JsEventHandler {
21 public:
22  explicit SyncInternalsUI(TabContents* contents);
23  virtual ~SyncInternalsUI();
24
25  // WebUI implementation.
26  //
27  // The following messages are processed:
28  //
29  // getAboutInfo():
30  //   Immediately fires a onGetAboutInfoFinished() event with a
31  //   dictionary of sync-related stats and info.
32  //
33  // All other messages are routed to the sync service if it exists,
34  // and dropped otherwise.
35  //
36  // TODO(akalin): Add a simple isSyncEnabled() message and make
37  // getAboutInfo() be handled by the sync service.
38  virtual void ProcessWebUIMessage(
39      const ExtensionHostMsg_DomMessage_Params& params);
40
41  // browser_sync::JsEventHandler implementation.
42  virtual void HandleJsEvent(const std::string& name,
43                             const browser_sync::JsArgList& args);
44
45 private:
46  // Returns the sync service's JsFrontend object, or NULL if the sync
47  // service does not exist.
48  browser_sync::JsFrontend* GetJsFrontend();
49
50  DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI);
51};
52
53#endif  // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
54