OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/sync/js/js_event_handler.h" | 14 #include "chrome/browser/sync/js/js_event_handler.h" |
15 #include "chrome/browser/sync/js/js_reply_handler.h" | 15 #include "chrome/browser/sync/js/js_reply_handler.h" |
16 #include "content/browser/webui/web_ui.h" | 16 #include "content/browser/webui/web_ui.h" |
| 17 #include "content/public/browser/web_ui_controller.h" |
17 | 18 |
18 namespace browser_sync { | 19 namespace browser_sync { |
19 class JsController; | 20 class JsController; |
20 } // namespace browser_sync | 21 } // namespace browser_sync |
21 | 22 |
22 // The implementation for the chrome://sync-internals page. | 23 // The implementation for the chrome://sync-internals page. |
23 class SyncInternalsUI : public WebUI, | 24 class SyncInternalsUI : public WebUI, public content::WebUIController, |
24 public browser_sync::JsEventHandler, | 25 public browser_sync::JsEventHandler, |
25 public browser_sync::JsReplyHandler { | 26 public browser_sync::JsReplyHandler { |
26 public: | 27 public: |
27 explicit SyncInternalsUI(content::WebContents* contents); | 28 explicit SyncInternalsUI(content::WebContents* contents); |
28 virtual ~SyncInternalsUI(); | 29 virtual ~SyncInternalsUI(); |
29 | 30 |
30 // WebUI implementation. | 31 // WebUIController implementation. |
31 // | 32 // |
32 // The following messages are processed: | 33 // The following messages are processed: |
33 // | 34 // |
34 // getAboutInfo(): | 35 // getAboutInfo(): |
35 // Immediately fires a onGetAboutInfoFinished() event with a | 36 // Immediately fires a onGetAboutInfoFinished() event with a |
36 // dictionary of sync-related stats and info. | 37 // dictionary of sync-related stats and info. |
37 // | 38 // |
38 // All other messages are routed to the sync service if it exists, | 39 // All other messages are routed to the sync service if it exists, |
39 // and dropped otherwise. | 40 // and dropped otherwise. |
40 // | 41 // |
41 // TODO(akalin): Add a simple isSyncEnabled() message and make | 42 // TODO(akalin): Add a simple isSyncEnabled() message and make |
42 // getAboutInfo() be handled by the sync service. | 43 // getAboutInfo() be handled by the sync service. |
43 virtual void OnWebUISend(const GURL& source_url, | 44 virtual bool OverrideHandleWebUIMessage(const GURL& source_url, |
44 const std::string& name, | 45 const std::string& name, |
45 const base::ListValue& args) OVERRIDE; | 46 const base::ListValue& args) OVERRIDE; |
46 | 47 |
47 // browser_sync::JsEventHandler implementation. | 48 // browser_sync::JsEventHandler implementation. |
48 virtual void HandleJsEvent( | 49 virtual void HandleJsEvent( |
49 const std::string& name, | 50 const std::string& name, |
50 const browser_sync::JsEventDetails& details) OVERRIDE; | 51 const browser_sync::JsEventDetails& details) OVERRIDE; |
51 | 52 |
52 // browser_sync::JsReplyHandler implementation. | 53 // browser_sync::JsReplyHandler implementation. |
53 virtual void HandleJsReply( | 54 virtual void HandleJsReply( |
54 const std::string& name, | 55 const std::string& name, |
55 const browser_sync::JsArgList& args) OVERRIDE; | 56 const browser_sync::JsArgList& args) OVERRIDE; |
56 | 57 |
57 private: | 58 private: |
58 base::WeakPtrFactory<SyncInternalsUI> weak_ptr_factory_; | 59 base::WeakPtrFactory<SyncInternalsUI> weak_ptr_factory_; |
59 base::WeakPtr<browser_sync::JsController> js_controller_; | 60 base::WeakPtr<browser_sync::JsController> js_controller_; |
60 | 61 |
61 DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI); | 62 DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI); |
62 }; | 63 }; |
63 | 64 |
64 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_ | 65 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_ |
OLD | NEW |