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