summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/sync_internals_ui.h
blob: c44e761392b4073fcf270acf218d735588b855a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
#pragma once

#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/sync/js/js_event_handler.h"
#include "chrome/browser/sync/js/js_reply_handler.h"
#include "content/public/browser/web_ui_controller.h"

namespace browser_sync {
class JsController;
}  // namespace browser_sync

// The implementation for the chrome://sync-internals page.
class SyncInternalsUI : public content::WebUIController,
                        public browser_sync::JsEventHandler,
                        public browser_sync::JsReplyHandler {
 public:
  explicit SyncInternalsUI(content::WebUI* web_ui);
  virtual ~SyncInternalsUI();

  // WebUIController implementation.
  //
  // The following messages are processed:
  //
  // getAboutInfo():
  //   Immediately fires a onGetAboutInfoFinished() event with a
  //   dictionary of sync-related stats and info.
  //
  // All other messages are routed to the sync service if it exists,
  // and dropped otherwise.
  //
  // TODO(akalin): Add a simple isSyncEnabled() message and make
  // getAboutInfo() be handled by the sync service.
  virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
                                          const std::string& name,
                                          const base::ListValue& args) OVERRIDE;

  // browser_sync::JsEventHandler implementation.
  virtual void HandleJsEvent(
      const std::string& name,
      const browser_sync::JsEventDetails& details) OVERRIDE;

  // browser_sync::JsReplyHandler implementation.
  virtual void HandleJsReply(
      const std::string& name,
      const browser_sync::JsArgList& args) OVERRIDE;

 private:
  base::WeakPtrFactory<SyncInternalsUI> weak_ptr_factory_;
  base::WeakPtr<browser_sync::JsController> js_controller_;

  DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI);
};

#endif  // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_