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_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_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/callback.h" |
12 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
13 #include "base/process_util.h" | 14 #include "base/process_util.h" |
14 #include "base/string16.h" | 15 #include "base/string16.h" |
15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
16 #include "content/public/common/javascript_message_type.h" | 17 #include "content/public/common/javascript_message_type.h" |
| 18 #include "content/public/common/media_stream_request.h" |
17 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
18 #include "net/base/load_states.h" | 20 #include "net/base/load_states.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" |
20 #include "webkit/glue/window_open_disposition.h" | 22 #include "webkit/glue/window_open_disposition.h" |
21 | 23 |
22 class GURL; | 24 class GURL; |
23 class SkBitmap; | 25 class SkBitmap; |
24 class WebContentsImpl; | 26 class WebContentsImpl; |
25 class WebKeyboardEvent; | 27 class WebKeyboardEvent; |
26 struct ViewHostMsg_CreateWindow_Params; | 28 struct ViewHostMsg_CreateWindow_Params; |
(...skipping 23 matching lines...) Expand all Loading... |
50 class RenderViewHostDelegateView; | 52 class RenderViewHostDelegateView; |
51 class SessionStorageNamespace; | 53 class SessionStorageNamespace; |
52 class WebContents; | 54 class WebContents; |
53 struct ContextMenuParams; | 55 struct ContextMenuParams; |
54 struct FileChooserParams; | 56 struct FileChooserParams; |
55 struct GlobalRequestID; | 57 struct GlobalRequestID; |
56 struct NativeWebKeyboardEvent; | 58 struct NativeWebKeyboardEvent; |
57 struct Referrer; | 59 struct Referrer; |
58 struct RendererPreferences; | 60 struct RendererPreferences; |
59 | 61 |
| 62 typedef base::Callback< void(const MediaStreamDevices&) > MediaResponseCallback; |
| 63 |
60 // | 64 // |
61 // RenderViewHostDelegate | 65 // RenderViewHostDelegate |
62 // | 66 // |
63 // An interface implemented by an object interested in knowing about the state | 67 // An interface implemented by an object interested in knowing about the state |
64 // of the RenderViewHost. | 68 // of the RenderViewHost. |
65 // | 69 // |
66 // This interface currently encompasses every type of message that was | 70 // This interface currently encompasses every type of message that was |
67 // previously being sent by WebContents itself. Some of these notifications | 71 // previously being sent by WebContents itself. Some of these notifications |
68 // may not be relevant to all users of RenderViewHost and we should consider | 72 // may not be relevant to all users of RenderViewHost and we should consider |
69 // exposing a more generic Send function on RenderViewHost and a response | 73 // exposing a more generic Send function on RenderViewHost and a response |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // IPC::Channel::Listener implementation. | 111 // IPC::Channel::Listener implementation. |
108 // This is used to give the delegate a chance to filter IPC messages. | 112 // This is used to give the delegate a chance to filter IPC messages. |
109 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 113 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
110 | 114 |
111 // Gets the URL that is currently being displayed, if there is one. | 115 // Gets the URL that is currently being displayed, if there is one. |
112 virtual const GURL& GetURL() const; | 116 virtual const GURL& GetURL() const; |
113 | 117 |
114 // Return this object cast to a WebContents, if it is one. If the object is | 118 // Return this object cast to a WebContents, if it is one. If the object is |
115 // not a WebContents, returns NULL. DEPRECATED: Be sure to include brettw or | 119 // not a WebContents, returns NULL. DEPRECATED: Be sure to include brettw or |
116 // jam as reviewers before you use this method. http://crbug.com/82582 | 120 // jam as reviewers before you use this method. http://crbug.com/82582 |
117 virtual content::WebContents* GetAsWebContents(); | 121 virtual WebContents* GetAsWebContents(); |
118 | 122 |
119 // Return the rect where to display the resize corner, if any, otherwise | 123 // Return the rect where to display the resize corner, if any, otherwise |
120 // an empty rect. | 124 // an empty rect. |
121 virtual gfx::Rect GetRootWindowResizerRect() const = 0; | 125 virtual gfx::Rect GetRootWindowResizerRect() const = 0; |
122 | 126 |
123 // The RenderView is being constructed (message sent to the renderer process | 127 // The RenderView is being constructed (message sent to the renderer process |
124 // to construct a RenderView). Now is a good time to send other setup events | 128 // to construct a RenderView). Now is a good time to send other setup events |
125 // to the RenderView. This precedes any other commands to the RenderView. | 129 // to the RenderView. This precedes any other commands to the RenderView. |
126 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} | 130 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} |
127 | 131 |
128 // The RenderView has been constructed. | 132 // The RenderView has been constructed. |
129 virtual void RenderViewReady(RenderViewHost* render_view_host) {} | 133 virtual void RenderViewReady(RenderViewHost* render_view_host) {} |
130 | 134 |
131 // The RenderView died somehow (crashed or was killed by the user). | 135 // The RenderView died somehow (crashed or was killed by the user). |
132 virtual void RenderViewGone(RenderViewHost* render_view_host, | 136 virtual void RenderViewGone(RenderViewHost* render_view_host, |
133 base::TerminationStatus status, | 137 base::TerminationStatus status, |
134 int error_code) {} | 138 int error_code) {} |
135 | 139 |
136 // The RenderView is going to be deleted. This is called when each | 140 // The RenderView is going to be deleted. This is called when each |
137 // RenderView is going to be destroyed | 141 // RenderView is going to be destroyed |
138 virtual void RenderViewDeleted(RenderViewHost* render_view_host) {} | 142 virtual void RenderViewDeleted(RenderViewHost* render_view_host) {} |
139 | 143 |
140 // The RenderView started a provisional load for a given frame. | 144 // The RenderView started a provisional load for a given frame. |
141 virtual void DidStartProvisionalLoadForFrame( | 145 virtual void DidStartProvisionalLoadForFrame( |
142 content::RenderViewHost* render_view_host, | 146 RenderViewHost* render_view_host, |
143 int64 frame_id, | 147 int64 frame_id, |
144 bool main_frame, | 148 bool main_frame, |
145 const GURL& opener_url, | 149 const GURL& opener_url, |
146 const GURL& url) {} | 150 const GURL& url) {} |
147 | 151 |
148 // The RenderView processed a redirect during a provisional load. | 152 // The RenderView processed a redirect during a provisional load. |
149 // | 153 // |
150 // TODO(creis): Remove this method and have the pre-rendering code listen to | 154 // TODO(creis): Remove this method and have the pre-rendering code listen to |
151 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification | 155 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification |
152 // instead. See http://crbug.com/78512. | 156 // instead. See http://crbug.com/78512. |
153 virtual void DidRedirectProvisionalLoad( | 157 virtual void DidRedirectProvisionalLoad( |
154 content::RenderViewHost* render_view_host, | 158 RenderViewHost* render_view_host, |
155 int32 page_id, | 159 int32 page_id, |
156 const GURL& opener_url, | 160 const GURL& opener_url, |
157 const GURL& source_url, | 161 const GURL& source_url, |
158 const GURL& target_url) {} | 162 const GURL& target_url) {} |
159 | 163 |
160 // A provisional load in the RenderView failed. | 164 // A provisional load in the RenderView failed. |
161 virtual void DidFailProvisionalLoadWithError( | 165 virtual void DidFailProvisionalLoadWithError( |
162 content::RenderViewHost* render_view_host, | 166 RenderViewHost* render_view_host, |
163 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) {} | 167 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) {} |
164 | 168 |
165 // The RenderView was navigated to a different page. | 169 // The RenderView was navigated to a different page. |
166 virtual void DidNavigate(RenderViewHost* render_view_host, | 170 virtual void DidNavigate(RenderViewHost* render_view_host, |
167 const ViewHostMsg_FrameNavigate_Params& params) {} | 171 const ViewHostMsg_FrameNavigate_Params& params) {} |
168 | 172 |
169 // The state for the page changed and should be updated. | 173 // The state for the page changed and should be updated. |
170 virtual void UpdateState(RenderViewHost* render_view_host, | 174 virtual void UpdateState(RenderViewHost* render_view_host, |
171 int32 page_id, | 175 int32 page_id, |
172 const std::string& state) {} | 176 const std::string& state) {} |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 virtual void DocumentAvailableInMainFrame(RenderViewHost* render_view_host) {} | 218 virtual void DocumentAvailableInMainFrame(RenderViewHost* render_view_host) {} |
215 | 219 |
216 // The onload handler in the RenderView's main frame has completed. | 220 // The onload handler in the RenderView's main frame has completed. |
217 virtual void DocumentOnLoadCompletedInMainFrame( | 221 virtual void DocumentOnLoadCompletedInMainFrame( |
218 RenderViewHost* render_view_host, | 222 RenderViewHost* render_view_host, |
219 int32 page_id) {} | 223 int32 page_id) {} |
220 | 224 |
221 // The page wants to open a URL with the specified disposition. | 225 // The page wants to open a URL with the specified disposition. |
222 virtual void RequestOpenURL(RenderViewHost* rvh, | 226 virtual void RequestOpenURL(RenderViewHost* rvh, |
223 const GURL& url, | 227 const GURL& url, |
224 const content::Referrer& referrer, | 228 const Referrer& referrer, |
225 WindowOpenDisposition disposition, | 229 WindowOpenDisposition disposition, |
226 int64 source_frame_id) {} | 230 int64 source_frame_id) {} |
227 | 231 |
228 // The page wants to transfer the request to a new renderer. | 232 // The page wants to transfer the request to a new renderer. |
229 virtual void RequestTransferURL( | 233 virtual void RequestTransferURL( |
230 const GURL& url, | 234 const GURL& url, |
231 const content::Referrer& referrer, | 235 const Referrer& referrer, |
232 WindowOpenDisposition disposition, | 236 WindowOpenDisposition disposition, |
233 int64 source_frame_id, | 237 int64 source_frame_id, |
234 const content::GlobalRequestID& old_request_id) {} | 238 const GlobalRequestID& old_request_id) {} |
235 | 239 |
236 // The page wants to close the active view in this tab. | 240 // The page wants to close the active view in this tab. |
237 virtual void RouteCloseEvent(RenderViewHost* rvh) {} | 241 virtual void RouteCloseEvent(RenderViewHost* rvh) {} |
238 | 242 |
239 // The page wants to post a message to the active view in this tab. | 243 // The page wants to post a message to the active view in this tab. |
240 virtual void RouteMessageEvent( | 244 virtual void RouteMessageEvent( |
241 RenderViewHost* rvh, | 245 RenderViewHost* rvh, |
242 const ViewMsg_PostMessage_Params& params) {} | 246 const ViewMsg_PostMessage_Params& params) {} |
243 | 247 |
244 // A javascript message, confirmation or prompt should be shown. | 248 // A javascript message, confirmation or prompt should be shown. |
245 virtual void RunJavaScriptMessage(RenderViewHost* rvh, | 249 virtual void RunJavaScriptMessage(RenderViewHost* rvh, |
246 const string16& message, | 250 const string16& message, |
247 const string16& default_prompt, | 251 const string16& default_prompt, |
248 const GURL& frame_url, | 252 const GURL& frame_url, |
249 content::JavaScriptMessageType type, | 253 JavaScriptMessageType type, |
250 IPC::Message* reply_msg, | 254 IPC::Message* reply_msg, |
251 bool* did_suppress_message) {} | 255 bool* did_suppress_message) {} |
252 | 256 |
253 virtual void RunBeforeUnloadConfirm(RenderViewHost* rvh, | 257 virtual void RunBeforeUnloadConfirm(RenderViewHost* rvh, |
254 const string16& message, | 258 const string16& message, |
255 bool is_reload, | 259 bool is_reload, |
256 IPC::Message* reply_msg) {} | 260 IPC::Message* reply_msg) {} |
257 | 261 |
258 // A message was added to to the console. | 262 // A message was added to to the console. |
259 virtual bool AddMessageToConsole(int32 level, | 263 virtual bool AddMessageToConsole(int32 level, |
260 const string16& message, | 264 const string16& message, |
261 int32 line_no, | 265 int32 line_no, |
262 const string16& source_id); | 266 const string16& source_id); |
263 | 267 |
264 // Return a dummy RendererPreferences object that will be used by the renderer | 268 // Return a dummy RendererPreferences object that will be used by the renderer |
265 // associated with the owning RenderViewHost. | 269 // associated with the owning RenderViewHost. |
266 virtual content::RendererPreferences GetRendererPrefs( | 270 virtual RendererPreferences GetRendererPrefs( |
267 content::BrowserContext* browser_context) const = 0; | 271 BrowserContext* browser_context) const = 0; |
268 | 272 |
269 // Returns a WebPreferences object that will be used by the renderer | 273 // Returns a WebPreferences object that will be used by the renderer |
270 // associated with the owning render view host. | 274 // associated with the owning render view host. |
271 virtual webkit_glue::WebPreferences GetWebkitPrefs(); | 275 virtual webkit_glue::WebPreferences GetWebkitPrefs(); |
272 | 276 |
273 // Notification the user has made a gesture while focus was on the | 277 // Notification the user has made a gesture while focus was on the |
274 // page. This is used to avoid uninitiated user downloads (aka carpet | 278 // page. This is used to avoid uninitiated user downloads (aka carpet |
275 // bombing), see DownloadRequestLimiter for details. | 279 // bombing), see DownloadRequestLimiter for details. |
276 virtual void OnUserGesture() {} | 280 virtual void OnUserGesture() {} |
277 | 281 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // implementing global 'on hover' features external to the view. | 316 // implementing global 'on hover' features external to the view. |
313 virtual void HandleMouseMove() {} | 317 virtual void HandleMouseMove() {} |
314 virtual void HandleMouseDown() {} | 318 virtual void HandleMouseDown() {} |
315 virtual void HandleMouseLeave() {} | 319 virtual void HandleMouseLeave() {} |
316 virtual void HandleMouseUp() {} | 320 virtual void HandleMouseUp() {} |
317 virtual void HandleMouseActivate() {} | 321 virtual void HandleMouseActivate() {} |
318 | 322 |
319 // Called when a file selection is to be done. | 323 // Called when a file selection is to be done. |
320 virtual void RunFileChooser( | 324 virtual void RunFileChooser( |
321 RenderViewHost* render_view_host, | 325 RenderViewHost* render_view_host, |
322 const content::FileChooserParams& params) {} | 326 const FileChooserParams& params) {} |
323 | 327 |
324 // Notification that the page wants to go into or out of fullscreen mode. | 328 // Notification that the page wants to go into or out of fullscreen mode. |
325 virtual void ToggleFullscreenMode(bool enter_fullscreen) {} | 329 virtual void ToggleFullscreenMode(bool enter_fullscreen) {} |
326 virtual bool IsFullscreenForCurrentTab() const; | 330 virtual bool IsFullscreenForCurrentTab() const; |
327 | 331 |
328 // The contents' preferred size changed. | 332 // The contents' preferred size changed. |
329 virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} | 333 virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} |
330 | 334 |
331 // The contents auto-resized and the container should match it. | 335 // The contents auto-resized and the container should match it. |
332 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) {} | 336 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) {} |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // Show the newly created widget with the specified bounds. | 385 // Show the newly created widget with the specified bounds. |
382 // The widget is identified by the route_id passed to CreateNewWidget. | 386 // The widget is identified by the route_id passed to CreateNewWidget. |
383 virtual void ShowCreatedWidget(int route_id, | 387 virtual void ShowCreatedWidget(int route_id, |
384 const gfx::Rect& initial_pos) {} | 388 const gfx::Rect& initial_pos) {} |
385 | 389 |
386 // Show the newly created full screen widget. Similar to above. | 390 // Show the newly created full screen widget. Similar to above. |
387 virtual void ShowCreatedFullscreenWidget(int route_id) {} | 391 virtual void ShowCreatedFullscreenWidget(int route_id) {} |
388 | 392 |
389 // A context menu should be shown, to be built using the context information | 393 // A context menu should be shown, to be built using the context information |
390 // provided in the supplied params. | 394 // provided in the supplied params. |
391 virtual void ShowContextMenu(const content::ContextMenuParams& params) {} | 395 virtual void ShowContextMenu(const ContextMenuParams& params) {} |
| 396 |
| 397 // The render view has requested access to media devices listed in |
| 398 // |request|, and the client should grant or deny that permission by |
| 399 // calling |callback|. |
| 400 virtual void RequestMediaAccessPermission( |
| 401 const MediaStreamRequest* request, |
| 402 const MediaResponseCallback& callback) {} |
392 | 403 |
393 protected: | 404 protected: |
394 virtual ~RenderViewHostDelegate() {} | 405 virtual ~RenderViewHostDelegate() {} |
395 }; | 406 }; |
396 | 407 |
397 } // namespace content | 408 } // namespace content |
398 | 409 |
399 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_ | 410 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_ |
OLD | NEW |