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 CONTENT_BROWSER_WEBUI_WEB_UI_H_ | 5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
6 #define CONTENT_BROWSER_WEBUI_WEB_UI_H_ | 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_old.h" | 13 #include "base/callback_old.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "content/common/page_transition_types.h" | 16 #include "content/common/page_transition_types.h" |
17 #include "content/common/content_export.h" | |
darin (slow to review)
2011/09/04 15:41:04
nit: "page" after "content"
Dirk Pranke
2011/09/07 01:46:07
Done.
| |
17 #include "ipc/ipc_channel.h" | 18 #include "ipc/ipc_channel.h" |
18 | 19 |
19 class WebUIMessageHandler; | 20 class WebUIMessageHandler; |
20 class GURL; | 21 class GURL; |
21 class RenderViewHost; | 22 class RenderViewHost; |
22 class TabContents; | 23 class TabContents; |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class DictionaryValue; | 26 class DictionaryValue; |
26 class ListValue; | 27 class ListValue; |
27 class Value; | 28 class Value; |
28 } | 29 } |
29 | 30 |
30 // A WebUI sets up the datasources and message handlers for a given HTML-based | 31 // A WebUI sets up the datasources and message handlers for a given HTML-based |
31 // UI. | 32 // UI. |
32 // | 33 // |
33 // NOTE: If you're creating a new WebUI for Chrome code, make sure you extend | 34 // NOTE: If you're creating a new WebUI for Chrome code, make sure you extend |
34 // ChromeWebUI. | 35 // ChromeWebUI. |
35 class WebUI : public IPC::Channel::Listener { | 36 class CONTENT_EXPORT WebUI : public IPC::Channel::Listener { |
36 public: | 37 public: |
37 explicit WebUI(TabContents* contents); | 38 explicit WebUI(TabContents* contents); |
38 virtual ~WebUI(); | 39 virtual ~WebUI(); |
39 | 40 |
40 // IPC message handling. | 41 // IPC message handling. |
41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
42 virtual void OnWebUISend(const GURL& source_url, | 43 virtual void OnWebUISend(const GURL& source_url, |
43 const std::string& message, | 44 const std::string& message, |
44 const base::ListValue& args); | 45 const base::ListValue& args); |
45 | 46 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 // A map of message name -> message handling callback. | 190 // A map of message name -> message handling callback. |
190 typedef std::map<std::string, MessageCallback*> MessageCallbackMap; | 191 typedef std::map<std::string, MessageCallback*> MessageCallbackMap; |
191 MessageCallbackMap message_callbacks_; | 192 MessageCallbackMap message_callbacks_; |
192 | 193 |
193 DISALLOW_COPY_AND_ASSIGN(WebUI); | 194 DISALLOW_COPY_AND_ASSIGN(WebUI); |
194 }; | 195 }; |
195 | 196 |
196 // Messages sent from the DOM are forwarded via the WebUI to handler | 197 // Messages sent from the DOM are forwarded via the WebUI to handler |
197 // classes. These objects are owned by WebUI and destroyed when the | 198 // classes. These objects are owned by WebUI and destroyed when the |
198 // host is destroyed. | 199 // host is destroyed. |
199 class WebUIMessageHandler { | 200 class CONTENT_EXPORT WebUIMessageHandler { |
200 public: | 201 public: |
201 WebUIMessageHandler(); | 202 WebUIMessageHandler(); |
202 virtual ~WebUIMessageHandler(); | 203 virtual ~WebUIMessageHandler(); |
203 | 204 |
204 // Attaches |this| to |web_ui| in order to handle messages from it. Declared | 205 // Attaches |this| to |web_ui| in order to handle messages from it. Declared |
205 // virtual so that subclasses can do special init work as soon as the web_ui | 206 // virtual so that subclasses can do special init work as soon as the web_ui |
206 // is provided. Returns |this| for convenience. | 207 // is provided. Returns |this| for convenience. |
207 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 208 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
208 | 209 |
209 // Returns true to indicate that a long running operation is in progress and | 210 // Returns true to indicate that a long running operation is in progress and |
(...skipping 19 matching lines...) Expand all Loading... | |
229 // Returns the attached WebUI for this handler. | 230 // Returns the attached WebUI for this handler. |
230 WebUI* web_ui() const { return web_ui_; } | 231 WebUI* web_ui() const { return web_ui_; } |
231 | 232 |
232 WebUI* web_ui_; // TODO(wyck): Make private after merge conflicts go away. | 233 WebUI* web_ui_; // TODO(wyck): Make private after merge conflicts go away. |
233 | 234 |
234 private: | 235 private: |
235 DISALLOW_COPY_AND_ASSIGN(WebUIMessageHandler); | 236 DISALLOW_COPY_AND_ASSIGN(WebUIMessageHandler); |
236 }; | 237 }; |
237 | 238 |
238 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ | 239 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
OLD | NEW |