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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/process/kill.h"
17 #include "content/browser/renderer_host/render_widget_host_impl.h"
18 #include "content/browser/site_instance_impl.h"
19 #include "content/common/drag_event_source_info.h"
20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/render_view_host.h"
22 #include "content/public/common/javascript_message_type.h"
23 #include "content/public/common/window_container_type.h"
24 #include "net/base/load_states.h"
25 #include "third_party/WebKit/public/web/WebAXEnums.h"
26 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
27 #include "third_party/WebKit/public/web/WebPopupType.h"
28 #include "third_party/WebKit/public/web/WebTextDirection.h"
29 #include "third_party/skia/include/core/SkColor.h"
30 #include "ui/accessibility/ax_node_data.h"
31 #include "ui/base/window_open_disposition.h"
34 class FrameMsg_Navigate
;
35 struct AccessibilityHostMsg_EventParams
;
36 struct AccessibilityHostMsg_LocationChangeParams
;
37 struct MediaPlayerAction
;
38 struct ViewHostMsg_CreateWindow_Params
;
39 struct ViewHostMsg_SelectionBounds_Params
;
40 struct ViewHostMsg_ShowPopup_Params
;
41 struct FrameMsg_Navigate_Params
;
42 struct ViewMsg_PostMessage_Params
;
54 struct SelectedFileInfo
;
59 class BrowserMediaPlayerManager
;
60 class ChildProcessSecurityPolicyImpl
;
62 class RenderWidgetHostDelegate
;
63 class SessionStorageNamespace
;
64 class SessionStorageNamespaceImpl
;
65 class TestRenderViewHost
;
67 struct FileChooserParams
;
68 struct ShowDesktopNotificationHostMsgParams
;
70 #if defined(COMPILER_MSVC)
71 // RenderViewHostImpl is the bottom of a diamond-shaped hierarchy,
72 // with RenderWidgetHost at the root. VS warns when methods from the
73 // root are overridden in only one of the base classes and not both
74 // (in this case, RenderWidgetHostImpl provides implementations of
75 // many of the methods). This is a silly warning when dealing with
76 // pure virtual methods that only have a single implementation in the
77 // hierarchy above this class, and is safe to ignore in this case.
79 #pragma warning(disable: 4250)
82 // This implements the RenderViewHost interface that is exposed to
83 // embedders of content, and adds things only visible to content.
85 // The exact API of this object needs to be more thoroughly designed. Right
86 // now it mimics what WebContentsImpl exposed, which is a fairly large API and
87 // may contain things that are not relevant to a common subset of views. See
88 // also the comment in render_view_host_delegate.h about the size and scope of
91 // Right now, the concept of page navigation (both top level and frame) exists
92 // in the WebContentsImpl still, so if you instantiate one of these elsewhere,
93 // you will not be able to traverse pages back and forward. We need to determine
94 // if we want to bring that and other functionality down into this object so it
95 // can be shared by others.
96 class CONTENT_EXPORT RenderViewHostImpl
97 : public RenderViewHost
,
98 public RenderWidgetHostImpl
{
100 // Keeps track of the state of the RenderViewHostImpl, particularly with
101 // respect to swap out.
102 enum RenderViewHostImplState
{
103 // The standard state for a RVH handling the communication with a
106 // The RVH has sent the SwapOut request to the renderer, but has not
107 // received the SwapOutACK yet. The new page has not been committed yet
109 STATE_WAITING_FOR_UNLOAD_ACK
,
110 // The RVH received the SwapOutACK from the RenderView, but the new page has
111 // not been committed yet.
112 STATE_WAITING_FOR_COMMIT
,
113 // The RVH is waiting for the CloseACK from the RenderView.
114 STATE_WAITING_FOR_CLOSE
,
115 // The RVH has not received the SwapOutACK yet, but the new page has
116 // committed in a different RVH. The number of active views of the RVH
117 // SiteInstanceImpl is not zero. Upon reception of the SwapOutACK, the RVH
118 // will be swapped out.
119 STATE_PENDING_SWAP_OUT
,
120 // The RVH has not received the SwapOutACK yet, but the new page has
121 // committed in a different RVH. The number of active views of the RVH
122 // SiteInstanceImpl is zero. Upon reception of the SwapOutACK, the RVH will
124 STATE_PENDING_SHUTDOWN
,
125 // The RVH is swapped out, and it is being used as a placeholder to allow
126 // for cross-process communication.
129 // Helper function to determine whether the RVH state should contribute to the
130 // number of active views of a SiteInstance or not.
131 static bool IsRVHStateActive(RenderViewHostImplState rvh_state
);
133 // Convenience function, just like RenderViewHost::FromID.
134 static RenderViewHostImpl
* FromID(int render_process_id
, int render_view_id
);
136 // |routing_id| could be a valid route id, or it could be MSG_ROUTING_NONE, in
137 // which case RenderWidgetHost will create a new one. |swapped_out| indicates
138 // whether the view should initially be swapped out (e.g., for an opener
139 // frame being rendered by another process). |hidden| indicates whether the
140 // view is initially hidden or visible.
142 // The |session_storage_namespace| parameter allows multiple render views and
143 // WebContentses to share the same session storage (part of the WebStorage
144 // spec) space. This is useful when restoring contentses, but most callers
145 // should pass in NULL which will cause a new SessionStorageNamespace to be
148 SiteInstance
* instance
,
149 RenderViewHostDelegate
* delegate
,
150 RenderWidgetHostDelegate
* widget_delegate
,
152 int main_frame_routing_id
,
155 virtual ~RenderViewHostImpl();
157 // RenderViewHost implementation.
158 virtual RenderFrameHost
* GetMainFrame() OVERRIDE
;
159 virtual void AllowBindings(int binding_flags
) OVERRIDE
;
160 virtual void ClearFocusedElement() OVERRIDE
;
161 virtual void ClosePage() OVERRIDE
;
162 virtual void CopyImageAt(int x
, int y
) OVERRIDE
;
163 virtual void DesktopNotificationPermissionRequestDone(
164 int callback_context
) OVERRIDE
;
165 virtual void DesktopNotificationPostDisplay(int callback_context
) OVERRIDE
;
166 virtual void DesktopNotificationPostError(
168 const base::string16
& message
) OVERRIDE
;
169 virtual void DesktopNotificationPostClose(int notification_id
,
170 bool by_user
) OVERRIDE
;
171 virtual void DesktopNotificationPostClick(int notification_id
) OVERRIDE
;
172 virtual void DirectoryEnumerationFinished(
174 const std::vector
<base::FilePath
>& files
) OVERRIDE
;
175 virtual void DisableScrollbarsForThreshold(const gfx::Size
& size
) OVERRIDE
;
176 virtual void DragSourceEndedAt(
177 int client_x
, int client_y
, int screen_x
, int screen_y
,
178 blink::WebDragOperation operation
) OVERRIDE
;
179 virtual void DragSourceMovedTo(
180 int client_x
, int client_y
, int screen_x
, int screen_y
) OVERRIDE
;
181 virtual void DragSourceSystemDragEnded() OVERRIDE
;
182 virtual void DragTargetDragEnter(
183 const DropData
& drop_data
,
184 const gfx::Point
& client_pt
,
185 const gfx::Point
& screen_pt
,
186 blink::WebDragOperationsMask operations_allowed
,
187 int key_modifiers
) OVERRIDE
;
188 virtual void DragTargetDragOver(
189 const gfx::Point
& client_pt
,
190 const gfx::Point
& screen_pt
,
191 blink::WebDragOperationsMask operations_allowed
,
192 int key_modifiers
) OVERRIDE
;
193 virtual void DragTargetDragLeave() OVERRIDE
;
194 virtual void DragTargetDrop(const gfx::Point
& client_pt
,
195 const gfx::Point
& screen_pt
,
196 int key_modifiers
) OVERRIDE
;
197 virtual void EnableAutoResize(const gfx::Size
& min_size
,
198 const gfx::Size
& max_size
) OVERRIDE
;
199 virtual void DisableAutoResize(const gfx::Size
& new_size
) OVERRIDE
;
200 virtual void EnablePreferredSizeMode() OVERRIDE
;
201 virtual void ExecuteMediaPlayerActionAtLocation(
202 const gfx::Point
& location
,
203 const blink::WebMediaPlayerAction
& action
) OVERRIDE
;
204 virtual void ExecuteJavascriptInWebFrame(
205 const base::string16
& frame_xpath
,
206 const base::string16
& jscript
) OVERRIDE
;
207 virtual void ExecuteJavascriptInWebFrameCallbackResult(
208 const base::string16
& frame_xpath
,
209 const base::string16
& jscript
,
210 const JavascriptResultCallback
& callback
) OVERRIDE
;
211 virtual void ExecutePluginActionAtLocation(
212 const gfx::Point
& location
,
213 const blink::WebPluginAction
& action
) OVERRIDE
;
214 virtual void ExitFullscreen() OVERRIDE
;
215 virtual void FirePageBeforeUnload(bool for_cross_site_transition
) OVERRIDE
;
216 virtual void FilesSelectedInChooser(
217 const std::vector
<ui::SelectedFileInfo
>& files
,
218 FileChooserParams::Mode permissions
) OVERRIDE
;
219 virtual RenderViewHostDelegate
* GetDelegate() const OVERRIDE
;
220 virtual int GetEnabledBindings() const OVERRIDE
;
221 virtual SiteInstance
* GetSiteInstance() const OVERRIDE
;
222 virtual void InsertCSS(const base::string16
& frame_xpath
,
223 const std::string
& css
) OVERRIDE
;
224 virtual bool IsRenderViewLive() const OVERRIDE
;
225 virtual void NotifyMoveOrResizeStarted() OVERRIDE
;
226 virtual void ReloadFrame() OVERRIDE
;
227 virtual void SetWebUIProperty(const std::string
& name
,
228 const std::string
& value
) OVERRIDE
;
229 virtual void Zoom(PageZoom zoom
) OVERRIDE
;
230 virtual void SyncRendererPrefs() OVERRIDE
;
231 virtual void ToggleSpeechInput() OVERRIDE
;
232 virtual WebPreferences
GetWebkitPreferences() OVERRIDE
;
233 virtual void UpdateWebkitPreferences(
234 const WebPreferences
& prefs
) OVERRIDE
;
235 virtual void NotifyTimezoneChange() OVERRIDE
;
236 virtual void GetAudioOutputControllers(
237 const GetAudioOutputControllersCallback
& callback
) const OVERRIDE
;
239 #if defined(OS_ANDROID)
240 virtual void ActivateNearestFindResult(int request_id
,
243 virtual void RequestFindMatchRects(int current_version
) OVERRIDE
;
244 virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE
;
247 void set_delegate(RenderViewHostDelegate
* d
) {
248 CHECK(d
); // http://crbug.com/82827
252 // Set up the RenderView child process. Virtual because it is overridden by
253 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used
254 // as the name of the new top-level frame.
255 // The |opener_route_id| parameter indicates which RenderView created this
256 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the
257 // RenderView is told to start issuing page IDs at |max_page_id| + 1.
258 virtual bool CreateRenderView(const base::string16
& frame_name
,
262 base::TerminationStatus
render_view_termination_status() const {
263 return render_view_termination_status_
;
266 // Returns the content specific prefs for this RenderViewHost.
267 WebPreferences
GetWebkitPrefs(const GURL
& url
);
269 // Sends the given navigation message. Use this rather than sending it
270 // yourself since this does the internal bookkeeping described below. This
271 // function takes ownership of the provided message pointer.
273 // If a cross-site request is in progress, we may be suspended while waiting
274 // for the onbeforeunload handler, so this function might buffer the message
275 // rather than sending it.
276 // TODO(nasko): Remove this method once all callers are converted to use
277 // RenderFrameHostImpl.
278 void Navigate(const FrameMsg_Navigate_Params
& message
);
280 // Load the specified URL, this is a shortcut for Navigate().
281 // TODO(nasko): Remove this method once all callers are converted to use
282 // RenderFrameHostImpl.
283 void NavigateToURL(const GURL
& url
);
285 // Returns whether navigation messages are currently suspended for this
286 // RenderViewHost. Only true during a cross-site navigation, while waiting
287 // for the onbeforeunload handler.
288 bool are_navigations_suspended() const { return navigations_suspended_
; }
290 // Suspends (or unsuspends) any navigation messages from being sent from this
291 // RenderViewHost. This is called when a pending RenderViewHost is created
292 // for a cross-site navigation, because we must suspend any navigations until
293 // we hear back from the old renderer's onbeforeunload handler. Note that it
294 // is important that only one navigation event happen after calling this
295 // method with |suspend| equal to true. If |suspend| is false and there is
296 // a suspended_nav_message_, this will send the message. This function
297 // should only be called to toggle the state; callers should check
298 // are_navigations_suspended() first. If |suspend| is false, the time that the
299 // user decided the navigation should proceed should be passed as
301 void SetNavigationsSuspended(bool suspend
,
302 const base::TimeTicks
& proceed_time
);
304 // Clears any suspended navigation state after a cross-site navigation is
305 // canceled or suspended. This is important if we later return to this
307 void CancelSuspendedNavigations();
309 // Whether the initial empty page of this view has been accessed by another
310 // page, making it unsafe to show the pending URL. Always false after the
312 bool has_accessed_initial_document() {
313 return has_accessed_initial_document_
;
316 // Whether this RenderViewHost has been swapped out to be displayed by a
317 // different process.
318 bool IsSwappedOut() const { return rvh_state_
== STATE_SWAPPED_OUT
; }
320 // The current state of this RVH.
321 RenderViewHostImplState
rvh_state() const { return rvh_state_
; }
323 // Tells the renderer that this RenderView will soon be swapped out, and thus
324 // not to create any new modal dialogs until it happens. This must be done
325 // separately so that the PageGroupLoadDeferrers of any current dialogs are no
326 // longer on the stack when we attempt to swap it out.
327 void SuppressDialogsUntilSwapOut();
329 // Tells the renderer that this RenderView is being swapped out for one in a
330 // different renderer process. It should run its unload handler and move to
331 // a blank document. The renderer should preserve the Frame object until it
332 // exits, in case we come back. The renderer can exit if it has no other
333 // active RenderViews, but not until WasSwappedOut is called (when it is no
337 // Called when either the SwapOut request has been acknowledged or has timed
339 void OnSwappedOut(bool timed_out
);
341 // Called when the RenderFrameHostManager has swapped in a new
342 // RenderFrameHost. Should |this| RVH switch to the pending shutdown state,
343 // |pending_delete_on_swap_out| will be executed upon reception of the
344 // SwapOutACK, or when the unload timer times out.
345 void WasSwappedOut(const base::Closure
& pending_delete_on_swap_out
);
347 // Set |this| as pending shutdown. |on_swap_out| will be called
348 // when the SwapOutACK is received, or when the unload timer times out.
349 void SetPendingShutdown(const base::Closure
& on_swap_out
);
351 // Close the page ignoring whether it has unload events registers.
352 // This is called after the beforeunload and unload events have fired
353 // and the user has agreed to continue with closing the page.
354 void ClosePageIgnoringUnloadEvents();
356 // Returns whether this RenderViewHost has an outstanding cross-site request.
357 // Cleared when we hear the response and start to swap out the old
358 // RenderViewHost, or if we hear a commit here without a network request.
359 bool HasPendingCrossSiteRequest();
361 // Sets whether this RenderViewHost has an outstanding cross-site request,
362 // for which another renderer will need to run an onunload event handler.
363 // This is called before the first navigation event for this RenderViewHost,
364 // and cleared when we hear the response or commit.
365 void SetHasPendingCrossSiteRequest(bool has_pending_request
);
367 // Notifies the RenderView that the JavaScript message that was shown was
368 // closed by the user.
369 void JavaScriptDialogClosed(IPC::Message
* reply_msg
,
371 const base::string16
& user_input
);
373 // Tells the renderer view to focus the first (last if reverse is true) node.
374 void SetInitialFocus(bool reverse
);
376 // Get html data by serializing all frames of current page with lists
377 // which contain all resource links that have local copy.
378 // The parameter links contain original URLs of all saved links.
379 // The parameter local_paths contain corresponding local file paths of
380 // all saved links, which matched with vector:links one by one.
381 // The parameter local_directory_name is relative path of directory which
382 // contain all saved auxiliary files included all sub frames and resouces.
383 void GetSerializedHtmlDataForCurrentPageWithLocalLinks(
384 const std::vector
<GURL
>& links
,
385 const std::vector
<base::FilePath
>& local_paths
,
386 const base::FilePath
& local_directory_name
);
388 // Notifies the RenderViewHost that its load state changed.
389 void LoadStateChanged(const GURL
& url
,
390 const net::LoadStateWithParam
& load_state
,
391 uint64 upload_position
,
394 bool SuddenTerminationAllowed() const;
395 void set_sudden_termination_allowed(bool enabled
) {
396 sudden_termination_allowed_
= enabled
;
399 // RenderWidgetHost public overrides.
400 virtual void Init() OVERRIDE
;
401 virtual bool IsRenderView() const OVERRIDE
;
402 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
403 virtual void GotFocus() OVERRIDE
;
404 virtual void LostCapture() OVERRIDE
;
405 virtual void LostMouseLock() OVERRIDE
;
406 virtual void ForwardMouseEvent(
407 const blink::WebMouseEvent
& mouse_event
) OVERRIDE
;
408 virtual void OnPointerEventActivate() OVERRIDE
;
409 virtual void ForwardKeyboardEvent(
410 const NativeWebKeyboardEvent
& key_event
) OVERRIDE
;
411 virtual gfx::Rect
GetRootWindowResizerRect() const OVERRIDE
;
413 // Creates a new RenderView with the given route id.
414 void CreateNewWindow(
416 int main_frame_route_id
,
417 const ViewHostMsg_CreateWindow_Params
& params
,
418 SessionStorageNamespace
* session_storage_namespace
);
420 // Creates a new RenderWidget with the given route id. |popup_type| indicates
421 // if this widget is a popup and what kind of popup it is (select, autofill).
422 void CreateNewWidget(int route_id
, blink::WebPopupType popup_type
);
424 // Creates a full screen RenderWidget.
425 void CreateNewFullscreenWidget(int route_id
);
427 #if defined(OS_MACOSX)
428 // Select popup menu related methods (for external popup menus).
429 void DidSelectPopupMenuItem(int selected_index
);
430 void DidCancelPopupMenu();
433 #if defined(OS_ANDROID)
434 BrowserMediaPlayerManager
* media_player_manager() {
435 return media_player_manager_
.get();
438 void DidSelectPopupMenuItems(const std::vector
<int>& selected_indices
);
439 void DidCancelPopupMenu();
442 // User rotated the screen. Calls the "onorientationchange" Javascript hook.
443 void SendOrientationChangeEvent(int orientation
);
445 int main_frame_routing_id() const {
446 return main_frame_routing_id_
;
449 // Set the opener to null in the renderer process.
452 // Turn on accessibility testing. The given callback will be run
453 // every time an accessibility notification is received from the
454 // renderer process, and the accessibility tree it sent can be
455 // retrieved using accessibility_tree_for_testing().
456 void SetAccessibilityCallbackForTesting(
457 const base::Callback
<void(ui::AXEvent
)>& callback
);
459 // Only valid if SetAccessibilityCallbackForTesting was called and
460 // the callback was run at least once. Returns a snapshot of the
461 // accessibility tree received from the renderer as of the last time
462 // an accessibility notification was received.
463 const ui::AXTree
& ax_tree_for_testing() {
464 CHECK(ax_tree_
.get());
465 return *ax_tree_
.get();
468 // Set accessibility callbacks.
469 void SetAccessibilityLayoutCompleteCallbackForTesting(
470 const base::Closure
& callback
);
471 void SetAccessibilityLoadCompleteCallbackForTesting(
472 const base::Closure
& callback
);
473 void SetAccessibilityOtherCallbackForTesting(
474 const base::Closure
& callback
);
476 bool is_waiting_for_beforeunload_ack() {
477 return is_waiting_for_beforeunload_ack_
;
480 // Whether the RVH is waiting for the unload ack from the renderer.
481 bool IsWaitingForUnloadACK() const;
483 // Update the FrameTree to use this RenderViewHost's main frame
484 // RenderFrameHost. Called when the RenderViewHost is committed.
486 // TODO(ajwong): Remove once RenderViewHost no longer owns the main frame
488 void AttachToFrameTree();
490 // The following IPC handlers are public so RenderFrameHost can call them,
491 // while we transition the code to not use RenderViewHost.
493 // TODO(nasko): Remove those methods once we are done moving navigation
494 // into RenderFrameHost.
495 void OnDidStartProvisionalLoadForFrame(int parent_routing_id
,
499 // Increases the refcounting on this RVH. This is done by the FrameTree on
500 // creation of a RenderFrameHost.
501 void increment_ref_count() { ++frames_ref_count_
; }
503 // Decreases the refcounting on this RVH. This is done by the FrameTree on
504 // destruction of a RenderFrameHost.
505 void decrement_ref_count() { --frames_ref_count_
; }
507 // Returns the refcount on this RVH, that is the number of RenderFrameHosts
508 // currently using it.
509 int ref_count() { return frames_ref_count_
; }
511 // NOTE: Do not add functions that just send an IPC message that are called in
512 // one or two places. Have the caller send the IPC message directly (unless
513 // the caller places are in different platforms, in which case it's better
514 // to keep them consistent).
517 // RenderWidgetHost protected overrides.
518 virtual void OnUserGesture() OVERRIDE
;
519 virtual void NotifyRendererUnresponsive() OVERRIDE
;
520 virtual void NotifyRendererResponsive() OVERRIDE
;
521 virtual void OnRenderAutoResized(const gfx::Size
& size
) OVERRIDE
;
522 virtual void RequestToLockMouse(bool user_gesture
,
523 bool last_unlocked_by_target
) OVERRIDE
;
524 virtual bool IsFullscreen() const OVERRIDE
;
525 virtual void OnFocus() OVERRIDE
;
526 virtual void OnBlur() OVERRIDE
;
528 // IPC message handlers.
529 void OnShowView(int route_id
,
530 WindowOpenDisposition disposition
,
531 const gfx::Rect
& initial_pos
,
533 void OnShowWidget(int route_id
, const gfx::Rect
& initial_pos
);
534 void OnShowFullscreenWidget(int route_id
);
535 void OnRenderViewReady();
536 void OnRenderProcessGone(int status
, int error_code
);
537 void OnNavigate(const IPC::Message
& msg
);
538 void OnUpdateState(int32 page_id
, const PageState
& state
);
539 void OnUpdateTitle(int32 page_id
,
540 const base::string16
& title
,
541 blink::WebTextDirection title_direction
);
542 void OnUpdateEncoding(const std::string
& encoding
);
543 void OnUpdateTargetURL(int32 page_id
, const GURL
& url
);
545 void OnRequestMove(const gfx::Rect
& pos
);
546 void OnDidChangeLoadProgress(double load_progress
);
547 void OnDidDisownOpener();
548 void OnDocumentAvailableInMainFrame();
549 void OnDocumentOnLoadCompletedInMainFrame(int32 page_id
);
550 void OnToggleFullscreen(bool enter_fullscreen
);
551 void OnDidContentsPreferredSizeChange(const gfx::Size
& new_size
);
552 void OnDidChangeScrollOffset();
553 void OnDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar
,
554 bool has_vertical_scrollbar
);
555 void OnDidChangeScrollOffsetPinningForMainFrame(bool is_pinned_to_left
,
556 bool is_pinned_to_right
);
557 void OnDidChangeNumWheelEvents(int count
);
558 void OnSelectionChanged(const base::string16
& text
,
560 const gfx::Range
& range
);
561 void OnSelectionBoundsChanged(
562 const ViewHostMsg_SelectionBounds_Params
& params
);
563 void OnPasteFromSelectionClipboard();
564 void OnRouteCloseEvent();
565 void OnRouteMessageEvent(const ViewMsg_PostMessage_Params
& params
);
566 void OnRunJavaScriptMessage(const base::string16
& message
,
567 const base::string16
& default_prompt
,
568 const GURL
& frame_url
,
569 JavaScriptMessageType type
,
570 IPC::Message
* reply_msg
);
571 void OnRunBeforeUnloadConfirm(const GURL
& frame_url
,
572 const base::string16
& message
,
574 IPC::Message
* reply_msg
);
575 void OnStartDragging(const DropData
& drop_data
,
576 blink::WebDragOperationsMask operations_allowed
,
577 const SkBitmap
& bitmap
,
578 const gfx::Vector2d
& bitmap_offset_in_dip
,
579 const DragEventSourceInfo
& event_info
);
580 void OnUpdateDragCursor(blink::WebDragOperation drag_operation
);
581 void OnTargetDropACK();
582 void OnTakeFocus(bool reverse
);
583 void OnFocusedNodeChanged(bool is_editable_node
);
584 void OnAddMessageToConsole(int32 level
,
585 const base::string16
& message
,
587 const base::string16
& source_id
);
588 void OnUpdateInspectorSetting(const std::string
& key
,
589 const std::string
& value
);
590 void OnShouldCloseACK(
592 const base::TimeTicks
& renderer_before_unload_start_time
,
593 const base::TimeTicks
& renderer_before_unload_end_time
);
594 void OnClosePageACK();
596 void OnAccessibilityEvents(
597 const std::vector
<AccessibilityHostMsg_EventParams
>& params
);
598 void OnAccessibilityLocationChanges(
599 const std::vector
<AccessibilityHostMsg_LocationChangeParams
>& params
);
600 void OnScriptEvalResponse(int id
, const base::ListValue
& result
);
601 void OnDidZoomURL(double zoom_level
, bool remember
, const GURL
& url
);
602 void OnRequestDesktopNotificationPermission(const GURL
& origin
,
604 void OnShowDesktopNotification(
605 const ShowDesktopNotificationHostMsgParams
& params
);
606 void OnCancelDesktopNotification(int notification_id
);
607 void OnRunFileChooser(const FileChooserParams
& params
);
608 void OnDidAccessInitialDocument();
609 void OnFocusedNodeTouched(bool editable
);
611 #if defined(OS_MACOSX) || defined(OS_ANDROID)
612 void OnShowPopup(const ViewHostMsg_ShowPopup_Params
& params
);
616 // TODO(nasko): Temporarily friend RenderFrameHostImpl, so we don't duplicate
617 // utility functions and state needed in both classes, while we move frame
618 // specific code away from this class.
619 friend class RenderFrameHostImpl
;
620 friend class TestRenderViewHost
;
621 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest
, BasicRenderFrameHost
);
622 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest
, RoutingIdSane
);
624 // Updates the state of this RenderViewHost and clears any waiting state
625 // that is no longer relevant.
626 void SetState(RenderViewHostImplState rvh_state
);
628 bool CanAccessFilesOfPageState(const PageState
& state
) const;
630 // The number of RenderFrameHosts which have a reference to this RVH.
631 int frames_ref_count_
;
633 // Our delegate, which wants to know about changes in the RenderView.
634 RenderViewHostDelegate
* delegate_
;
636 // The SiteInstance associated with this RenderViewHost. All pages drawn
637 // in this RenderViewHost are part of this SiteInstance. Should not change
639 scoped_refptr
<SiteInstanceImpl
> instance_
;
641 // true if we are currently waiting for a response for drag context
643 bool waiting_for_drag_context_response_
;
645 // A bitwise OR of bindings types that have been enabled for this RenderView.
646 // See BindingsPolicy for details.
647 int enabled_bindings_
;
649 // Whether we should buffer outgoing Navigate messages rather than sending
650 // them. This will be true when a RenderViewHost is created for a cross-site
651 // request, until we hear back from the onbeforeunload handler of the old
653 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
654 bool navigations_suspended_
;
656 // We only buffer the params for a suspended navigation while we have a
657 // pending RVH for a WebContentsImpl. There will only ever be one suspended
658 // navigation, because WebContentsImpl will destroy the pending RVH and create
659 // a new one if a second navigation occurs.
660 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
661 scoped_ptr
<FrameMsg_Navigate_Params
> suspended_nav_params_
;
663 // Whether the initial empty page of this view has been accessed by another
664 // page, making it unsafe to show the pending URL. Usually false unless
665 // another window tries to modify the blank page. Always false after the
667 bool has_accessed_initial_document_
;
669 // The current state of this RVH.
670 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
671 RenderViewHostImplState rvh_state_
;
673 // Routing ID for the main frame's RenderFrameHost.
674 int main_frame_routing_id_
;
676 // Set to true when there is a pending ViewMsg_ShouldClose message. This
677 // ensures we don't spam the renderer with multiple beforeunload requests.
678 // When either this value or IsWaitingForUnloadACK is true, the value of
679 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
680 // cross-site transition or a tab close attempt.
681 // TODO(clamy): Remove this boolean and add one more state to the state
683 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
684 bool is_waiting_for_beforeunload_ack_
;
686 // Valid only when is_waiting_for_beforeunload_ack_ or
687 // IsWaitingForUnloadACK is true. This tells us if the unload request
688 // is for closing the entire tab ( = false), or only this RenderViewHost in
689 // the case of a cross-site transition ( = true).
690 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
691 bool unload_ack_is_for_cross_site_transition_
;
693 bool are_javascript_messages_suppressed_
;
695 // The mapping of pending javascript calls created by
696 // ExecuteJavascriptInWebFrameCallbackResult and their corresponding
698 std::map
<int, JavascriptResultCallback
> javascript_callbacks_
;
700 // Accessibility callback for testing.
701 base::Callback
<void(ui::AXEvent
)> accessibility_testing_callback_
;
703 // The most recently received accessibility tree - for testing only.
704 scoped_ptr
<ui::AXTree
> ax_tree_
;
706 // True if the render view can be shut down suddenly.
707 bool sudden_termination_allowed_
;
709 // The termination status of the last render view that terminated.
710 base::TerminationStatus render_view_termination_status_
;
712 // When the last ShouldClose message was sent.
713 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
714 base::TimeTicks send_should_close_start_time_
;
716 // Set to true if we requested the on screen keyboard to be displayed.
717 bool virtual_keyboard_requested_
;
719 #if defined(OS_ANDROID)
720 // Manages all the android mediaplayer objects and handling IPCs for video.
721 scoped_ptr
<BrowserMediaPlayerManager
> media_player_manager_
;
724 // Used to swap out or shutdown this RVH when the unload event is taking too
725 // long to execute, depending on the number of active views in the
727 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
728 scoped_ptr
<TimeoutMonitor
> unload_event_monitor_timeout_
;
730 // Called after receiving the SwapOutACK when the RVH is in state pending
731 // shutdown. Also called if the unload timer times out.
732 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
733 base::Closure pending_shutdown_on_swap_out_
;
735 base::WeakPtrFactory
<RenderViewHostImpl
> weak_factory_
;
737 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl
);
740 #if defined(COMPILER_MSVC)
744 } // namespace content
746 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_