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 |
| 298 #if defined(OS_WIN) |
| 299 // RenderViewHostImpl is the bottom of a diamond-shaped hierarchy, |
| 300 // with RenderWidgetHost at the root. VS warns when methods from the |
| 301 // root are overridden in only one of the base classes and not both |
| 302 // (in this case, RenderWidgetHostImpl provides implementations of |
| 303 // many of the methods). This is a silly warning when dealing with |
| 304 // pure virtual methods that only have a single implementation in the |
| 305 // hierarchy above this class, and is safe to ignore in this case. |
| 306 #pragma warning(push) |
| 307 #pragma warning(disable: 4250) |
| 308 #endif |
| 309 |
104 // | 310 // |
105 // RenderViewHost | 311 // RenderViewHostImpl |
106 // | 312 // |
107 // A RenderViewHost is responsible for creating and talking to a RenderView | 313 // 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 | 314 // 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, | 315 // like loading pages, adjusting the display and other browser functionality, |
110 // which it translates into IPC messages sent over the IPC channel with the | 316 // 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 | 317 // 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 | 318 // cracks them, calling a delegate object back with higher level types where |
113 // possible. | 319 // possible. |
114 // | 320 // |
115 // The intent of this class is to provide a view-agnostic communication | 321 // 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 | 322 // 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. | 323 // TabContents (see TabContents for an example) but also as views, etc. |
118 // | 324 // |
119 // The exact API of this object needs to be more thoroughly designed. Right | 325 // 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 | 326 // 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 | 327 // 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 | 328 // the comment in render_view_host_delegate.h about the size and scope of the |
123 // delegate API. | 329 // delegate API. |
124 // | 330 // |
125 // Right now, the concept of page navigation (both top level and frame) exists | 331 // 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 | 332 // 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 | 333 // 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 | 334 // if we want to bring that and other functionality down into this object so |
129 // it can be shared by others. | 335 // it can be shared by others. |
130 // | 336 // TODO(joi): Move to content namespace. |
131 // TODO(joi): Hide most of this from chrome. | 337 class CONTENT_EXPORT RenderViewHostImpl |
132 class CONTENT_EXPORT RenderViewHost : public RenderWidgetHostImpl { | 338 : public RenderViewHost, |
| 339 public RenderWidgetHostImpl { |
133 public: | 340 public: |
134 // Returns the RenderViewHost given its ID and the ID of its render process. | 341 // Convenience function, just like RenderViewHost::FromID. |
135 // Returns NULL if the IDs do not correspond to a live RenderViewHost. | 342 static RenderViewHostImpl* FromID(int render_process_id, int render_view_id); |
136 static RenderViewHost* FromID(int render_process_id, int render_view_id); | |
137 | 343 |
138 // routing_id could be a valid route id, or it could be MSG_ROUTING_NONE, in | 344 // 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. | 345 // which case RenderWidgetHost will create a new one. |
140 // | 346 // |
141 // The session storage namespace parameter allows multiple render views and | 347 // The session storage namespace parameter allows multiple render views and |
142 // tab contentses to share the same session storage (part of the WebStorage | 348 // 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 | 349 // 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. | 350 // pass in NULL which will cause a new SessionStorageNamespace to be created. |
145 RenderViewHost(content::SiteInstance* instance, | 351 RenderViewHostImpl( |
146 content::RenderViewHostDelegate* delegate, | 352 content::SiteInstance* instance, |
147 int routing_id, | 353 content::RenderViewHostDelegate* delegate, |
148 content::SessionStorageNamespace* session_storage_namespace); | 354 int routing_id, |
149 virtual ~RenderViewHost(); | 355 content::SessionStorageNamespace* session_storage_namespace); |
| 356 virtual ~RenderViewHostImpl(); |
150 | 357 |
151 content::SiteInstance* site_instance() const { return instance_; } | 358 // RenderViewHost implementation. |
152 content::RenderViewHostDelegate* delegate() const { return delegate_; } | 359 virtual void AllowBindings(int binding_flags) OVERRIDE; |
| 360 virtual void ClearFocusedNode() OVERRIDE; |
| 361 virtual void ClosePage() OVERRIDE; |
| 362 virtual void CopyImageAt(int x, int y) OVERRIDE; |
| 363 virtual void DisassociateFromPopupCount() OVERRIDE; |
| 364 virtual void DesktopNotificationPermissionRequestDone( |
| 365 int callback_context) OVERRIDE; |
| 366 virtual void DesktopNotificationPostDisplay(int callback_context) OVERRIDE; |
| 367 virtual void DesktopNotificationPostError(int notification_id, |
| 368 const string16& message) OVERRIDE; |
| 369 virtual void DesktopNotificationPostClose(int notification_id, |
| 370 bool by_user) OVERRIDE; |
| 371 virtual void DesktopNotificationPostClick(int notification_id) OVERRIDE; |
| 372 virtual void DirectoryEnumerationFinished( |
| 373 int request_id, |
| 374 const std::vector<FilePath>& files) OVERRIDE; |
| 375 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) OVERRIDE; |
| 376 virtual void DragSourceEndedAt( |
| 377 int client_x, int client_y, int screen_x, int screen_y, |
| 378 WebKit::WebDragOperation operation) OVERRIDE; |
| 379 virtual void DragSourceMovedTo( |
| 380 int client_x, int client_y, int screen_x, int screen_y) OVERRIDE; |
| 381 virtual void DragSourceSystemDragEnded() OVERRIDE; |
| 382 virtual void DragTargetDragEnter( |
| 383 const WebDropData& drop_data, |
| 384 const gfx::Point& client_pt, |
| 385 const gfx::Point& screen_pt, |
| 386 WebKit::WebDragOperationsMask operations_allowed) OVERRIDE; |
| 387 virtual void DragTargetDragOver( |
| 388 const gfx::Point& client_pt, |
| 389 const gfx::Point& screen_pt, |
| 390 WebKit::WebDragOperationsMask operations_allowed) OVERRIDE; |
| 391 virtual void DragTargetDragLeave() OVERRIDE; |
| 392 virtual void DragTargetDrop(const gfx::Point& client_pt, |
| 393 const gfx::Point& screen_pt) OVERRIDE; |
| 394 virtual void EnableAutoResize(const gfx::Size& min_size, |
| 395 const gfx::Size& max_size) OVERRIDE; |
| 396 virtual void EnablePreferredSizeMode() OVERRIDE; |
| 397 virtual void ExecuteCustomContextMenuCommand( |
| 398 int action, const content::CustomContextMenuContext& context) OVERRIDE; |
| 399 virtual void ExecuteMediaPlayerActionAtLocation( |
| 400 const gfx::Point& location, |
| 401 const WebKit::WebMediaPlayerAction& action) OVERRIDE; |
| 402 virtual void ExecuteJavascriptInWebFrame(const string16& frame_xpath, |
| 403 const string16& jscript) OVERRIDE; |
| 404 virtual int ExecuteJavascriptInWebFrameNotifyResult( |
| 405 const string16& frame_xpath, |
| 406 const string16& jscript) OVERRIDE; |
| 407 virtual Value* ExecuteJavascriptAndGetValue(const string16& frame_xpath, |
| 408 const string16& jscript) OVERRIDE; |
| 409 virtual void ExecutePluginActionAtLocation( |
| 410 const gfx::Point& location, |
| 411 const WebKit::WebPluginAction& action) OVERRIDE; |
| 412 virtual void ExitFullscreen() OVERRIDE; |
| 413 virtual void Find(int request_id, const string16& search_text, |
| 414 const WebKit::WebFindOptions& options) OVERRIDE; |
| 415 virtual void FirePageBeforeUnload(bool for_cross_site_transition) OVERRIDE; |
| 416 virtual void FilesSelectedInChooser(const std::vector<FilePath>& files, |
| 417 int permissions) OVERRIDE; |
| 418 virtual content::RenderViewHostDelegate* GetDelegate() const OVERRIDE; |
| 419 virtual int GetEnabledBindings() const OVERRIDE; |
| 420 virtual content::SessionStorageNamespace* |
| 421 GetSessionStorageNamespace() OVERRIDE; |
| 422 virtual content::SiteInstance* GetSiteInstance() const OVERRIDE; |
| 423 virtual void InsertCSS(const string16& frame_xpath, |
| 424 const std::string& css) OVERRIDE; |
| 425 virtual bool IsRenderViewLive() const OVERRIDE; |
| 426 virtual void NotifyContextMenuClosed( |
| 427 const content::CustomContextMenuContext& context) OVERRIDE; |
| 428 virtual void NotifyMoveOrResizeStarted() OVERRIDE; |
| 429 virtual void ReloadFrame() OVERRIDE; |
| 430 virtual void SetAltErrorPageURL(const GURL& url) OVERRIDE; |
| 431 virtual void SetWebUIProperty(const std::string& name, |
| 432 const std::string& value) OVERRIDE; |
| 433 virtual void SetZoomLevel(double level) OVERRIDE; |
| 434 virtual void StopFinding(content::StopFindAction action) OVERRIDE; |
| 435 virtual void SyncRendererPrefs() OVERRIDE; |
| 436 virtual void ToggleSpeechInput() OVERRIDE; |
| 437 virtual void UpdateWebkitPreferences(const WebPreferences& prefs) OVERRIDE; |
| 438 |
153 void set_delegate(content::RenderViewHostDelegate* d) { | 439 void set_delegate(content::RenderViewHostDelegate* d) { |
154 CHECK(d); // http://crbug.com/82827 | 440 CHECK(d); // http://crbug.com/82827 |
155 delegate_ = d; | 441 delegate_ = d; |
156 } | 442 } |
157 | 443 |
158 // Set up the RenderView child process. Virtual because it is overridden by | 444 // 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 | 445 // 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 | 446 // 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. | 447 // -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); | 448 virtual bool CreateRenderView(const string16& frame_name, int32 max_page_id); |
163 | 449 |
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 { | 450 base::TerminationStatus render_view_termination_status() const { |
169 return render_view_termination_status_; | 451 return render_view_termination_status_; |
170 } | 452 } |
171 | 453 |
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 | 454 // Sends the given navigation message. Use this rather than sending it |
177 // yourself since this does the internal bookkeeping described below. This | 455 // yourself since this does the internal bookkeeping described below. This |
178 // function takes ownership of the provided message pointer. | 456 // function takes ownership of the provided message pointer. |
179 // | 457 // |
180 // If a cross-site request is in progress, we may be suspended while waiting | 458 // 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 | 459 // for the onbeforeunload handler, so this function might buffer the message |
182 // rather than sending it. | 460 // rather than sending it. |
183 void Navigate(const ViewMsg_Navigate_Params& message); | 461 void Navigate(const ViewMsg_Navigate_Params& message); |
184 | 462 |
185 // Load the specified URL, this is a shortcut for Navigate(). | 463 // Load the specified URL, this is a shortcut for Navigate(). |
(...skipping 17 matching lines...) Expand all Loading... |
203 | 481 |
204 // Clears any suspended navigation state after a cross-site navigation is | 482 // Clears any suspended navigation state after a cross-site navigation is |
205 // canceled or suspended. This is important if we later return to this | 483 // canceled or suspended. This is important if we later return to this |
206 // RenderViewHost. | 484 // RenderViewHost. |
207 void CancelSuspendedNavigations(); | 485 void CancelSuspendedNavigations(); |
208 | 486 |
209 // Whether this RenderViewHost has been swapped out to be displayed by a | 487 // Whether this RenderViewHost has been swapped out to be displayed by a |
210 // different process. | 488 // different process. |
211 bool is_swapped_out() const { return is_swapped_out_; } | 489 bool is_swapped_out() const { return is_swapped_out_; } |
212 | 490 |
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 | 491 // 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 | 492 // 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 | 493 // 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 | 494 // 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 | 495 // active RenderViews, but not until WasSwappedOut is called (when it is no |
227 // longer visible). | 496 // longer visible). |
228 // | 497 // |
229 // Please see ViewMsg_SwapOut_Params in view_messages.h for a description | 498 // Please see ViewMsg_SwapOut_Params in view_messages.h for a description |
230 // of the parameters. | 499 // of the parameters. |
231 void SwapOut(int new_render_process_host_id, int new_request_id); | 500 void SwapOut(int new_render_process_host_id, int new_request_id); |
232 | 501 |
233 // Called by ResourceDispatcherHost after the SwapOutACK is received. | 502 // Called by ResourceDispatcherHost after the SwapOutACK is received. |
234 void OnSwapOutACK(); | 503 void OnSwapOutACK(); |
235 | 504 |
236 // Called to notify the renderer that it has been visibly swapped out and | 505 // Called to notify the renderer that it has been visibly swapped out and |
237 // replaced by another RenderViewHost, after an earlier call to SwapOut. | 506 // 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 | 507 // It is now safe for the process to exit if there are no other active |
239 // RenderViews. | 508 // RenderViews. |
240 void WasSwappedOut(); | 509 void WasSwappedOut(); |
241 | 510 |
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. | 511 // Close the page ignoring whether it has unload events registers. |
248 // This is called after the beforeunload and unload events have fired | 512 // This is called after the beforeunload and unload events have fired |
249 // and the user has agreed to continue with closing the page. | 513 // and the user has agreed to continue with closing the page. |
250 void ClosePageIgnoringUnloadEvents(); | 514 void ClosePageIgnoringUnloadEvents(); |
251 | 515 |
252 // Sets whether this RenderViewHost has an outstanding cross-site request, | 516 // Sets whether this RenderViewHost has an outstanding cross-site request, |
253 // for which another renderer will need to run an onunload event handler. | 517 // for which another renderer will need to run an onunload event handler. |
254 // This is called before the first navigation event for this RenderViewHost, | 518 // This is called before the first navigation event for this RenderViewHost, |
255 // and again after the corresponding OnCrossSiteResponse. | 519 // and again after the corresponding OnCrossSiteResponse. |
256 void SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id); | 520 void SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id); |
257 | 521 |
258 // Returns the request_id for the pending cross-site request. | 522 // Returns the request_id for the pending cross-site request. |
259 // This is just needed in case the unload of the current page | 523 // 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. | 524 // hangs, in which case we need to swap to the pending RenderViewHost. |
261 int GetPendingRequestId(); | 525 int GetPendingRequestId(); |
262 | 526 |
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 | 527 // Notifies the RenderView that the JavaScript message that was shown was |
297 // closed by the user. | 528 // closed by the user. |
298 void JavaScriptDialogClosed(IPC::Message* reply_msg, | 529 void JavaScriptDialogClosed(IPC::Message* reply_msg, |
299 bool success, | 530 bool success, |
300 const string16& user_input); | 531 const string16& user_input); |
301 | 532 |
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. | 533 // Tells the renderer view to focus the first (last if reverse is true) node. |
330 void SetInitialFocus(bool reverse); | 534 void SetInitialFocus(bool reverse); |
331 | 535 |
332 // Get html data by serializing all frames of current page with lists | 536 // Get html data by serializing all frames of current page with lists |
333 // which contain all resource links that have local copy. | 537 // which contain all resource links that have local copy. |
334 // The parameter links contain original URLs of all saved links. | 538 // The parameter links contain original URLs of all saved links. |
335 // The parameter local_paths contain corresponding local file paths of | 539 // The parameter local_paths contain corresponding local file paths of |
336 // all saved links, which matched with vector:links one by one. | 540 // all saved links, which matched with vector:links one by one. |
337 // The parameter local_directory_name is relative path of directory which | 541 // The parameter local_directory_name is relative path of directory which |
338 // contain all saved auxiliary files included all sub frames and resouces. | 542 // contain all saved auxiliary files included all sub frames and resouces. |
339 void GetSerializedHtmlDataForCurrentPageWithLocalLinks( | 543 void GetSerializedHtmlDataForCurrentPageWithLocalLinks( |
340 const std::vector<GURL>& links, | 544 const std::vector<GURL>& links, |
341 const std::vector<FilePath>& local_paths, | 545 const std::vector<FilePath>& local_paths, |
342 const FilePath& local_directory_name); | 546 const FilePath& local_directory_name); |
343 | 547 |
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. | 548 // Notifies the RenderViewHost that its load state changed. |
356 void LoadStateChanged(const GURL& url, | 549 void LoadStateChanged(const GURL& url, |
357 const net::LoadStateWithParam& load_state, | 550 const net::LoadStateWithParam& load_state, |
358 uint64 upload_position, | 551 uint64 upload_position, |
359 uint64 upload_size); | 552 uint64 upload_size); |
360 | 553 |
361 bool SuddenTerminationAllowed() const; | 554 bool SuddenTerminationAllowed() const; |
362 void set_sudden_termination_allowed(bool enabled) { | 555 void set_sudden_termination_allowed(bool enabled) { |
363 sudden_termination_allowed_ = enabled; | 556 sudden_termination_allowed_ = enabled; |
364 } | 557 } |
(...skipping 22 matching lines...) Expand all Loading... |
387 | 580 |
388 // Creates a full screen RenderWidget. | 581 // Creates a full screen RenderWidget. |
389 void CreateNewFullscreenWidget(int route_id); | 582 void CreateNewFullscreenWidget(int route_id); |
390 | 583 |
391 #if defined(OS_MACOSX) | 584 #if defined(OS_MACOSX) |
392 // Select popup menu related methods (for external popup menus). | 585 // Select popup menu related methods (for external popup menus). |
393 void DidSelectPopupMenuItem(int selected_index); | 586 void DidSelectPopupMenuItem(int selected_index); |
394 void DidCancelPopupMenu(); | 587 void DidCancelPopupMenu(); |
395 #endif | 588 #endif |
396 | 589 |
397 void ToggleSpeechInput(); | |
398 | |
399 void set_save_accessibility_tree_for_testing(bool save) { | 590 void set_save_accessibility_tree_for_testing(bool save) { |
400 save_accessibility_tree_for_testing_ = save; | 591 save_accessibility_tree_for_testing_ = save; |
401 } | 592 } |
402 | 593 |
403 void set_send_accessibility_updated_notifications(bool send) { | 594 void set_send_accessibility_updated_notifications(bool send) { |
404 send_accessibility_updated_notifications_ = send; | 595 send_accessibility_updated_notifications_ = send; |
405 } | 596 } |
406 | 597 |
407 const webkit_glue::WebAccessibility& accessibility_tree_for_testing() { | 598 const webkit_glue::WebAccessibility& accessibility_tree_for_testing() { |
408 return accessibility_tree_; | 599 return accessibility_tree_; |
409 } | 600 } |
410 | 601 |
411 bool is_waiting_for_unload_ack_for_testing() { | 602 bool is_waiting_for_unload_ack_for_testing() { |
412 return is_waiting_for_unload_ack_; | 603 return is_waiting_for_unload_ack_; |
413 } | 604 } |
414 | 605 |
415 // Checks that the given renderer can request |url|, if not it sets it to an | 606 // Checks that the given renderer can request |url|, if not it sets it to an |
416 // empty url. | 607 // empty url. |
417 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, | 608 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, |
418 int renderer_id, | 609 int renderer_id, |
419 GURL* url); | 610 GURL* url); |
420 | 611 |
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. | 612 // Changes the zoom level for the current main frame. |
437 void Zoom(content::PageZoom zoom); | 613 void Zoom(content::PageZoom zoom); |
438 | 614 |
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 | 615 // 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. | 616 // one or two places. Have the caller send the IPC message directly. |
502 | 617 |
503 protected: | 618 protected: |
504 friend class content::RenderViewHostObserver; | 619 friend class content::RenderViewHostObserver; |
505 | 620 |
506 // Add and remove observers for filtering IPC messages. Clients must be sure | 621 // Add and remove observers for filtering IPC messages. Clients must be sure |
507 // to remove the observer before they go away. | 622 // to remove the observer before they go away. |
508 void AddObserver(content::RenderViewHostObserver* observer); | 623 void AddObserver(content::RenderViewHostObserver* observer); |
509 void RemoveObserver(content::RenderViewHostObserver* observer); | 624 void RemoveObserver(content::RenderViewHostObserver* observer); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 729 |
615 private: | 730 private: |
616 friend class TestRenderViewHost; | 731 friend class TestRenderViewHost; |
617 | 732 |
618 // Sets whether this RenderViewHost is swapped out in favor of another, | 733 // Sets whether this RenderViewHost is swapped out in favor of another, |
619 // and clears any waiting state that is no longer relevant. | 734 // and clears any waiting state that is no longer relevant. |
620 void SetSwappedOut(bool is_swapped_out); | 735 void SetSwappedOut(bool is_swapped_out); |
621 | 736 |
622 void ClearPowerSaveBlockers(); | 737 void ClearPowerSaveBlockers(); |
623 | 738 |
| 739 // Our delegate, which wants to know about changes in the RenderView. |
| 740 content::RenderViewHostDelegate* delegate_; |
| 741 |
624 // The SiteInstance associated with this RenderViewHost. All pages drawn | 742 // The SiteInstance associated with this RenderViewHost. All pages drawn |
625 // in this RenderViewHost are part of this SiteInstance. Should not change | 743 // in this RenderViewHost are part of this SiteInstance. Should not change |
626 // over time. | 744 // over time. |
627 scoped_refptr<SiteInstanceImpl> instance_; | 745 scoped_refptr<SiteInstanceImpl> instance_; |
628 | 746 |
629 // Our delegate, which wants to know about changes in the RenderView. | |
630 content::RenderViewHostDelegate* delegate_; | |
631 | |
632 // true if we are currently waiting for a response for drag context | 747 // true if we are currently waiting for a response for drag context |
633 // information. | 748 // information. |
634 bool waiting_for_drag_context_response_; | 749 bool waiting_for_drag_context_response_; |
635 | 750 |
636 // A bitwise OR of bindings types that have been enabled for this RenderView. | 751 // A bitwise OR of bindings types that have been enabled for this RenderView. |
637 // See BindingsPolicy for details. | 752 // See BindingsPolicy for details. |
638 int enabled_bindings_; | 753 int enabled_bindings_; |
639 | 754 |
640 // The request_id for the pending cross-site request. Set to -1 if | 755 // The request_id for the pending cross-site request. Set to -1 if |
641 // there is a pending request, but we have not yet started the unload | 756 // 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... |
703 base::TerminationStatus render_view_termination_status_; | 818 base::TerminationStatus render_view_termination_status_; |
704 | 819 |
705 // Holds PowerSaveBlockers for the media players in use. Key is the | 820 // Holds PowerSaveBlockers for the media players in use. Key is the |
706 // player_cookie passed to OnMediaNotification, value is the PowerSaveBlocker. | 821 // player_cookie passed to OnMediaNotification, value is the PowerSaveBlocker. |
707 typedef std::map<int64, PowerSaveBlocker*> PowerSaveBlockerMap; | 822 typedef std::map<int64, PowerSaveBlocker*> PowerSaveBlockerMap; |
708 PowerSaveBlockerMap power_save_blockers_; | 823 PowerSaveBlockerMap power_save_blockers_; |
709 | 824 |
710 // A list of observers that filter messages. Weak references. | 825 // A list of observers that filter messages. Weak references. |
711 ObserverList<content::RenderViewHostObserver> observers_; | 826 ObserverList<content::RenderViewHostObserver> observers_; |
712 | 827 |
713 DISALLOW_COPY_AND_ASSIGN(RenderViewHost); | 828 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); |
714 }; | 829 }; |
715 | 830 |
| 831 #if defined(OS_WIN) |
| 832 #pragma warning(pop) |
| 833 #endif |
| 834 |
716 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ | 835 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
OLD | NEW |