OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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> |
(...skipping 25 matching lines...) Expand all Loading... |
36 // | 36 // |
37 // NOTE: If you're creating a new WebUI for Chrome code, make sure you extend | 37 // NOTE: If you're creating a new WebUI for Chrome code, make sure you extend |
38 // ChromeWebUI. | 38 // ChromeWebUI. |
39 class CONTENT_EXPORT WebUI : public IPC::Channel::Listener { | 39 class CONTENT_EXPORT WebUI : public IPC::Channel::Listener { |
40 public: | 40 public: |
41 WebUI(content::WebContents* contents, content::WebUIController* controller); | 41 WebUI(content::WebContents* contents, content::WebUIController* controller); |
42 virtual ~WebUI(); | 42 virtual ~WebUI(); |
43 | 43 |
44 // IPC::Channel::Listener implementation: | 44 // IPC::Channel::Listener implementation: |
45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 46 // TODO(jam): move to private |
| 47 // IPC message handling. |
| 48 void OnWebUISend(const GURL& source_url, |
| 49 const std::string& message, |
| 50 const base::ListValue& args); |
46 | 51 |
47 // Called by TabContents when the RenderView is first created. This is *not* | 52 // Called by TabContents when the RenderView is first created. This is *not* |
48 // called for every page load because in some cases RenderViewHostManager will | 53 // called for every page load because in some cases RenderViewHostManager will |
49 // reuse RenderView instances. | 54 // reuse RenderView instances. |
50 void RenderViewCreated(RenderViewHost* render_view_host); | 55 void RenderViewCreated(RenderViewHost* render_view_host); |
51 | 56 |
52 // Used by WebUIMessageHandlers. If the given message is already registered, | 57 // Used by WebUIMessageHandlers. If the given message is already registered, |
53 // the call has no effect unless |register_callback_overwrites_| is set to | 58 // the call has no effect unless |register_callback_overwrites_| is set to |
54 // true. | 59 // true. |
55 typedef base::Callback<void(const base::ListValue*)> MessageCallback; | 60 typedef base::Callback<void(const base::ListValue*)> MessageCallback; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 std::vector<content::WebUIMessageHandler*> handlers_; | 177 std::vector<content::WebUIMessageHandler*> handlers_; |
173 | 178 |
174 // Non-owning pointer to the WebContents this WebUI is associated with. | 179 // Non-owning pointer to the WebContents this WebUI is associated with. |
175 content::WebContents* web_contents_; | 180 content::WebContents* web_contents_; |
176 | 181 |
177 // TODO(jam): once WebUI objects aren't also WebUIController, make one own the | 182 // TODO(jam): once WebUI objects aren't also WebUIController, make one own the |
178 // other. | 183 // other. |
179 content::WebUIController* controller_; | 184 content::WebUIController* controller_; |
180 | 185 |
181 private: | 186 private: |
182 // IPC message handling. | |
183 void OnWebUISend(const GURL& source_url, | |
184 const std::string& message, | |
185 const base::ListValue& args); | |
186 | |
187 // A map of message name -> message handling callback. | 187 // A map of message name -> message handling callback. |
188 typedef std::map<std::string, MessageCallback> MessageCallbackMap; | 188 typedef std::map<std::string, MessageCallback> MessageCallbackMap; |
189 MessageCallbackMap message_callbacks_; | 189 MessageCallbackMap message_callbacks_; |
190 | 190 |
191 // The path for the iframe this WebUI is embedded in (empty if not in an | 191 // The path for the iframe this WebUI is embedded in (empty if not in an |
192 // iframe). | 192 // iframe). |
193 std::string frame_xpath_; | 193 std::string frame_xpath_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(WebUI); | 195 DISALLOW_COPY_AND_ASSIGN(WebUI); |
196 }; | 196 }; |
197 | 197 |
198 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ | 198 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ |
OLD | NEW |