OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 // TODO(jam): remove this file when all files have been converted. |
10 #include <vector> | 10 #include "content/browser/renderer_host/render_view_host.h" |
11 | |
12 #include "base/process_util.h" | |
13 #include "base/scoped_ptr.h" | |
14 #include "chrome/browser/renderer_host/render_widget_host.h" | |
15 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | |
16 #include "chrome/common/content_settings_types.h" | |
17 #include "chrome/common/page_zoom.h" | |
18 #include "chrome/common/render_view_commands.h" | |
19 #include "chrome/common/translate_errors.h" | |
20 #include "chrome/common/view_types.h" | |
21 #include "chrome/common/window_container_type.h" | |
22 #include "net/base/load_states.h" | |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | |
27 #include "webkit/glue/webaccessibility.h" | |
28 #include "webkit/glue/window_open_disposition.h" | |
29 | |
30 class ChildProcessSecurityPolicy; | |
31 class FilePath; | |
32 class GURL; | |
33 class ListValue; | |
34 class RenderViewHostDelegate; | |
35 class SessionStorageNamespace; | |
36 class SiteInstance; | |
37 class SkBitmap; | |
38 class ViewMsg_Navigate; | |
39 struct ContentSettings; | |
40 struct ContextMenuParams; | |
41 struct MediaPlayerAction; | |
42 struct ThumbnailScore; | |
43 struct ViewHostMsg_AccessibilityNotification_Params; | |
44 struct ViewHostMsg_CreateWindow_Params; | |
45 struct ViewHostMsg_DomMessage_Params; | |
46 struct ViewHostMsg_ShowPopup_Params; | |
47 struct ViewMsg_Navigate_Params; | |
48 struct WebApplicationInfo; | |
49 struct WebDropData; | |
50 struct WebPreferences; | |
51 struct UserMetricsAction; | |
52 | |
53 namespace gfx { | |
54 class Point; | |
55 } // namespace gfx | |
56 | |
57 namespace webkit_glue { | |
58 struct CustomContextMenuContext; | |
59 struct WebAccessibility; | |
60 } // namespace webkit_glue | |
61 | |
62 namespace WebKit { | |
63 struct WebMediaPlayerAction; | |
64 } // namespace WebKit | |
65 | |
66 class URLRequestContextGetter; | |
67 | |
68 // | |
69 // RenderViewHost | |
70 // | |
71 // A RenderViewHost is responsible for creating and talking to a RenderView | |
72 // object in a child process. It exposes a high level API to users, for things | |
73 // like loading pages, adjusting the display and other browser functionality, | |
74 // which it translates into IPC messages sent over the IPC channel with the | |
75 // RenderView. It responds to all IPC messages sent by that RenderView and | |
76 // cracks them, calling a delegate object back with higher level types where | |
77 // possible. | |
78 // | |
79 // The intent of this class is to provide a view-agnostic communication | |
80 // conduit with a renderer. This is so we can build HTML views not only as | |
81 // TabContents (see TabContents for an example) but also as views, etc. | |
82 // | |
83 // The exact API of this object needs to be more thoroughly designed. Right | |
84 // now it mimics what TabContents exposed, which is a fairly large API and may | |
85 // contain things that are not relevant to a common subset of views. See also | |
86 // the comment in render_view_host_delegate.h about the size and scope of the | |
87 // delegate API. | |
88 // | |
89 // Right now, the concept of page navigation (both top level and frame) exists | |
90 // in the TabContents still, so if you instantiate one of these elsewhere, you | |
91 // will not be able to traverse pages back and forward. We need to determine | |
92 // if we want to bring that and other functionality down into this object so | |
93 // it can be shared by others. | |
94 // | |
95 class RenderViewHost : public RenderWidgetHost { | |
96 public: | |
97 // Returns the RenderViewHost given its ID and the ID of its render process. | |
98 // Returns NULL if the IDs do not correspond to a live RenderViewHost. | |
99 static RenderViewHost* FromID(int render_process_id, int render_view_id); | |
100 | |
101 // routing_id could be a valid route id, or it could be MSG_ROUTING_NONE, in | |
102 // which case RenderWidgetHost will create a new one. | |
103 // | |
104 // The session storage namespace parameter allows multiple render views and | |
105 // tab contentses to share the same session storage (part of the WebStorage | |
106 // spec) space. This is useful when restoring tabs, but most callers should | |
107 // pass in NULL which will cause a new SessionStorageNamespace to be created. | |
108 RenderViewHost(SiteInstance* instance, | |
109 RenderViewHostDelegate* delegate, | |
110 int routing_id, | |
111 SessionStorageNamespace* session_storage_namespace); | |
112 virtual ~RenderViewHost(); | |
113 | |
114 SiteInstance* site_instance() const { return instance_; } | |
115 RenderViewHostDelegate* delegate() const { return delegate_; } | |
116 void set_delegate(RenderViewHostDelegate* d) { delegate_ = d; } | |
117 | |
118 // Set up the RenderView child process. Virtual because it is overridden by | |
119 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used | |
120 // as the name of the new top-level frame. | |
121 virtual bool CreateRenderView(const string16& frame_name); | |
122 | |
123 // Returns true if the RenderView is active and has not crashed. Virtual | |
124 // because it is overridden by TestRenderViewHost. | |
125 virtual bool IsRenderViewLive() const; | |
126 | |
127 base::TerminationStatus render_view_termination_status() const { | |
128 return render_view_termination_status_; | |
129 } | |
130 | |
131 // Send the renderer process the current preferences supplied by the | |
132 // RenderViewHostDelegate. | |
133 void SyncRendererPrefs(); | |
134 | |
135 // Sends the given navigation message. Use this rather than sending it | |
136 // yourself since this does the internal bookkeeping described below. This | |
137 // function takes ownership of the provided message pointer. | |
138 // | |
139 // If a cross-site request is in progress, we may be suspended while waiting | |
140 // for the onbeforeunload handler, so this function might buffer the message | |
141 // rather than sending it. | |
142 void Navigate(const ViewMsg_Navigate_Params& message); | |
143 | |
144 // Load the specified URL, this is a shortcut for Navigate(). | |
145 void NavigateToURL(const GURL& url); | |
146 | |
147 // Returns whether navigation messages are currently suspended for this | |
148 // RenderViewHost. Only true during a cross-site navigation, while waiting | |
149 // for the onbeforeunload handler. | |
150 bool are_navigations_suspended() const { return navigations_suspended_; } | |
151 | |
152 // Suspends (or unsuspends) any navigation messages from being sent from this | |
153 // RenderViewHost. This is called when a pending RenderViewHost is created | |
154 // for a cross-site navigation, because we must suspend any navigations until | |
155 // we hear back from the old renderer's onbeforeunload handler. Note that it | |
156 // is important that only one navigation event happen after calling this | |
157 // method with |suspend| equal to true. If |suspend| is false and there is | |
158 // a suspended_nav_message_, this will send the message. This function | |
159 // should only be called to toggle the state; callers should check | |
160 // are_navigations_suspended() first. | |
161 void SetNavigationsSuspended(bool suspend); | |
162 | |
163 // Causes the renderer to invoke the onbeforeunload event handler. The | |
164 // result will be returned via ViewMsg_ShouldClose. See also ClosePage which | |
165 // will fire the PageUnload event. | |
166 // | |
167 // Set bool for_cross_site_transition when this close is just for the current | |
168 // RenderView in the case of a cross-site transition. False means we're | |
169 // closing the entire tab. | |
170 void FirePageBeforeUnload(bool for_cross_site_transition); | |
171 | |
172 // Causes the renderer to close the current page, including running its | |
173 // onunload event handler. A ClosePage_ACK message will be sent to the | |
174 // ResourceDispatcherHost when it is finished. | |
175 // | |
176 // Please see ViewMsg_ClosePage in resource_messages_internal.h for a | |
177 // description of the parameters. | |
178 void ClosePage(bool for_cross_site_transition, | |
179 int new_render_process_host_id, | |
180 int new_request_id); | |
181 | |
182 // Close the page ignoring whether it has unload events registers. | |
183 // This is called after the beforeunload and unload events have fired | |
184 // and the user has agreed to continue with closing the page. | |
185 void ClosePageIgnoringUnloadEvents(); | |
186 | |
187 // Sets whether this RenderViewHost has an outstanding cross-site request, | |
188 // for which another renderer will need to run an onunload event handler. | |
189 // This is called before the first navigation event for this RenderViewHost, | |
190 // and again after the corresponding OnCrossSiteResponse. | |
191 void SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id); | |
192 | |
193 // Returns the request_id for the pending cross-site request. | |
194 // This is just needed in case the unload of the current page | |
195 // hangs, in which case we need to swap to the pending RenderViewHost. | |
196 int GetPendingRequestId(); | |
197 | |
198 struct CommandState { | |
199 bool is_enabled; | |
200 RenderViewCommandCheckedState checked_state; | |
201 }; | |
202 CommandState GetStateForCommand(RenderViewCommand command) const; | |
203 | |
204 // Stops the current load. | |
205 void Stop(); | |
206 | |
207 // Reloads the current frame. | |
208 void ReloadFrame(); | |
209 | |
210 // Asks the renderer to "render" printed pages and initiate printing on our | |
211 // behalf. | |
212 bool PrintPages(); | |
213 | |
214 // Asks the renderer to render pages for print preview. | |
215 bool PrintPreview(); | |
216 | |
217 // Notify renderer of success/failure of print job. | |
218 void PrintingDone(int document_cookie, bool success); | |
219 | |
220 // Start looking for a string within the content of the page, with the | |
221 // specified options. | |
222 void StartFinding(int request_id, | |
223 const string16& search_string, | |
224 bool forward, | |
225 bool match_case, | |
226 bool find_next); | |
227 | |
228 // Cancel a pending find operation. | |
229 void StopFinding(FindBarController::SelectionAction selection_action); | |
230 | |
231 // Increment, decrement, or reset the zoom level of a page. | |
232 void Zoom(PageZoom::Function function); | |
233 | |
234 // Change the zoom level of a page to a specific value. | |
235 void SetZoomLevel(double zoom_level); | |
236 | |
237 // Change the encoding of the page. | |
238 void SetPageEncoding(const std::string& encoding); | |
239 | |
240 // Reset any override encoding on the page and change back to default. | |
241 void ResetPageEncodingToDefault(); | |
242 | |
243 // Change the alternate error page URL. An empty GURL disables the use of | |
244 // alternate error pages. | |
245 void SetAlternateErrorPageURL(const GURL& url); | |
246 | |
247 // D&d drop target messages that get sent to WebKit. | |
248 void DragTargetDragEnter(const WebDropData& drop_data, | |
249 const gfx::Point& client_pt, | |
250 const gfx::Point& screen_pt, | |
251 WebKit::WebDragOperationsMask operations_allowed); | |
252 void DragTargetDragOver(const gfx::Point& client_pt, | |
253 const gfx::Point& screen_pt, | |
254 WebKit::WebDragOperationsMask operations_allowed); | |
255 void DragTargetDragLeave(); | |
256 void DragTargetDrop(const gfx::Point& client_pt, | |
257 const gfx::Point& screen_pt); | |
258 | |
259 // Tell the RenderView to reserve a range of page ids of the given size. | |
260 void ReservePageIDRange(int size); | |
261 | |
262 // Runs some javascript within the context of a frame in the page. | |
263 void ExecuteJavascriptInWebFrame(const string16& frame_xpath, | |
264 const string16& jscript); | |
265 | |
266 // Runs some javascript within the context of a frame in the page. The result | |
267 // is sent back via the notification EXECUTE_JAVASCRIPT_RESULT. | |
268 int ExecuteJavascriptInWebFrameNotifyResult(const string16& frame_xpath, | |
269 const string16& jscript); | |
270 | |
271 // Insert some css into a frame in the page. |id| is optional, and specifies | |
272 // the element id given when inserting/replacing the style element. | |
273 void InsertCSSInWebFrame(const std::wstring& frame_xpath, | |
274 const std::string& css, | |
275 const std::string& id); | |
276 | |
277 // Logs a message to the console of a frame in the page. | |
278 void AddMessageToConsole(const string16& frame_xpath, | |
279 const string16& message, | |
280 const WebKit::WebConsoleMessage::Level&); | |
281 | |
282 // Edit operations. | |
283 void Undo(); | |
284 void Redo(); | |
285 void Cut(); | |
286 void Copy(); | |
287 void CopyToFindPboard(); | |
288 void Paste(); | |
289 void ToggleSpellCheck(); | |
290 void Delete(); | |
291 void SelectAll(); | |
292 void ToggleSpellPanel(bool is_currently_visible); | |
293 | |
294 // Downloads an image notifying the FavIcon delegate appropriately. The | |
295 // returned integer uniquely identifies the download for the lifetime of the | |
296 // browser. | |
297 int DownloadFavIcon(const GURL& url, int image_size); | |
298 | |
299 // Requests application info for the specified page. This is an asynchronous | |
300 // request. The delegate is notified by way of OnDidGetApplicationInfo when | |
301 // the data is available. | |
302 void GetApplicationInfo(int32 page_id); | |
303 | |
304 // Captures a thumbnail representation of the page. | |
305 void CaptureThumbnail(); | |
306 | |
307 // Captures a snapshot of the page. | |
308 void CaptureSnapshot(); | |
309 | |
310 // Notifies the RenderView that the JavaScript message that was shown was | |
311 // closed by the user. | |
312 void JavaScriptMessageBoxClosed(IPC::Message* reply_msg, | |
313 bool success, | |
314 const std::wstring& prompt); | |
315 | |
316 // Notifies the RenderView that the modal html dialog has been closed. | |
317 void ModalHTMLDialogClosed(IPC::Message* reply_msg, | |
318 const std::string& json_retval); | |
319 | |
320 // Send an action to the media player element located at |location|. | |
321 void MediaPlayerActionAt(const gfx::Point& location, | |
322 const WebKit::WebMediaPlayerAction& action); | |
323 | |
324 // Notifies the renderer that the context menu has closed. | |
325 void ContextMenuClosed( | |
326 const webkit_glue::CustomContextMenuContext& custom_context); | |
327 | |
328 // Prints the node that's under the context menu. | |
329 void PrintNodeUnderContextMenu(); | |
330 | |
331 // Triggers printing of the preview PDF. | |
332 void PrintForPrintPreview(); | |
333 | |
334 // Copies the image at the specified point. | |
335 void CopyImageAt(int x, int y); | |
336 | |
337 // Notifies the renderer that a a drag operation that it started has ended, | |
338 // either in a drop or by being cancelled. | |
339 void DragSourceEndedAt( | |
340 int client_x, int client_y, int screen_x, int screen_y, | |
341 WebKit::WebDragOperation operation); | |
342 | |
343 // Notifies the renderer that a drag and drop operation is in progress, with | |
344 // droppable items positioned over the renderer's view. | |
345 void DragSourceMovedTo( | |
346 int client_x, int client_y, int screen_x, int screen_y); | |
347 | |
348 // Notifies the renderer that we're done with the drag and drop operation. | |
349 // This allows the renderer to reset some state. | |
350 void DragSourceSystemDragEnded(); | |
351 | |
352 // Tell the render view to enable a set of javascript bindings. The argument | |
353 // should be a combination of values from BindingsPolicy. | |
354 void AllowBindings(int binding_flags); | |
355 | |
356 // Returns a bitwise OR of bindings types that have been enabled for this | |
357 // RenderView. See BindingsPolicy for details. | |
358 int enabled_bindings() const { return enabled_bindings_; } | |
359 | |
360 // See variable comment. | |
361 bool is_extension_process() const { return is_extension_process_; } | |
362 void set_is_extension_process(bool is_extension_process) { | |
363 is_extension_process_ = is_extension_process; | |
364 } | |
365 | |
366 // Sets a property with the given name and value on the Web UI binding object. | |
367 // Must call AllowWebUIBindings() on this renderer first. | |
368 void SetWebUIProperty(const std::string& name, const std::string& value); | |
369 | |
370 // Tells the renderer view to focus the first (last if reverse is true) node. | |
371 void SetInitialFocus(bool reverse); | |
372 | |
373 // Clears the node that is currently focused (if any). | |
374 void ClearFocusedNode(); | |
375 | |
376 // Tells the renderer view to scroll to the focused node. | |
377 void ScrollFocusedEditableNodeIntoView(); | |
378 | |
379 // Update render view specific (WebKit) preferences. | |
380 void UpdateWebPreferences(const WebPreferences& prefs); | |
381 | |
382 // Request the Renderer to ask the default plugin to start installation of | |
383 // missing plugin. Called by PluginInstallerInfoBarDelegate. | |
384 void InstallMissingPlugin(); | |
385 | |
386 // Load all blocked plugins in the RenderView. | |
387 void LoadBlockedPlugins(); | |
388 | |
389 // Get all script and frame urls from all frames in the current document. | |
390 // Called when a malware interstitial page is shown. | |
391 void GetMalwareDOMDetails(); | |
392 | |
393 // Get all savable resource links from current webpage, include main | |
394 // frame and sub-frame. | |
395 void GetAllSavableResourceLinksForCurrentPage(const GURL& page_url); | |
396 | |
397 // Get html data by serializing all frames of current page with lists | |
398 // which contain all resource links that have local copy. | |
399 // The parameter links contain original URLs of all saved links. | |
400 // The parameter local_paths contain corresponding local file paths of | |
401 // all saved links, which matched with vector:links one by one. | |
402 // The parameter local_directory_name is relative path of directory which | |
403 // contain all saved auxiliary files included all sub frames and resouces. | |
404 void GetSerializedHtmlDataForCurrentPageWithLocalLinks( | |
405 const std::vector<GURL>& links, | |
406 const std::vector<FilePath>& local_paths, | |
407 const FilePath& local_directory_name); | |
408 | |
409 // Notifies the Listener that one or more files have been chosen by the user | |
410 // from an Open File dialog for the form. | |
411 void FilesSelectedInChooser(const std::vector<FilePath>& files); | |
412 | |
413 // Notifies the RenderViewHost that its load state changed. | |
414 void LoadStateChanged(const GURL& url, net::LoadState load_state, | |
415 uint64 upload_position, uint64 upload_size); | |
416 | |
417 bool SuddenTerminationAllowed() const; | |
418 void set_sudden_termination_allowed(bool enabled) { | |
419 sudden_termination_allowed_ = enabled; | |
420 } | |
421 | |
422 // Forward a message from external host to chrome renderer. | |
423 void ForwardMessageFromExternalHost(const std::string& message, | |
424 const std::string& origin, | |
425 const std::string& target); | |
426 | |
427 // Message the renderer that we should be counted as a new document and not | |
428 // as a popup. | |
429 void DisassociateFromPopupCount(); | |
430 | |
431 // Tells the renderer whether it should allow window.close. This is initially | |
432 // set to false when creating a renderer-initiated window via window.open. | |
433 void AllowScriptToClose(bool visible); | |
434 | |
435 // Notifies the Renderer that a move or resize of its containing window has | |
436 // started (this is used to hide the autocomplete popups if any). | |
437 void WindowMoveOrResizeStarted(); | |
438 | |
439 // RenderWidgetHost public overrides. | |
440 virtual void Shutdown(); | |
441 virtual bool IsRenderView() const; | |
442 virtual bool OnMessageReceived(const IPC::Message& msg); | |
443 virtual void GotFocus(); | |
444 virtual void LostCapture(); | |
445 virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); | |
446 virtual void OnMouseActivate(); | |
447 virtual void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); | |
448 virtual void ForwardEditCommand(const std::string& name, | |
449 const std::string& value); | |
450 virtual void ForwardEditCommandsForNextKeyEvent( | |
451 const EditCommands& edit_commands); | |
452 | |
453 // Creates a new RenderView with the given route id. | |
454 void CreateNewWindow(int route_id, | |
455 const ViewHostMsg_CreateWindow_Params& params); | |
456 | |
457 // Creates a new RenderWidget with the given route id. |popup_type| indicates | |
458 // if this widget is a popup and what kind of popup it is (select, autofill). | |
459 void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); | |
460 | |
461 // Creates a full screen RenderWidget. | |
462 void CreateNewFullscreenWidget(int route_id); | |
463 | |
464 // Sends the response to an extension api call. | |
465 void SendExtensionResponse(int request_id, bool success, | |
466 const std::string& response, | |
467 const std::string& error); | |
468 | |
469 // Sends a response to an extension api call that it was blocked for lack of | |
470 // permission. | |
471 void BlockExtensionRequest(int request_id); | |
472 | |
473 // Tells the renderer which browser window it is being attached to. | |
474 void UpdateBrowserWindowId(int window_id); | |
475 | |
476 // Tells the render view that a custom context action has been selected. | |
477 void PerformCustomContextMenuAction( | |
478 const webkit_glue::CustomContextMenuContext& custom_context, | |
479 unsigned action); | |
480 | |
481 // Informs renderer of updated content settings. | |
482 void SendContentSettings(const GURL& url, | |
483 const ContentSettings& settings); | |
484 | |
485 // Tells the renderer to notify us when the page contents preferred size | |
486 // changed. |flags| is a combination of | |
487 // |ViewHostMsg_EnablePreferredSizeChangedMode_Flags| values, which is defined | |
488 // in render_messages.h. | |
489 void EnablePreferredSizeChangedMode(int flags); | |
490 | |
491 #if defined(OS_MACOSX) | |
492 // Select popup menu related methods (for external popup menus). | |
493 void DidSelectPopupMenuItem(int selected_index); | |
494 void DidCancelPopupMenu(); | |
495 #endif | |
496 | |
497 // SearchBox notifications. | |
498 void SearchBoxChange(const string16& value, | |
499 bool verbatim, | |
500 int selection_start, | |
501 int selection_end); | |
502 void SearchBoxSubmit(const string16& value, | |
503 bool verbatim); | |
504 void SearchBoxCancel(); | |
505 void SearchBoxResize(const gfx::Rect& search_box_bounds); | |
506 void DetermineIfPageSupportsInstant(const string16& value, | |
507 bool verbatim, | |
508 int selection_start, | |
509 int selection_end); | |
510 | |
511 // Send a notification to the V8 JavaScript engine to change its parameters | |
512 // while performing stress testing. |cmd| is one of the values defined by | |
513 // |ViewHostMsg_JavaScriptStressTestControl_Commands|, which is defined | |
514 // in render_messages.h. | |
515 void JavaScriptStressTestControl(int cmd, int param); | |
516 | |
517 #if defined(UNIT_TEST) | |
518 // These functions shouldn't be necessary outside of testing. | |
519 | |
520 void set_save_accessibility_tree_for_testing(bool save) { | |
521 save_accessibility_tree_for_testing_ = save; | |
522 } | |
523 | |
524 const webkit_glue::WebAccessibility& accessibility_tree() { | |
525 return accessibility_tree_; | |
526 } | |
527 | |
528 bool is_waiting_for_unload_ack() { return is_waiting_for_unload_ack_; } | |
529 #endif | |
530 | |
531 // Checks that the given renderer can request |url|, if not it sets it to an | |
532 // empty url. | |
533 static void FilterURL(ChildProcessSecurityPolicy* policy, | |
534 int renderer_id, | |
535 GURL* url); | |
536 | |
537 protected: | |
538 // RenderWidgetHost protected overrides. | |
539 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | |
540 bool* is_keyboard_shortcut); | |
541 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event); | |
542 virtual void OnUserGesture(); | |
543 virtual void NotifyRendererUnresponsive(); | |
544 virtual void NotifyRendererResponsive(); | |
545 virtual void OnMsgFocusedNodeChanged(bool is_editable_node); | |
546 virtual void OnMsgFocus(); | |
547 virtual void OnMsgBlur(); | |
548 | |
549 // IPC message handlers. | |
550 void OnMsgShowView(int route_id, | |
551 WindowOpenDisposition disposition, | |
552 const gfx::Rect& initial_pos, | |
553 bool user_gesture); | |
554 void OnMsgShowWidget(int route_id, const gfx::Rect& initial_pos); | |
555 void OnMsgShowFullscreenWidget(int route_id); | |
556 void OnMsgRunModal(IPC::Message* reply_msg); | |
557 void OnMsgRenderViewReady(); | |
558 void OnMsgRenderViewGone(int status, int error_code); | |
559 void OnMsgNavigate(const IPC::Message& msg); | |
560 void OnMsgUpdateState(int32 page_id, | |
561 const std::string& state); | |
562 void OnMsgUpdateTitle(int32 page_id, const std::wstring& title); | |
563 void OnMsgUpdateEncoding(const std::string& encoding); | |
564 void OnMsgUpdateTargetURL(int32 page_id, const GURL& url); | |
565 void OnMsgThumbnail(const GURL& url, | |
566 const ThumbnailScore& score, | |
567 const SkBitmap& bitmap); | |
568 void OnMsgScreenshot(const SkBitmap& bitmap); | |
569 void OnMsgClose(); | |
570 void OnMsgRequestMove(const gfx::Rect& pos); | |
571 void OnMsgDidStartLoading(); | |
572 void OnMsgDidStopLoading(); | |
573 void OnMsgDidChangeLoadProgress(double load_progress); | |
574 void OnMsgDocumentAvailableInMainFrame(); | |
575 void OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id); | |
576 void OnExecuteCodeFinished(int request_id, bool success); | |
577 void OnMsgUpdateFavIconURL(int32 page_id, const GURL& icon_url); | |
578 void OnMsgDidDownloadFavIcon(int id, | |
579 const GURL& image_url, | |
580 bool errored, | |
581 const SkBitmap& image_data); | |
582 void OnMsgContextMenu(const ContextMenuParams& params); | |
583 void OnMsgOpenURL(const GURL& url, const GURL& referrer, | |
584 WindowOpenDisposition disposition); | |
585 void OnMsgDidContentsPreferredSizeChange(const gfx::Size& new_size); | |
586 void OnMsgDomOperationResponse(const std::string& json_string, | |
587 int automation_id); | |
588 void OnMsgWebUISend(const GURL& source_url, | |
589 const std::string& message, | |
590 const std::string& content); | |
591 void OnMsgForwardMessageToExternalHost(const std::string& message, | |
592 const std::string& origin, | |
593 const std::string& target); | |
594 void OnMsgSetTooltipText(const std::wstring& tooltip_text, | |
595 WebKit::WebTextDirection text_direction_hint); | |
596 void OnMsgSelectionChanged(const std::string& text); | |
597 void OnMsgPasteFromSelectionClipboard(); | |
598 void OnMsgRunJavaScriptMessage(const std::wstring& message, | |
599 const std::wstring& default_prompt, | |
600 const GURL& frame_url, | |
601 const int flags, | |
602 IPC::Message* reply_msg); | |
603 void OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, | |
604 const std::wstring& message, | |
605 IPC::Message* reply_msg); | |
606 void OnMsgShowModalHTMLDialog(const GURL& url, int width, int height, | |
607 const std::string& json_arguments, | |
608 IPC::Message* reply_msg); | |
609 void OnMsgStartDragging(const WebDropData& drop_data, | |
610 WebKit::WebDragOperationsMask operations_allowed, | |
611 const SkBitmap& image, | |
612 const gfx::Point& image_offset); | |
613 void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation); | |
614 void OnTakeFocus(bool reverse); | |
615 void OnAddMessageToConsole(const std::wstring& message, | |
616 int32 line_no, | |
617 const std::wstring& source_id); | |
618 void OnUpdateInspectorSetting(const std::string& key, | |
619 const std::string& value); | |
620 void OnForwardToDevToolsAgent(const IPC::Message& message); | |
621 void OnForwardToDevToolsClient(const IPC::Message& message); | |
622 void OnActivateDevToolsWindow(); | |
623 void OnCloseDevToolsWindow(); | |
624 void OnRequestDockDevToolsWindow(); | |
625 void OnRequestUndockDevToolsWindow(); | |
626 void OnDevToolsRuntimePropertyChanged(const std::string& name, | |
627 const std::string& value); | |
628 void OnMsgShouldCloseACK(bool proceed); | |
629 | |
630 void OnExtensionRequest(const ViewHostMsg_DomMessage_Params& params); | |
631 void OnExtensionPostMessage(int port_id, const std::string& message); | |
632 void OnAccessibilityNotifications( | |
633 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params); | |
634 void OnCSSInserted(); | |
635 void OnContentBlocked(ContentSettingsType type, | |
636 const std::string& resource_identifier); | |
637 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); | |
638 void OnWebDatabaseAccessed(const GURL& url, | |
639 const string16& name, | |
640 const string16& display_name, | |
641 unsigned long estimated_size, | |
642 bool blocked_by_policy); | |
643 void OnUpdateZoomLimits(int minimum_percent, | |
644 int maximum_percent, | |
645 bool remember); | |
646 void OnScriptEvalResponse(int id, const ListValue& result); | |
647 void OnCommandStateChanged(int command, | |
648 bool is_enabled, | |
649 int checked_state); | |
650 | |
651 #if defined(OS_MACOSX) | |
652 void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params); | |
653 #endif | |
654 | |
655 private: | |
656 friend class TestRenderViewHost; | |
657 | |
658 // The SiteInstance associated with this RenderViewHost. All pages drawn | |
659 // in this RenderViewHost are part of this SiteInstance. Should not change | |
660 // over time. | |
661 scoped_refptr<SiteInstance> instance_; | |
662 | |
663 // Our delegate, which wants to know about changes in the RenderView. | |
664 RenderViewHostDelegate* delegate_; | |
665 | |
666 // true if we are currently waiting for a response for drag context | |
667 // information. | |
668 bool waiting_for_drag_context_response_; | |
669 | |
670 // A bitwise OR of bindings types that have been enabled for this RenderView. | |
671 // See BindingsPolicy for details. | |
672 int enabled_bindings_; | |
673 | |
674 // The request_id for the pending cross-site request. Set to -1 if | |
675 // there is a pending request, but we have not yet started the unload | |
676 // for the current page. Set to the request_id value of the pending | |
677 // request once we have gotten the some data for the pending page | |
678 // and thus started the unload process. | |
679 int pending_request_id_; | |
680 | |
681 // Whether we should buffer outgoing Navigate messages rather than sending | |
682 // them. This will be true when a RenderViewHost is created for a cross-site | |
683 // request, until we hear back from the onbeforeunload handler of the old | |
684 // RenderViewHost. | |
685 bool navigations_suspended_; | |
686 | |
687 // We only buffer a suspended navigation message while we a pending RVH for a | |
688 // TabContents. There will only ever be one suspended navigation, because | |
689 // TabContents will destroy the pending RVH and create a new one if a second | |
690 // navigation occurs. | |
691 scoped_ptr<ViewMsg_Navigate> suspended_nav_message_; | |
692 | |
693 // If we were asked to RunModal, then this will hold the reply_msg that we | |
694 // must return to the renderer to unblock it. | |
695 IPC::Message* run_modal_reply_msg_; | |
696 | |
697 // Set to true when there is a pending ViewMsg_ShouldClose message. This | |
698 // ensures we don't spam the renderer with multiple beforeunload requests. | |
699 // When either this value or is_waiting_for_unload_ack_ is true, the value of | |
700 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a | |
701 // cross-site transition or a tab close attempt. | |
702 bool is_waiting_for_beforeunload_ack_; | |
703 | |
704 // Set to true when there is a pending ViewMsg_Close message. Also see | |
705 // is_waiting_for_beforeunload_ack_, unload_ack_is_for_cross_site_transition_. | |
706 bool is_waiting_for_unload_ack_; | |
707 | |
708 // Valid only when is_waiting_for_beforeunload_ack_ or | |
709 // is_waiting_for_unload_ack_ is true. This tells us if the unload request | |
710 // is for closing the entire tab ( = false), or only this RenderViewHost in | |
711 // the case of a cross-site transition ( = true). | |
712 bool unload_ack_is_for_cross_site_transition_; | |
713 | |
714 bool are_javascript_messages_suppressed_; | |
715 | |
716 // True if the render view can be shut down suddenly. | |
717 bool sudden_termination_allowed_; | |
718 | |
719 // The session storage namespace to be used by the associated render view. | |
720 scoped_refptr<SessionStorageNamespace> session_storage_namespace_; | |
721 | |
722 // Whether this render view will get extension api bindings. This controls | |
723 // what process type we use. | |
724 bool is_extension_process_; | |
725 | |
726 // Whether the accessibility tree should be saved, for unit testing. | |
727 bool save_accessibility_tree_for_testing_; | |
728 | |
729 // The most recently received accessibility tree - for unit testing only. | |
730 webkit_glue::WebAccessibility accessibility_tree_; | |
731 | |
732 // The termination status of the last render view that terminated. | |
733 base::TerminationStatus render_view_termination_status_; | |
734 | |
735 // The enabled/disabled states of various commands. | |
736 std::map<RenderViewCommand, CommandState> command_states_; | |
737 | |
738 DISALLOW_COPY_AND_ASSIGN(RenderViewHost); | |
739 }; | |
740 | 11 |
741 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ | 12 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ |
OLD | NEW |