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_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 94 |
95 Value* value() const { return value_.get(); } | 95 Value* value() const { return value_.get(); } |
96 | 96 |
97 private: | 97 private: |
98 int id_; | 98 int id_; |
99 scoped_ptr<Value> value_; | 99 scoped_ptr<Value> value_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(ExecuteNotificationObserver); | 101 DISALLOW_COPY_AND_ASSIGN(ExecuteNotificationObserver); |
102 }; | 102 }; |
103 | 103 |
104 // TODO(joi): Put relevant bits of RWH documentation here. | |
105 // TODO(joi): Move to content namespace. | |
106 // TODO(joi): Move to separate file under content/public/browser. | |
107 class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost { | |
108 public: | |
109 // Returns the RenderViewHost given its ID and the ID of its render process. | |
110 // Returns NULL if the IDs do not correspond to a live RenderViewHost. | |
111 static RenderViewHost* FromID(int render_process_id, int render_view_id); | |
112 | |
113 virtual ~RenderViewHost() {} | |
114 | |
115 // Tell the render view to enable a set of javascript bindings. The argument | |
116 // should be a combination of values from BindingsPolicy. | |
117 virtual void AllowBindings(int binding_flags) = 0; | |
118 | |
119 // Tells the renderer to clear the focused node (if any). | |
120 virtual void ClearFocusedNode() = 0; | |
121 | |
122 // Causes the renderer to close the current page, including running its | |
123 // onunload event handler. A ClosePage_ACK message will be sent to the | |
124 // ResourceDispatcherHost when it is finished. | |
125 virtual void ClosePage() = 0; | |
126 | |
127 // Copies the image at location x, y to the clipboard (if there indeed is an | |
128 // image at that location). | |
129 virtual void CopyImageAt(int x, int y) = 0; | |
130 | |
131 // Sent to the renderer when a popup window should no longer count against | |
132 // the current popup count (either because it's not a popup or because it was | |
133 // a generated by a user action). | |
134 virtual void DisassociateFromPopupCount() = 0; | |
135 | |
136 // Notifies the renderer about the result of a desktop notification. | |
137 virtual void DesktopNotificationPermissionRequestDone( | |
138 int callback_context) = 0; | |
139 virtual void DesktopNotificationPostDisplay(int callback_context) = 0; | |
140 virtual void DesktopNotificationPostError(int notification_id, | |
141 const string16& message) = 0; | |
142 virtual void DesktopNotificationPostClose(int notification_id, | |
143 bool by_user) = 0; | |
144 virtual void DesktopNotificationPostClick(int notification_id) = 0; | |
145 | |
146 // Notifies the listener that a directory enumeration is complete. | |
147 virtual void DirectoryEnumerationFinished( | |
148 int request_id, | |
149 const std::vector<FilePath>& files) = 0; | |
150 | |
151 // Tells the renderer not to add scrollbars with height and width below a | |
152 // threshold. | |
153 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) = 0; | |
154 | |
155 // Notifies the renderer that a a drag operation that it started has ended, | |
156 // either in a drop or by being cancelled. | |
157 virtual void DragSourceEndedAt( | |
158 int client_x, int client_y, int screen_x, int screen_y, | |
159 WebKit::WebDragOperation operation) = 0; | |
160 | |
161 // Notifies the renderer that a drag and drop operation is in progress, with | |
162 // droppable items positioned over the renderer's view. | |
163 virtual void DragSourceMovedTo( | |
164 int client_x, int client_y, int screen_x, int screen_y) = 0; | |
165 | |
166 // Notifies the renderer that we're done with the drag and drop operation. | |
167 // This allows the renderer to reset some state. | |
168 virtual void DragSourceSystemDragEnded() = 0; | |
169 | |
170 // D&d drop target messages that get sent to WebKit. | |
171 virtual void DragTargetDragEnter( | |
172 const WebDropData& drop_data, | |
173 const gfx::Point& client_pt, | |
174 const gfx::Point& screen_pt, | |
175 WebKit::WebDragOperationsMask operations_allowed) = 0; | |
176 virtual void DragTargetDragOver( | |
177 const gfx::Point& client_pt, | |
178 const gfx::Point& screen_pt, | |
179 WebKit::WebDragOperationsMask operations_allowed) = 0; | |
180 virtual void DragTargetDragLeave() = 0; | |
181 virtual void DragTargetDrop(const gfx::Point& client_pt, | |
182 const gfx::Point& screen_pt) = 0; | |
183 | |
184 // Instructs the RenderView to automatically resize and send back updates | |
185 // for the new size. | |
186 virtual void EnableAutoResize(const gfx::Size& min_size, | |
187 const gfx::Size& max_size) = 0; | |
188 | |
189 // Instructs the RenderView to send back updates to the preferred size. | |
190 virtual void EnablePreferredSizeMode() = 0; | |
191 | |
192 // Executes custom context menu action that was provided from WebKit. | |
193 virtual void ExecuteCustomContextMenuCommand( | |
194 int action, const content::CustomContextMenuContext& context) = 0; | |
195 | |
196 // Tells the renderer to perform the given action on the media player | |
197 // located at the given point. | |
198 virtual void ExecuteMediaPlayerActionAtLocation( | |
199 const gfx::Point& location, | |
200 const WebKit::WebMediaPlayerAction& action) = 0; | |
201 | |
202 // Runs some javascript within the context of a frame in the page. | |
203 virtual void ExecuteJavascriptInWebFrame(const string16& frame_xpath, | |
204 const string16& jscript) = 0; | |
205 | |
206 // Runs some javascript within the context of a frame in the page. The result | |
207 // is sent back via the notification EXECUTE_JAVASCRIPT_RESULT. | |
208 virtual int ExecuteJavascriptInWebFrameNotifyResult( | |
209 const string16& frame_xpath, | |
210 const string16& jscript) = 0; | |
211 | |
212 virtual Value* ExecuteJavascriptAndGetValue(const string16& frame_xpath, | |
213 const string16& jscript) = 0; | |
214 | |
215 // Tells the renderer to perform the given action on the plugin located at | |
216 // the given point. | |
217 virtual void ExecutePluginActionAtLocation( | |
218 const gfx::Point& location, const WebKit::WebPluginAction& action) = 0; | |
219 | |
220 // Asks the renderer to exit fullscreen | |
221 virtual void ExitFullscreen() = 0; | |
222 | |
223 // Finds text on a page. | |
224 virtual void Find(int request_id, const string16& search_text, | |
225 const WebKit::WebFindOptions& options) = 0; | |
226 | |
227 // Causes the renderer to invoke the onbeforeunload event handler. The | |
228 // result will be returned via ViewMsg_ShouldClose. See also ClosePage and | |
229 // SwapOut, which fire the PageUnload event. | |
230 // | |
231 // Set bool for_cross_site_transition when this close is just for the current | |
232 // RenderView in the case of a cross-site transition. False means we're | |
233 // closing the entire tab. | |
234 virtual void FirePageBeforeUnload(bool for_cross_site_transition) = 0; | |
235 | |
236 // Notifies the Listener that one or more files have been chosen by the user | |
237 // from a file chooser dialog for the form. |permissions| are flags from the | |
238 // base::PlatformFileFlags enum which specify which file permissions should | |
239 // be granted to the renderer. | |
240 virtual void FilesSelectedInChooser(const std::vector<FilePath>& files, | |
241 int permissions) = 0; | |
242 | |
243 virtual content::RenderViewHostDelegate* GetDelegate() const = 0; | |
244 | |
245 // Returns a bitwise OR of bindings types that have been enabled for this | |
246 // RenderView. See BindingsPolicy for details. | |
247 virtual int GetEnabledBindings() const = 0; | |
248 | |
249 virtual content::SessionStorageNamespace* GetSessionStorageNamespace() = 0; | |
250 | |
251 virtual content::SiteInstance* GetSiteInstance() const = 0; | |
252 | |
253 // Requests the renderer to evaluate an xpath to a frame and insert css | |
254 // into that frame's document. | |
255 virtual void InsertCSS(const string16& frame_xpath, | |
256 const std::string& css) = 0; | |
257 | |
258 // Returns true if the RenderView is active and has not crashed. Virtual | |
259 // because it is overridden by TestRenderViewHost. | |
260 virtual bool IsRenderViewLive() const = 0; | |
261 | |
262 // Let the renderer know that the menu has been closed. | |
263 virtual void NotifyContextMenuClosed( | |
264 const content::CustomContextMenuContext& context) = 0; | |
265 | |
266 // Notification that a move or resize renderer's containing window has | |
267 // started. | |
268 virtual void NotifyMoveOrResizeStarted() = 0; | |
269 | |
270 // Reloads the current focused frame. | |
271 virtual void ReloadFrame() = 0; | |
272 | |
273 // Sets the alternate error page URL (link doctor) for the renderer process. | |
274 virtual void SetAltErrorPageURL(const GURL& url) = 0; | |
275 | |
276 // Sets a property with the given name and value on the Web UI binding object. | |
277 // Must call AllowWebUIBindings() on this renderer first. | |
278 virtual void SetWebUIProperty(const std::string& name, | |
279 const std::string& value) = 0; | |
280 | |
281 // Set the zoom level for the current main frame | |
282 virtual void SetZoomLevel(double level) = 0; | |
283 | |
284 // Notifies the renderer that the user has closed the FindInPage window | |
285 // (and what action to take regarding the selection). | |
286 virtual void StopFinding(content::StopFindAction action) = 0; | |
287 | |
288 // Send the renderer process the current preferences supplied by the | |
289 // RenderViewHostDelegate. | |
290 virtual void SyncRendererPrefs() = 0; | |
291 | |
292 virtual void ToggleSpeechInput() = 0; | |
293 | |
294 // Passes a list of Webkit preferences to the renderer. | |
295 virtual void UpdateWebkitPreferences(const WebPreferences& prefs) = 0; | |
296 | |
297 // Changes the zoom level for the current main frame. | |
298 virtual void Zoom(content::PageZoom zoom) = 0; | |
299 }; | |
300 | |
301 #if defined(OS_WIN) | |
darin (slow to review)
2012/03/01 23:15:39
nit: maybe this should be #if defined(COMPILER_MSV
Jói
2012/03/02 10:40:36
Done, changed this as well in render_view_impl.h w
| |
302 // RenderViewHostImpl is the bottom of a diamond-shaped hierarchy, | |
303 // with RenderWidgetHost at the root. VS warns when methods from the | |
304 // root are overridden in only one of the base classes and not both | |
305 // (in this case, RenderWidgetHostImpl provides implementations of | |
306 // many of the methods). This is a silly warning when dealing with | |
307 // pure virtual methods that only have a single implementation in the | |
308 // hierarchy above this class, and is safe to ignore in this case. | |
309 #pragma warning(push) | |
310 #pragma warning(disable: 4250) | |
311 #endif | |
312 | |
104 // | 313 // |
105 // RenderViewHost | 314 // RenderViewHostImpl |
106 // | 315 // |
107 // A RenderViewHost is responsible for creating and talking to a RenderView | 316 // A RenderViewHost is responsible for creating and talking to a RenderView |
108 // object in a child process. It exposes a high level API to users, for things | 317 // object in a child process. It exposes a high level API to users, for things |
109 // like loading pages, adjusting the display and other browser functionality, | 318 // like loading pages, adjusting the display and other browser functionality, |
110 // which it translates into IPC messages sent over the IPC channel with the | 319 // which it translates into IPC messages sent over the IPC channel with the |
111 // RenderView. It responds to all IPC messages sent by that RenderView and | 320 // RenderView. It responds to all IPC messages sent by that RenderView and |
112 // cracks them, calling a delegate object back with higher level types where | 321 // cracks them, calling a delegate object back with higher level types where |
113 // possible. | 322 // possible. |
114 // | 323 // |
115 // The intent of this class is to provide a view-agnostic communication | 324 // The intent of this class is to provide a view-agnostic communication |
116 // conduit with a renderer. This is so we can build HTML views not only as | 325 // conduit with a renderer. This is so we can build HTML views not only as |
117 // TabContents (see TabContents for an example) but also as views, etc. | 326 // TabContents (see TabContents for an example) but also as views, etc. |
118 // | 327 // |
119 // The exact API of this object needs to be more thoroughly designed. Right | 328 // The exact API of this object needs to be more thoroughly designed. Right |
120 // now it mimics what TabContents exposed, which is a fairly large API and may | 329 // now it mimics what TabContents exposed, which is a fairly large API and may |
121 // contain things that are not relevant to a common subset of views. See also | 330 // contain things that are not relevant to a common subset of views. See also |
122 // the comment in render_view_host_delegate.h about the size and scope of the | 331 // the comment in render_view_host_delegate.h about the size and scope of the |
123 // delegate API. | 332 // delegate API. |
124 // | 333 // |
125 // Right now, the concept of page navigation (both top level and frame) exists | 334 // Right now, the concept of page navigation (both top level and frame) exists |
126 // in the TabContents still, so if you instantiate one of these elsewhere, you | 335 // in the TabContents still, so if you instantiate one of these elsewhere, you |
127 // will not be able to traverse pages back and forward. We need to determine | 336 // will not be able to traverse pages back and forward. We need to determine |
128 // if we want to bring that and other functionality down into this object so | 337 // if we want to bring that and other functionality down into this object so |
129 // it can be shared by others. | 338 // it can be shared by others. |
130 // | 339 // TODO(joi): Move to content namespace. |
131 // TODO(joi): Hide most of this from chrome. | 340 class CONTENT_EXPORT RenderViewHostImpl |
132 class CONTENT_EXPORT RenderViewHost : public RenderWidgetHostImpl { | 341 : public RenderViewHost, |
342 public RenderWidgetHostImpl { | |
133 public: | 343 public: |
134 // Returns the RenderViewHost given its ID and the ID of its render process. | 344 // Convenience function, just like RenderViewHost::FromID. |
135 // Returns NULL if the IDs do not correspond to a live RenderViewHost. | 345 static RenderViewHostImpl* FromID(int render_process_id, int render_view_id); |
136 static RenderViewHost* FromID(int render_process_id, int render_view_id); | |
137 | 346 |
138 // routing_id could be a valid route id, or it could be MSG_ROUTING_NONE, in | 347 // routing_id could be a valid route id, or it could be MSG_ROUTING_NONE, in |
139 // which case RenderWidgetHost will create a new one. | 348 // which case RenderWidgetHost will create a new one. |
140 // | 349 // |
141 // The session storage namespace parameter allows multiple render views and | 350 // The session storage namespace parameter allows multiple render views and |
142 // tab contentses to share the same session storage (part of the WebStorage | 351 // tab contentses to share the same session storage (part of the WebStorage |
143 // spec) space. This is useful when restoring tabs, but most callers should | 352 // spec) space. This is useful when restoring tabs, but most callers should |
144 // pass in NULL which will cause a new SessionStorageNamespace to be created. | 353 // pass in NULL which will cause a new SessionStorageNamespace to be created. |
145 RenderViewHost(content::SiteInstance* instance, | 354 RenderViewHostImpl( |
146 content::RenderViewHostDelegate* delegate, | 355 content::SiteInstance* instance, |
147 int routing_id, | 356 content::RenderViewHostDelegate* delegate, |
148 content::SessionStorageNamespace* session_storage_namespace); | 357 int routing_id, |
149 virtual ~RenderViewHost(); | 358 content::SessionStorageNamespace* session_storage_namespace); |
359 virtual ~RenderViewHostImpl(); | |
150 | 360 |
151 content::SiteInstance* site_instance() const { return instance_; } | 361 // RenderViewHost implementation. |
152 content::RenderViewHostDelegate* delegate() const { return delegate_; } | 362 virtual void AllowBindings(int binding_flags) OVERRIDE; |
363 virtual void ClearFocusedNode() OVERRIDE; | |
364 virtual void ClosePage() OVERRIDE; | |
365 virtual void CopyImageAt(int x, int y) OVERRIDE; | |
366 virtual void DisassociateFromPopupCount() OVERRIDE; | |
367 virtual void DesktopNotificationPermissionRequestDone( | |
368 int callback_context) OVERRIDE; | |
369 virtual void DesktopNotificationPostDisplay(int callback_context) OVERRIDE; | |
370 virtual void DesktopNotificationPostError(int notification_id, | |
371 const string16& message) OVERRIDE; | |
372 virtual void DesktopNotificationPostClose(int notification_id, | |
373 bool by_user) OVERRIDE; | |
374 virtual void DesktopNotificationPostClick(int notification_id) OVERRIDE; | |
375 virtual void DirectoryEnumerationFinished( | |
376 int request_id, | |
377 const std::vector<FilePath>& files) OVERRIDE; | |
378 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) OVERRIDE; | |
379 virtual void DragSourceEndedAt( | |
380 int client_x, int client_y, int screen_x, int screen_y, | |
381 WebKit::WebDragOperation operation) OVERRIDE; | |
382 virtual void DragSourceMovedTo( | |
383 int client_x, int client_y, int screen_x, int screen_y) OVERRIDE; | |
384 virtual void DragSourceSystemDragEnded() OVERRIDE; | |
385 virtual void DragTargetDragEnter( | |
386 const WebDropData& drop_data, | |
387 const gfx::Point& client_pt, | |
388 const gfx::Point& screen_pt, | |
389 WebKit::WebDragOperationsMask operations_allowed) OVERRIDE; | |
390 virtual void DragTargetDragOver( | |
391 const gfx::Point& client_pt, | |
392 const gfx::Point& screen_pt, | |
393 WebKit::WebDragOperationsMask operations_allowed) OVERRIDE; | |
394 virtual void DragTargetDragLeave() OVERRIDE; | |
395 virtual void DragTargetDrop(const gfx::Point& client_pt, | |
396 const gfx::Point& screen_pt) OVERRIDE; | |
397 virtual void EnableAutoResize(const gfx::Size& min_size, | |
398 const gfx::Size& max_size) OVERRIDE; | |
399 virtual void EnablePreferredSizeMode() OVERRIDE; | |
400 virtual void ExecuteCustomContextMenuCommand( | |
401 int action, const content::CustomContextMenuContext& context) OVERRIDE; | |
402 virtual void ExecuteMediaPlayerActionAtLocation( | |
403 const gfx::Point& location, | |
404 const WebKit::WebMediaPlayerAction& action) OVERRIDE; | |
405 virtual void ExecuteJavascriptInWebFrame(const string16& frame_xpath, | |
406 const string16& jscript) OVERRIDE; | |
407 virtual int ExecuteJavascriptInWebFrameNotifyResult( | |
408 const string16& frame_xpath, | |
409 const string16& jscript) OVERRIDE; | |
410 virtual Value* ExecuteJavascriptAndGetValue(const string16& frame_xpath, | |
411 const string16& jscript) OVERRIDE; | |
412 virtual void ExecutePluginActionAtLocation( | |
413 const gfx::Point& location, | |
414 const WebKit::WebPluginAction& action) OVERRIDE; | |
415 virtual void ExitFullscreen() OVERRIDE; | |
416 virtual void Find(int request_id, const string16& search_text, | |
417 const WebKit::WebFindOptions& options) OVERRIDE; | |
418 virtual void FirePageBeforeUnload(bool for_cross_site_transition) OVERRIDE; | |
419 virtual void FilesSelectedInChooser(const std::vector<FilePath>& files, | |
420 int permissions) OVERRIDE; | |
421 virtual content::RenderViewHostDelegate* GetDelegate() const OVERRIDE; | |
422 virtual int GetEnabledBindings() const OVERRIDE; | |
423 virtual content::SessionStorageNamespace* | |
424 GetSessionStorageNamespace() OVERRIDE; | |
425 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE; | |
426 virtual void InsertCSS(const string16& frame_xpath, | |
427 const std::string& css) OVERRIDE; | |
428 virtual bool IsRenderViewLive() const OVERRIDE; | |
429 virtual void NotifyContextMenuClosed( | |
430 const content::CustomContextMenuContext& context) OVERRIDE; | |
431 virtual void NotifyMoveOrResizeStarted() OVERRIDE; | |
432 virtual void ReloadFrame() OVERRIDE; | |
433 virtual void SetAltErrorPageURL(const GURL& url) OVERRIDE; | |
434 virtual void SetWebUIProperty(const std::string& name, | |
435 const std::string& value) OVERRIDE; | |
436 virtual void SetZoomLevel(double level) OVERRIDE; | |
437 virtual void StopFinding(content::StopFindAction action) OVERRIDE; | |
438 virtual void SyncRendererPrefs() OVERRIDE; | |
439 virtual void ToggleSpeechInput() OVERRIDE; | |
440 virtual void UpdateWebkitPreferences(const WebPreferences& prefs) OVERRIDE; | |
441 virtual void Zoom(content::PageZoom zoom) OVERRIDE; | |
442 | |
153 void set_delegate(content::RenderViewHostDelegate* d) { | 443 void set_delegate(content::RenderViewHostDelegate* d) { |
154 CHECK(d); // http://crbug.com/82827 | 444 CHECK(d); // http://crbug.com/82827 |
155 delegate_ = d; | 445 delegate_ = d; |
156 } | 446 } |
157 | 447 |
158 // Set up the RenderView child process. Virtual because it is overridden by | 448 // Set up the RenderView child process. Virtual because it is overridden by |
159 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used | 449 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used |
160 // as the name of the new top-level frame. If |max_page_id| is larger than | 450 // as the name of the new top-level frame. If |max_page_id| is larger than |
161 // -1, the RenderView is told to start issuing page IDs at |max_page_id| + 1. | 451 // -1, the RenderView is told to start issuing page IDs at |max_page_id| + 1. |
162 virtual bool CreateRenderView(const string16& frame_name, int32 max_page_id); | 452 virtual bool CreateRenderView(const string16& frame_name, int32 max_page_id); |
163 | 453 |
164 // Returns true if the RenderView is active and has not crashed. Virtual | |
165 // because it is overridden by TestRenderViewHost. | |
166 virtual bool IsRenderViewLive() const; | |
167 | |
168 base::TerminationStatus render_view_termination_status() const { | 454 base::TerminationStatus render_view_termination_status() const { |
169 return render_view_termination_status_; | 455 return render_view_termination_status_; |
170 } | 456 } |
171 | 457 |
172 // Send the renderer process the current preferences supplied by the | |
173 // RenderViewHostDelegate. | |
174 void SyncRendererPrefs(); | |
175 | |
176 // Sends the given navigation message. Use this rather than sending it | 458 // Sends the given navigation message. Use this rather than sending it |
177 // yourself since this does the internal bookkeeping described below. This | 459 // yourself since this does the internal bookkeeping described below. This |
178 // function takes ownership of the provided message pointer. | 460 // function takes ownership of the provided message pointer. |
179 // | 461 // |
180 // If a cross-site request is in progress, we may be suspended while waiting | 462 // If a cross-site request is in progress, we may be suspended while waiting |
181 // for the onbeforeunload handler, so this function might buffer the message | 463 // for the onbeforeunload handler, so this function might buffer the message |
182 // rather than sending it. | 464 // rather than sending it. |
183 void Navigate(const ViewMsg_Navigate_Params& message); | 465 void Navigate(const ViewMsg_Navigate_Params& message); |
184 | 466 |
185 // Load the specified URL, this is a shortcut for Navigate(). | 467 // Load the specified URL, this is a shortcut for Navigate(). |
(...skipping 17 matching lines...) Expand all Loading... | |
203 | 485 |
204 // Clears any suspended navigation state after a cross-site navigation is | 486 // Clears any suspended navigation state after a cross-site navigation is |
205 // canceled or suspended. This is important if we later return to this | 487 // canceled or suspended. This is important if we later return to this |
206 // RenderViewHost. | 488 // RenderViewHost. |
207 void CancelSuspendedNavigations(); | 489 void CancelSuspendedNavigations(); |
208 | 490 |
209 // Whether this RenderViewHost has been swapped out to be displayed by a | 491 // Whether this RenderViewHost has been swapped out to be displayed by a |
210 // different process. | 492 // different process. |
211 bool is_swapped_out() const { return is_swapped_out_; } | 493 bool is_swapped_out() const { return is_swapped_out_; } |
212 | 494 |
213 // Causes the renderer to invoke the onbeforeunload event handler. The | |
214 // result will be returned via ViewMsg_ShouldClose. See also ClosePage and | |
215 // SwapOut, which fire the PageUnload event. | |
216 // | |
217 // Set bool for_cross_site_transition when this close is just for the current | |
218 // RenderView in the case of a cross-site transition. False means we're | |
219 // closing the entire tab. | |
220 void FirePageBeforeUnload(bool for_cross_site_transition); | |
221 | |
222 // Tells the renderer that this RenderView is being swapped out for one in a | 495 // Tells the renderer that this RenderView is being swapped out for one in a |
223 // different renderer process. It should run its unload handler and move to | 496 // different renderer process. It should run its unload handler and move to |
224 // a blank document. The renderer should preserve the Frame object until it | 497 // a blank document. The renderer should preserve the Frame object until it |
225 // exits, in case we come back. The renderer can exit if it has no other | 498 // exits, in case we come back. The renderer can exit if it has no other |
226 // active RenderViews, but not until WasSwappedOut is called (when it is no | 499 // active RenderViews, but not until WasSwappedOut is called (when it is no |
227 // longer visible). | 500 // longer visible). |
228 // | 501 // |
229 // Please see ViewMsg_SwapOut_Params in view_messages.h for a description | 502 // Please see ViewMsg_SwapOut_Params in view_messages.h for a description |
230 // of the parameters. | 503 // of the parameters. |
231 void SwapOut(int new_render_process_host_id, int new_request_id); | 504 void SwapOut(int new_render_process_host_id, int new_request_id); |
232 | 505 |
233 // Called by ResourceDispatcherHost after the SwapOutACK is received. | 506 // Called by ResourceDispatcherHost after the SwapOutACK is received. |
234 void OnSwapOutACK(); | 507 void OnSwapOutACK(); |
235 | 508 |
236 // Called to notify the renderer that it has been visibly swapped out and | 509 // Called to notify the renderer that it has been visibly swapped out and |
237 // replaced by another RenderViewHost, after an earlier call to SwapOut. | 510 // replaced by another RenderViewHost, after an earlier call to SwapOut. |
238 // It is now safe for the process to exit if there are no other active | 511 // It is now safe for the process to exit if there are no other active |
239 // RenderViews. | 512 // RenderViews. |
240 void WasSwappedOut(); | 513 void WasSwappedOut(); |
241 | 514 |
242 // Causes the renderer to close the current page, including running its | |
243 // onunload event handler. A ClosePage_ACK message will be sent to the | |
244 // ResourceDispatcherHost when it is finished. | |
245 void ClosePage(); | |
246 | |
247 // Close the page ignoring whether it has unload events registers. | 515 // Close the page ignoring whether it has unload events registers. |
248 // This is called after the beforeunload and unload events have fired | 516 // This is called after the beforeunload and unload events have fired |
249 // and the user has agreed to continue with closing the page. | 517 // and the user has agreed to continue with closing the page. |
250 void ClosePageIgnoringUnloadEvents(); | 518 void ClosePageIgnoringUnloadEvents(); |
251 | 519 |
252 // Sets whether this RenderViewHost has an outstanding cross-site request, | 520 // Sets whether this RenderViewHost has an outstanding cross-site request, |
253 // for which another renderer will need to run an onunload event handler. | 521 // for which another renderer will need to run an onunload event handler. |
254 // This is called before the first navigation event for this RenderViewHost, | 522 // This is called before the first navigation event for this RenderViewHost, |
255 // and again after the corresponding OnCrossSiteResponse. | 523 // and again after the corresponding OnCrossSiteResponse. |
256 void SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id); | 524 void SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id); |
257 | 525 |
258 // Returns the request_id for the pending cross-site request. | 526 // Returns the request_id for the pending cross-site request. |
259 // This is just needed in case the unload of the current page | 527 // This is just needed in case the unload of the current page |
260 // hangs, in which case we need to swap to the pending RenderViewHost. | 528 // hangs, in which case we need to swap to the pending RenderViewHost. |
261 int GetPendingRequestId(); | 529 int GetPendingRequestId(); |
262 | 530 |
263 // D&d drop target messages that get sent to WebKit. | |
264 void DragTargetDragEnter(const WebDropData& drop_data, | |
265 const gfx::Point& client_pt, | |
266 const gfx::Point& screen_pt, | |
267 WebKit::WebDragOperationsMask operations_allowed); | |
268 void DragTargetDragOver(const gfx::Point& client_pt, | |
269 const gfx::Point& screen_pt, | |
270 WebKit::WebDragOperationsMask operations_allowed); | |
271 void DragTargetDragLeave(); | |
272 void DragTargetDrop(const gfx::Point& client_pt, | |
273 const gfx::Point& screen_pt); | |
274 | |
275 // Notifies the renderer about the result of a desktop notification. | |
276 void DesktopNotificationPermissionRequestDone(int callback_context); | |
277 void DesktopNotificationPostDisplay(int callback_context); | |
278 void DesktopNotificationPostError(int notification_id, | |
279 const string16& message); | |
280 void DesktopNotificationPostClose(int notification_id, bool by_user); | |
281 void DesktopNotificationPostClick(int notification_id); | |
282 | |
283 // Runs some javascript within the context of a frame in the page. | |
284 void ExecuteJavascriptInWebFrame(const string16& frame_xpath, | |
285 const string16& jscript); | |
286 | |
287 // Runs some javascript within the context of a frame in the page. The result | |
288 // is sent back via the notification EXECUTE_JAVASCRIPT_RESULT. | |
289 int ExecuteJavascriptInWebFrameNotifyResult(const string16& frame_xpath, | |
290 const string16& jscript); | |
291 | |
292 Value* ExecuteJavascriptAndGetValue(const string16& frame_xpath, | |
293 const string16& jscript); | |
294 | |
295 | |
296 // Notifies the RenderView that the JavaScript message that was shown was | 531 // Notifies the RenderView that the JavaScript message that was shown was |
297 // closed by the user. | 532 // closed by the user. |
298 void JavaScriptDialogClosed(IPC::Message* reply_msg, | 533 void JavaScriptDialogClosed(IPC::Message* reply_msg, |
299 bool success, | 534 bool success, |
300 const string16& user_input); | 535 const string16& user_input); |
301 | 536 |
302 // Notifies the renderer that a a drag operation that it started has ended, | |
303 // either in a drop or by being cancelled. | |
304 void DragSourceEndedAt( | |
305 int client_x, int client_y, int screen_x, int screen_y, | |
306 WebKit::WebDragOperation operation); | |
307 | |
308 // Notifies the renderer that a drag and drop operation is in progress, with | |
309 // droppable items positioned over the renderer's view. | |
310 void DragSourceMovedTo( | |
311 int client_x, int client_y, int screen_x, int screen_y); | |
312 | |
313 // Notifies the renderer that we're done with the drag and drop operation. | |
314 // This allows the renderer to reset some state. | |
315 void DragSourceSystemDragEnded(); | |
316 | |
317 // Tell the render view to enable a set of javascript bindings. The argument | |
318 // should be a combination of values from BindingsPolicy. | |
319 void AllowBindings(int binding_flags); | |
320 | |
321 // Returns a bitwise OR of bindings types that have been enabled for this | |
322 // RenderView. See BindingsPolicy for details. | |
323 int enabled_bindings() const { return enabled_bindings_; } | |
324 | |
325 // Sets a property with the given name and value on the Web UI binding object. | |
326 // Must call AllowWebUIBindings() on this renderer first. | |
327 void SetWebUIProperty(const std::string& name, const std::string& value); | |
328 | |
329 // Tells the renderer view to focus the first (last if reverse is true) node. | 537 // Tells the renderer view to focus the first (last if reverse is true) node. |
330 void SetInitialFocus(bool reverse); | 538 void SetInitialFocus(bool reverse); |
331 | 539 |
332 // Get html data by serializing all frames of current page with lists | 540 // Get html data by serializing all frames of current page with lists |
333 // which contain all resource links that have local copy. | 541 // which contain all resource links that have local copy. |
334 // The parameter links contain original URLs of all saved links. | 542 // The parameter links contain original URLs of all saved links. |
335 // The parameter local_paths contain corresponding local file paths of | 543 // The parameter local_paths contain corresponding local file paths of |
336 // all saved links, which matched with vector:links one by one. | 544 // all saved links, which matched with vector:links one by one. |
337 // The parameter local_directory_name is relative path of directory which | 545 // The parameter local_directory_name is relative path of directory which |
338 // contain all saved auxiliary files included all sub frames and resouces. | 546 // contain all saved auxiliary files included all sub frames and resouces. |
339 void GetSerializedHtmlDataForCurrentPageWithLocalLinks( | 547 void GetSerializedHtmlDataForCurrentPageWithLocalLinks( |
340 const std::vector<GURL>& links, | 548 const std::vector<GURL>& links, |
341 const std::vector<FilePath>& local_paths, | 549 const std::vector<FilePath>& local_paths, |
342 const FilePath& local_directory_name); | 550 const FilePath& local_directory_name); |
343 | 551 |
344 // Notifies the Listener that one or more files have been chosen by the user | |
345 // from a file chooser dialog for the form. |permissions| are flags from the | |
346 // base::PlatformFileFlags enum which specify which file permissions should | |
347 // be granted to the renderer. | |
348 void FilesSelectedInChooser(const std::vector<FilePath>& files, | |
349 int permissions); | |
350 | |
351 // Notifies the listener that a directory enumeration is complete. | |
352 void DirectoryEnumerationFinished(int request_id, | |
353 const std::vector<FilePath>& files); | |
354 | |
355 // Notifies the RenderViewHost that its load state changed. | 552 // Notifies the RenderViewHost that its load state changed. |
356 void LoadStateChanged(const GURL& url, | 553 void LoadStateChanged(const GURL& url, |
357 const net::LoadStateWithParam& load_state, | 554 const net::LoadStateWithParam& load_state, |
358 uint64 upload_position, | 555 uint64 upload_position, |
359 uint64 upload_size); | 556 uint64 upload_size); |
360 | 557 |
361 bool SuddenTerminationAllowed() const; | 558 bool SuddenTerminationAllowed() const; |
362 void set_sudden_termination_allowed(bool enabled) { | 559 void set_sudden_termination_allowed(bool enabled) { |
363 sudden_termination_allowed_ = enabled; | 560 sudden_termination_allowed_ = enabled; |
364 } | 561 } |
(...skipping 22 matching lines...) Expand all Loading... | |
387 | 584 |
388 // Creates a full screen RenderWidget. | 585 // Creates a full screen RenderWidget. |
389 void CreateNewFullscreenWidget(int route_id); | 586 void CreateNewFullscreenWidget(int route_id); |
390 | 587 |
391 #if defined(OS_MACOSX) | 588 #if defined(OS_MACOSX) |
392 // Select popup menu related methods (for external popup menus). | 589 // Select popup menu related methods (for external popup menus). |
393 void DidSelectPopupMenuItem(int selected_index); | 590 void DidSelectPopupMenuItem(int selected_index); |
394 void DidCancelPopupMenu(); | 591 void DidCancelPopupMenu(); |
395 #endif | 592 #endif |
396 | 593 |
397 void ToggleSpeechInput(); | |
398 | |
399 void set_save_accessibility_tree_for_testing(bool save) { | 594 void set_save_accessibility_tree_for_testing(bool save) { |
400 save_accessibility_tree_for_testing_ = save; | 595 save_accessibility_tree_for_testing_ = save; |
401 } | 596 } |
402 | 597 |
403 void set_send_accessibility_updated_notifications(bool send) { | 598 void set_send_accessibility_updated_notifications(bool send) { |
404 send_accessibility_updated_notifications_ = send; | 599 send_accessibility_updated_notifications_ = send; |
405 } | 600 } |
406 | 601 |
407 const webkit_glue::WebAccessibility& accessibility_tree_for_testing() { | 602 const webkit_glue::WebAccessibility& accessibility_tree_for_testing() { |
408 return accessibility_tree_; | 603 return accessibility_tree_; |
409 } | 604 } |
410 | 605 |
411 bool is_waiting_for_unload_ack_for_testing() { | 606 bool is_waiting_for_unload_ack_for_testing() { |
412 return is_waiting_for_unload_ack_; | 607 return is_waiting_for_unload_ack_; |
413 } | 608 } |
414 | 609 |
415 // Checks that the given renderer can request |url|, if not it sets it to an | 610 // Checks that the given renderer can request |url|, if not it sets it to an |
416 // empty url. | 611 // empty url. |
417 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, | 612 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, |
418 int renderer_id, | 613 int renderer_id, |
419 GURL* url); | 614 GURL* url); |
420 | 615 |
421 // Sets the alternate error page URL (link doctor) for the renderer process. | |
422 void SetAltErrorPageURL(const GURL& url); | |
423 | |
424 // Asks the renderer to exit fullscreen | |
425 void ExitFullscreen(); | |
426 | |
427 // Passes a list of Webkit preferences to the renderer. | |
428 void UpdateWebkitPreferences(const WebPreferences& prefs); | |
429 | |
430 // Tells the renderer to clear the focused node (if any). | |
431 void ClearFocusedNode(); | |
432 | |
433 // Set the zoom level for the current main frame | |
434 void SetZoomLevel(double level); | |
435 | |
436 // Changes the zoom level for the current main frame. | |
437 void Zoom(content::PageZoom zoom); | |
438 | |
439 // Reloads the current focused frame. | |
440 void ReloadFrame(); | |
441 | |
442 // Finds text on a page. | |
443 void Find(int request_id, const string16& search_text, | |
444 const WebKit::WebFindOptions& options); | |
445 | |
446 // Requests the renderer to evaluate an xpath to a frame and insert css | |
447 // into that frame's document. | |
448 void InsertCSS(const string16& frame_xpath, const std::string& css); | |
449 | |
450 // Tells the renderer not to add scrollbars with height and width below a | |
451 // threshold. | |
452 void DisableScrollbarsForThreshold(const gfx::Size& size); | |
453 | |
454 // Instructs the RenderView to send back updates to the preferred size. | |
455 void EnablePreferredSizeMode(); | |
456 | |
457 // Instructs the RenderView to automatically resize and send back updates | |
458 // for the new size. | |
459 void EnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size); | |
460 | |
461 // Executes custom context menu action that was provided from WebKit. | |
462 void ExecuteCustomContextMenuCommand( | |
463 int action, const content::CustomContextMenuContext& context); | |
464 | |
465 // Let the renderer know that the menu has been closed. | |
466 void NotifyContextMenuClosed( | |
467 const content::CustomContextMenuContext& context); | |
468 | |
469 // Copies the image at location x, y to the clipboard (if there indeed is an | |
470 // image at that location). | |
471 void CopyImageAt(int x, int y); | |
472 | |
473 // Tells the renderer to perform the given action on the media player | |
474 // located at the given point. | |
475 void ExecuteMediaPlayerActionAtLocation( | |
476 const gfx::Point& location, const WebKit::WebMediaPlayerAction& action); | |
477 | |
478 // Tells the renderer to perform the given action on the plugin located at | |
479 // the given point. | |
480 void ExecutePluginActionAtLocation( | |
481 const gfx::Point& location, const WebKit::WebPluginAction& action); | |
482 | |
483 // Sent to the renderer when a popup window should no longer count against | |
484 // the current popup count (either because it's not a popup or because it was | |
485 // a generated by a user action). | |
486 void DisassociateFromPopupCount(); | |
487 | |
488 // Notification that a move or resize renderer's containing window has | |
489 // started. | |
490 void NotifyMoveOrResizeStarted(); | |
491 | |
492 // Notifies the renderer that the user has closed the FindInPage window | |
493 // (and what action to take regarding the selection). | |
494 void StopFinding(content::StopFindAction action); | |
495 | |
496 content::SessionStorageNamespace* session_storage_namespace() { | |
497 return session_storage_namespace_.get(); | |
498 } | |
499 | |
500 // NOTE: Do not add functions that just send an IPC message that are called in | 616 // NOTE: Do not add functions that just send an IPC message that are called in |
501 // one or two places. Have the caller send the IPC message directly. | 617 // one or two places. Have the caller send the IPC message directly. |
502 | 618 |
503 protected: | 619 protected: |
504 friend class content::RenderViewHostObserver; | 620 friend class content::RenderViewHostObserver; |
505 | 621 |
506 // Add and remove observers for filtering IPC messages. Clients must be sure | 622 // Add and remove observers for filtering IPC messages. Clients must be sure |
507 // to remove the observer before they go away. | 623 // to remove the observer before they go away. |
508 void AddObserver(content::RenderViewHostObserver* observer); | 624 void AddObserver(content::RenderViewHostObserver* observer); |
509 void RemoveObserver(content::RenderViewHostObserver* observer); | 625 void RemoveObserver(content::RenderViewHostObserver* observer); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 | 731 |
616 private: | 732 private: |
617 friend class TestRenderViewHost; | 733 friend class TestRenderViewHost; |
618 | 734 |
619 // Sets whether this RenderViewHost is swapped out in favor of another, | 735 // Sets whether this RenderViewHost is swapped out in favor of another, |
620 // and clears any waiting state that is no longer relevant. | 736 // and clears any waiting state that is no longer relevant. |
621 void SetSwappedOut(bool is_swapped_out); | 737 void SetSwappedOut(bool is_swapped_out); |
622 | 738 |
623 void ClearPowerSaveBlockers(); | 739 void ClearPowerSaveBlockers(); |
624 | 740 |
741 // Our delegate, which wants to know about changes in the RenderView. | |
742 content::RenderViewHostDelegate* delegate_; | |
743 | |
625 // The SiteInstance associated with this RenderViewHost. All pages drawn | 744 // The SiteInstance associated with this RenderViewHost. All pages drawn |
626 // in this RenderViewHost are part of this SiteInstance. Should not change | 745 // in this RenderViewHost are part of this SiteInstance. Should not change |
627 // over time. | 746 // over time. |
628 scoped_refptr<SiteInstanceImpl> instance_; | 747 scoped_refptr<SiteInstanceImpl> instance_; |
629 | 748 |
630 // Our delegate, which wants to know about changes in the RenderView. | |
631 content::RenderViewHostDelegate* delegate_; | |
632 | |
633 // true if we are currently waiting for a response for drag context | 749 // true if we are currently waiting for a response for drag context |
634 // information. | 750 // information. |
635 bool waiting_for_drag_context_response_; | 751 bool waiting_for_drag_context_response_; |
636 | 752 |
637 // A bitwise OR of bindings types that have been enabled for this RenderView. | 753 // A bitwise OR of bindings types that have been enabled for this RenderView. |
638 // See BindingsPolicy for details. | 754 // See BindingsPolicy for details. |
639 int enabled_bindings_; | 755 int enabled_bindings_; |
640 | 756 |
641 // The request_id for the pending cross-site request. Set to -1 if | 757 // The request_id for the pending cross-site request. Set to -1 if |
642 // there is a pending request, but we have not yet started the unload | 758 // there is a pending request, but we have not yet started the unload |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 base::TerminationStatus render_view_termination_status_; | 820 base::TerminationStatus render_view_termination_status_; |
705 | 821 |
706 // Holds PowerSaveBlockers for the media players in use. Key is the | 822 // Holds PowerSaveBlockers for the media players in use. Key is the |
707 // player_cookie passed to OnMediaNotification, value is the PowerSaveBlocker. | 823 // player_cookie passed to OnMediaNotification, value is the PowerSaveBlocker. |
708 typedef std::map<int64, PowerSaveBlocker*> PowerSaveBlockerMap; | 824 typedef std::map<int64, PowerSaveBlocker*> PowerSaveBlockerMap; |
709 PowerSaveBlockerMap power_save_blockers_; | 825 PowerSaveBlockerMap power_save_blockers_; |
710 | 826 |
711 // A list of observers that filter messages. Weak references. | 827 // A list of observers that filter messages. Weak references. |
712 ObserverList<content::RenderViewHostObserver> observers_; | 828 ObserverList<content::RenderViewHostObserver> observers_; |
713 | 829 |
714 DISALLOW_COPY_AND_ASSIGN(RenderViewHost); | 830 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); |
715 }; | 831 }; |
716 | 832 |
833 #if defined(OS_WIN) | |
834 #pragma warning(pop) | |
835 #endif | |
836 | |
717 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ | 837 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
OLD | NEW |