Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: content/browser/webui/web_ui.h

Issue 9003014: Replace WebUI::tab_contents() with web_contents() and switch all users to use web_contents.h inst... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/webui/generic_handler.cc ('k') | content/browser/webui/web_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 13 #include "base/callback.h"
14 #include "base/callback_old.h" 14 #include "base/callback_old.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/public/common/page_transition_types.h" 18 #include "content/public/common/page_transition_types.h"
19 #include "ipc/ipc_channel.h" 19 #include "ipc/ipc_channel.h"
20 20
21 class GURL; 21 class GURL;
22 class RenderViewHost; 22 class RenderViewHost;
23 class TabContents;
24 class WebUIMessageHandler; 23 class WebUIMessageHandler;
25 24
26 namespace base { 25 namespace base {
27 class DictionaryValue; 26 class DictionaryValue;
28 class ListValue; 27 class ListValue;
29 class Value; 28 class Value;
30 } 29 }
31 30
31 namespace content {
32 class WebContents;
33 }
34
32 // A WebUI sets up the datasources and message handlers for a given HTML-based 35 // A WebUI sets up the datasources and message handlers for a given HTML-based
33 // UI. 36 // UI.
34 // 37 //
35 // NOTE: If you're creating a new WebUI for Chrome code, make sure you extend 38 // NOTE: If you're creating a new WebUI for Chrome code, make sure you extend
36 // ChromeWebUI. 39 // ChromeWebUI.
37 class CONTENT_EXPORT WebUI : public IPC::Channel::Listener { 40 class CONTENT_EXPORT WebUI : public IPC::Channel::Listener {
38 public: 41 public:
39 explicit WebUI(TabContents* contents); 42 explicit WebUI(content::WebContents* contents);
40 virtual ~WebUI(); 43 virtual ~WebUI();
41 44
42 // IPC message handling. 45 // IPC message handling.
43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
44 virtual void OnWebUISend(const GURL& source_url, 47 virtual void OnWebUISend(const GURL& source_url,
45 const std::string& message, 48 const std::string& message,
46 const base::ListValue& args); 49 const base::ListValue& args);
47 50
48 // Called by RenderViewHost when the RenderView is first created. This is 51 // Called by RenderViewHost when the RenderView is first created. This is
49 // *not* called for every page load because in some cases 52 // *not* called for every page load because in some cases
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 const base::Value& arg2, 142 const base::Value& arg2,
140 const base::Value& arg3); 143 const base::Value& arg3);
141 void CallJavascriptFunction(const std::string& function_name, 144 void CallJavascriptFunction(const std::string& function_name,
142 const base::Value& arg1, 145 const base::Value& arg1,
143 const base::Value& arg2, 146 const base::Value& arg2,
144 const base::Value& arg3, 147 const base::Value& arg3,
145 const base::Value& arg4); 148 const base::Value& arg4);
146 void CallJavascriptFunction(const std::string& function_name, 149 void CallJavascriptFunction(const std::string& function_name,
147 const std::vector<const base::Value*>& args); 150 const std::vector<const base::Value*>& args);
148 151
149 TabContents* tab_contents() const { return tab_contents_; } 152 content::WebContents* web_contents() const { return web_contents_; }
150 153
151 // An opaque identifier used to identify a WebUI. This can only be compared to 154 // An opaque identifier used to identify a WebUI. This can only be compared to
152 // kNoWebUI or other WebUI types. See GetWebUIType. 155 // kNoWebUI or other WebUI types. See GetWebUIType.
153 typedef void* TypeID; 156 typedef void* TypeID;
154 157
155 // A special WebUI type that signifies that a given page would not use the 158 // A special WebUI type that signifies that a given page would not use the
156 // Web UI system. 159 // Web UI system.
157 static const TypeID kNoWebUI; 160 static const TypeID kNoWebUI;
158 161
159 // Returns JavaScript code that, when executed, calls the function specified 162 // Returns JavaScript code that, when executed, calls the function specified
(...skipping 19 matching lines...) Expand all
179 content::PageTransition link_transition_type_; // Defaults to LINK. 182 content::PageTransition link_transition_type_; // Defaults to LINK.
180 int bindings_; // The bindings from BindingsPolicy that should be enabled for 183 int bindings_; // The bindings from BindingsPolicy that should be enabled for
181 // this page. 184 // this page.
182 185
183 // Used by test mocks. See the public getters for more information. 186 // Used by test mocks. See the public getters for more information.
184 bool register_callback_overwrites_; // Defaults to false. 187 bool register_callback_overwrites_; // Defaults to false.
185 188
186 // The WebUIMessageHandlers we own. 189 // The WebUIMessageHandlers we own.
187 std::vector<WebUIMessageHandler*> handlers_; 190 std::vector<WebUIMessageHandler*> handlers_;
188 191
189 // Non-owning pointer to the TabContents this WebUI is associated with. 192 // Non-owning pointer to the WebContents this WebUI is associated with.
190 TabContents* tab_contents_; 193 content::WebContents* web_contents_;
191 194
192 private: 195 private:
193 // A map of message name -> message handling callback. 196 // A map of message name -> message handling callback.
194 typedef std::map<std::string, MessageCallback> MessageCallbackMap; 197 typedef std::map<std::string, MessageCallback> MessageCallbackMap;
195 MessageCallbackMap message_callbacks_; 198 MessageCallbackMap message_callbacks_;
196 199
197 // The path for the iframe this WebUI is embedded in (empty if not in an 200 // The path for the iframe this WebUI is embedded in (empty if not in an
198 // iframe). 201 // iframe).
199 std::string frame_xpath_; 202 std::string frame_xpath_;
200 203
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 friend class WebUIBrowserTest; 244 friend class WebUIBrowserTest;
242 245
243 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; } 246 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; }
244 247
245 WebUI* web_ui_; 248 WebUI* web_ui_;
246 249
247 DISALLOW_COPY_AND_ASSIGN(WebUIMessageHandler); 250 DISALLOW_COPY_AND_ASSIGN(WebUIMessageHandler);
248 }; 251 };
249 252
250 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ 253 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_
OLDNEW
« no previous file with comments | « content/browser/webui/generic_handler.cc ('k') | content/browser/webui/web_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698