Add a FrameHostMsg_BeginNavigation IPC
[chromium-blink-merge.git] / content / browser / renderer_host / render_view_host_impl.h
blob204d31ce3d840f09dc28297a9770340208af87f1
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_
8 #include <map>
9 #include <string>
10 #include <vector>
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/window_container_type.h"
23 #include "net/base/load_states.h"
24 #include "third_party/WebKit/public/web/WebAXEnums.h"
25 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
26 #include "third_party/WebKit/public/web/WebPopupType.h"
27 #include "third_party/skia/include/core/SkColor.h"
28 #include "ui/accessibility/ax_node_data.h"
29 #include "ui/base/window_open_disposition.h"
31 class SkBitmap;
32 class FrameMsg_Navigate;
33 struct AccessibilityHostMsg_EventParams;
34 struct AccessibilityHostMsg_LocationChangeParams;
35 struct MediaPlayerAction;
36 struct ViewHostMsg_CreateWindow_Params;
37 struct ViewHostMsg_ShowPopup_Params;
38 struct FrameMsg_Navigate_Params;
39 struct ViewMsg_PostMessage_Params;
41 namespace base {
42 class ListValue;
45 namespace gfx {
46 class Range;
49 namespace ui {
50 class AXTree;
51 struct SelectedFileInfo;
54 namespace content {
56 class MediaWebContentsObserver;
57 class ChildProcessSecurityPolicyImpl;
58 class PageState;
59 class RenderWidgetHostDelegate;
60 class SessionStorageNamespace;
61 class SessionStorageNamespaceImpl;
62 class TestRenderViewHost;
63 class TimeoutMonitor;
64 struct FileChooserParams;
66 #if defined(COMPILER_MSVC)
67 // RenderViewHostImpl is the bottom of a diamond-shaped hierarchy,
68 // with RenderWidgetHost at the root. VS warns when methods from the
69 // root are overridden in only one of the base classes and not both
70 // (in this case, RenderWidgetHostImpl provides implementations of
71 // many of the methods). This is a silly warning when dealing with
72 // pure virtual methods that only have a single implementation in the
73 // hierarchy above this class, and is safe to ignore in this case.
74 #pragma warning(push)
75 #pragma warning(disable: 4250)
76 #endif
78 // This implements the RenderViewHost interface that is exposed to
79 // embedders of content, and adds things only visible to content.
81 // The exact API of this object needs to be more thoroughly designed. Right
82 // now it mimics what WebContentsImpl exposed, which is a fairly large API and
83 // may contain things that are not relevant to a common subset of views. See
84 // also the comment in render_view_host_delegate.h about the size and scope of
85 // the delegate API.
87 // Right now, the concept of page navigation (both top level and frame) exists
88 // in the WebContentsImpl still, so if you instantiate one of these elsewhere,
89 // you will not be able to traverse pages back and forward. We need to determine
90 // if we want to bring that and other functionality down into this object so it
91 // can be shared by others.
92 class CONTENT_EXPORT RenderViewHostImpl
93 : public RenderViewHost,
94 public RenderWidgetHostImpl {
95 public:
96 // Keeps track of the state of the RenderViewHostImpl, particularly with
97 // respect to swap out.
98 enum RenderViewHostImplState {
99 // The standard state for a RVH handling the communication with a
100 // RenderView.
101 STATE_DEFAULT = 0,
102 // The RVH has sent the SwapOut request to the renderer, but has not
103 // received the SwapOutACK yet. The new page has not been committed yet
104 // either.
105 STATE_WAITING_FOR_UNLOAD_ACK,
106 // The RVH received the SwapOutACK from the RenderView, but the new page has
107 // not been committed yet.
108 STATE_WAITING_FOR_COMMIT,
109 // The RVH is waiting for the CloseACK from the RenderView.
110 STATE_WAITING_FOR_CLOSE,
111 // The RVH has not received the SwapOutACK yet, but the new page has
112 // committed in a different RVH. The number of active views of the RVH
113 // SiteInstanceImpl is not zero. Upon reception of the SwapOutACK, the RVH
114 // will be swapped out.
115 STATE_PENDING_SWAP_OUT,
116 // The RVH has not received the SwapOutACK yet, but the new page has
117 // committed in a different RVH. The number of active views of the RVH
118 // SiteInstanceImpl is zero. Upon reception of the SwapOutACK, the RVH will
119 // be shutdown.
120 STATE_PENDING_SHUTDOWN,
121 // The RVH is swapped out, and it is being used as a placeholder to allow
122 // for cross-process communication.
123 STATE_SWAPPED_OUT,
125 // Helper function to determine whether the RVH state should contribute to the
126 // number of active views of a SiteInstance or not.
127 static bool IsRVHStateActive(RenderViewHostImplState rvh_state);
129 // Convenience function, just like RenderViewHost::FromID.
130 static RenderViewHostImpl* FromID(int render_process_id, int render_view_id);
132 // |routing_id| could be a valid route id, or it could be MSG_ROUTING_NONE, in
133 // which case RenderWidgetHost will create a new one. |swapped_out| indicates
134 // whether the view should initially be swapped out (e.g., for an opener
135 // frame being rendered by another process). |hidden| indicates whether the
136 // view is initially hidden or visible.
138 // The |session_storage_namespace| parameter allows multiple render views and
139 // WebContentses to share the same session storage (part of the WebStorage
140 // spec) space. This is useful when restoring contentses, but most callers
141 // should pass in NULL which will cause a new SessionStorageNamespace to be
142 // created.
143 RenderViewHostImpl(
144 SiteInstance* instance,
145 RenderViewHostDelegate* delegate,
146 RenderWidgetHostDelegate* widget_delegate,
147 int routing_id,
148 int main_frame_routing_id,
149 bool swapped_out,
150 bool hidden);
151 virtual ~RenderViewHostImpl();
153 // RenderViewHost implementation.
154 virtual RenderFrameHost* GetMainFrame() OVERRIDE;
155 virtual void AllowBindings(int binding_flags) OVERRIDE;
156 virtual void ClearFocusedElement() OVERRIDE;
157 virtual bool IsFocusedElementEditable() OVERRIDE;
158 virtual void ClosePage() OVERRIDE;
159 virtual void CopyImageAt(int x, int y) OVERRIDE;
160 virtual void SaveImageAt(int x, int y) OVERRIDE;
161 virtual void DirectoryEnumerationFinished(
162 int request_id,
163 const std::vector<base::FilePath>& files) OVERRIDE;
164 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) OVERRIDE;
165 virtual void DragSourceEndedAt(
166 int client_x, int client_y, int screen_x, int screen_y,
167 blink::WebDragOperation operation) OVERRIDE;
168 virtual void DragSourceSystemDragEnded() OVERRIDE;
169 virtual void DragTargetDragEnter(
170 const DropData& drop_data,
171 const gfx::Point& client_pt,
172 const gfx::Point& screen_pt,
173 blink::WebDragOperationsMask operations_allowed,
174 int key_modifiers) OVERRIDE;
175 virtual void DragTargetDragOver(
176 const gfx::Point& client_pt,
177 const gfx::Point& screen_pt,
178 blink::WebDragOperationsMask operations_allowed,
179 int key_modifiers) OVERRIDE;
180 virtual void DragTargetDragLeave() OVERRIDE;
181 virtual void DragTargetDrop(const gfx::Point& client_pt,
182 const gfx::Point& screen_pt,
183 int key_modifiers) OVERRIDE;
184 virtual void EnableAutoResize(const gfx::Size& min_size,
185 const gfx::Size& max_size) OVERRIDE;
186 virtual void DisableAutoResize(const gfx::Size& new_size) OVERRIDE;
187 virtual void EnablePreferredSizeMode() OVERRIDE;
188 virtual void ExecuteMediaPlayerActionAtLocation(
189 const gfx::Point& location,
190 const blink::WebMediaPlayerAction& action) OVERRIDE;
191 virtual void ExecutePluginActionAtLocation(
192 const gfx::Point& location,
193 const blink::WebPluginAction& action) OVERRIDE;
194 virtual void ExitFullscreen() OVERRIDE;
195 virtual void FilesSelectedInChooser(
196 const std::vector<ui::SelectedFileInfo>& files,
197 FileChooserParams::Mode permissions) OVERRIDE;
198 virtual RenderViewHostDelegate* GetDelegate() const OVERRIDE;
199 virtual int GetEnabledBindings() const OVERRIDE;
200 virtual SiteInstance* GetSiteInstance() const OVERRIDE;
201 virtual bool IsRenderViewLive() const OVERRIDE;
202 virtual void NotifyMoveOrResizeStarted() OVERRIDE;
203 virtual void SetWebUIProperty(const std::string& name,
204 const std::string& value) OVERRIDE;
205 virtual void Zoom(PageZoom zoom) OVERRIDE;
206 virtual void SyncRendererPrefs() OVERRIDE;
207 virtual WebPreferences GetWebkitPreferences() OVERRIDE;
208 virtual void UpdateWebkitPreferences(
209 const WebPreferences& prefs) OVERRIDE;
210 virtual void GetAudioOutputControllers(
211 const GetAudioOutputControllersCallback& callback) const OVERRIDE;
212 virtual void SelectWordAroundCaret() OVERRIDE;
214 #if defined(OS_ANDROID)
215 virtual void ActivateNearestFindResult(int request_id,
216 float x,
217 float y) OVERRIDE;
218 virtual void RequestFindMatchRects(int current_version) OVERRIDE;
219 #endif
221 void set_delegate(RenderViewHostDelegate* d) {
222 CHECK(d); // http://crbug.com/82827
223 delegate_ = d;
226 // Set up the RenderView child process. Virtual because it is overridden by
227 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used
228 // as the name of the new top-level frame.
229 // The |opener_route_id| parameter indicates which RenderView created this
230 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the
231 // RenderView is told to start issuing page IDs at |max_page_id| + 1.
232 // |window_was_created_with_opener| is true if this top-level frame was
233 // created with an opener. (The opener may have been closed since.)
234 // The |proxy_route_id| is only used when creating a RenderView in swapped out
235 // state.
236 virtual bool CreateRenderView(const base::string16& frame_name,
237 int opener_route_id,
238 int proxy_route_id,
239 int32 max_page_id,
240 bool window_was_created_with_opener);
242 base::TerminationStatus render_view_termination_status() const {
243 return render_view_termination_status_;
246 // Returns the content specific prefs for this RenderViewHost.
247 WebPreferences GetWebkitPrefs(const GURL& url);
249 // Sends the given navigation message. Use this rather than sending it
250 // yourself since this does the internal bookkeeping described below. This
251 // function takes ownership of the provided message pointer.
253 // If a cross-site request is in progress, we may be suspended while waiting
254 // for the onbeforeunload handler, so this function might buffer the message
255 // rather than sending it.
256 // TODO(nasko): Remove this method once all callers are converted to use
257 // RenderFrameHostImpl.
258 void Navigate(const FrameMsg_Navigate_Params& message);
260 // Load the specified URL, this is a shortcut for Navigate().
261 // TODO(nasko): Remove this method once all callers are converted to use
262 // RenderFrameHostImpl.
263 void NavigateToURL(const GURL& url);
265 // Returns whether navigation messages are currently suspended for this
266 // RenderViewHost. Only true during a cross-site navigation, while waiting
267 // for the onbeforeunload handler.
268 bool are_navigations_suspended() const { return navigations_suspended_; }
270 // Suspends (or unsuspends) any navigation messages from being sent from this
271 // RenderViewHost. This is called when a pending RenderViewHost is created
272 // for a cross-site navigation, because we must suspend any navigations until
273 // we hear back from the old renderer's onbeforeunload handler. Note that it
274 // is important that only one navigation event happen after calling this
275 // method with |suspend| equal to true. If |suspend| is false and there is
276 // a suspended_nav_message_, this will send the message. This function
277 // should only be called to toggle the state; callers should check
278 // are_navigations_suspended() first. If |suspend| is false, the time that the
279 // user decided the navigation should proceed should be passed as
280 // |proceed_time|.
281 void SetNavigationsSuspended(bool suspend,
282 const base::TimeTicks& proceed_time);
284 // Clears any suspended navigation state after a cross-site navigation is
285 // canceled or suspended. This is important if we later return to this
286 // RenderViewHost.
287 void CancelSuspendedNavigations();
289 // Whether this RenderViewHost has been swapped out to be displayed by a
290 // different process.
291 bool IsSwappedOut() const { return rvh_state_ == STATE_SWAPPED_OUT; }
293 // The current state of this RVH.
294 RenderViewHostImplState rvh_state() const { return rvh_state_; }
296 // Tells the renderer that this RenderView will soon be swapped out, and thus
297 // not to create any new modal dialogs until it happens. This must be done
298 // separately so that the PageGroupLoadDeferrers of any current dialogs are no
299 // longer on the stack when we attempt to swap it out.
300 void SuppressDialogsUntilSwapOut();
302 // Called when either the SwapOut request has been acknowledged or has timed
303 // out.
304 void OnSwappedOut(bool timed_out);
306 // Called when the RenderFrameHostManager has swapped in a new
307 // RenderFrameHost. Should |this| RVH switch to the pending shutdown state,
308 // |pending_delete_on_swap_out| will be executed upon reception of the
309 // SwapOutACK, or when the unload timer times out.
310 void WasSwappedOut(const base::Closure& pending_delete_on_swap_out);
312 // Set |this| as pending shutdown. |on_swap_out| will be called
313 // when the SwapOutACK is received, or when the unload timer times out.
314 void SetPendingShutdown(const base::Closure& on_swap_out);
316 // Close the page ignoring whether it has unload events registers.
317 // This is called after the beforeunload and unload events have fired
318 // and the user has agreed to continue with closing the page.
319 void ClosePageIgnoringUnloadEvents();
321 // Returns whether this RenderViewHost has an outstanding cross-site request.
322 // Cleared when we hear the response and start to swap out the old
323 // RenderViewHost, or if we hear a commit here without a network request.
324 bool HasPendingCrossSiteRequest();
326 // Sets whether this RenderViewHost has an outstanding cross-site request,
327 // for which another renderer will need to run an onunload event handler.
328 // This is called before the first navigation event for this RenderViewHost,
329 // and cleared when we hear the response or commit.
330 void SetHasPendingCrossSiteRequest(bool has_pending_request);
332 // Tells the renderer view to focus the first (last if reverse is true) node.
333 void SetInitialFocus(bool reverse);
335 // Get html data by serializing all frames of current page with lists
336 // which contain all resource links that have local copy.
337 // The parameter links contain original URLs of all saved links.
338 // The parameter local_paths contain corresponding local file paths of
339 // all saved links, which matched with vector:links one by one.
340 // The parameter local_directory_name is relative path of directory which
341 // contain all saved auxiliary files included all sub frames and resouces.
342 void GetSerializedHtmlDataForCurrentPageWithLocalLinks(
343 const std::vector<GURL>& links,
344 const std::vector<base::FilePath>& local_paths,
345 const base::FilePath& local_directory_name);
347 // Notifies the RenderViewHost that its load state changed.
348 void LoadStateChanged(const GURL& url,
349 const net::LoadStateWithParam& load_state,
350 uint64 upload_position,
351 uint64 upload_size);
353 bool SuddenTerminationAllowed() const;
354 void set_sudden_termination_allowed(bool enabled) {
355 sudden_termination_allowed_ = enabled;
358 // RenderWidgetHost public overrides.
359 virtual void Init() OVERRIDE;
360 virtual void Shutdown() OVERRIDE;
361 virtual bool IsRenderView() const OVERRIDE;
362 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
363 virtual void GotFocus() OVERRIDE;
364 virtual void LostCapture() OVERRIDE;
365 virtual void LostMouseLock() OVERRIDE;
366 virtual void ForwardMouseEvent(
367 const blink::WebMouseEvent& mouse_event) OVERRIDE;
368 virtual void OnPointerEventActivate() OVERRIDE;
369 virtual void ForwardKeyboardEvent(
370 const NativeWebKeyboardEvent& key_event) OVERRIDE;
371 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
373 // Creates a new RenderView with the given route id.
374 void CreateNewWindow(
375 int route_id,
376 int main_frame_route_id,
377 const ViewHostMsg_CreateWindow_Params& params,
378 SessionStorageNamespace* session_storage_namespace);
380 // Creates a new RenderWidget with the given route id. |popup_type| indicates
381 // if this widget is a popup and what kind of popup it is (select, autofill).
382 void CreateNewWidget(int route_id, blink::WebPopupType popup_type);
384 // Creates a full screen RenderWidget.
385 void CreateNewFullscreenWidget(int route_id);
387 #if defined(OS_MACOSX)
388 // Select popup menu related methods (for external popup menus).
389 void DidSelectPopupMenuItem(int selected_index);
390 void DidCancelPopupMenu();
391 #endif
393 #if defined(ENABLE_BROWSER_CDMS)
394 MediaWebContentsObserver* media_web_contents_observer() {
395 return media_web_contents_observer_.get();
397 #endif
399 #if defined(OS_ANDROID)
400 void DidSelectPopupMenuItems(const std::vector<int>& selected_indices);
401 void DidCancelPopupMenu();
402 #endif
404 int main_frame_routing_id() const {
405 return main_frame_routing_id_;
408 // Set the opener to null in the renderer process.
409 void DisownOpener();
411 // Turn on accessibility testing. The given callback will be run
412 // every time an accessibility notification is received from the
413 // renderer process, and the accessibility tree it sent can be
414 // retrieved using accessibility_tree_for_testing().
415 void SetAccessibilityCallbackForTesting(
416 const base::Callback<void(ui::AXEvent, int)>& callback);
418 // Only valid if SetAccessibilityCallbackForTesting was called and
419 // the callback was run at least once. Returns a snapshot of the
420 // accessibility tree received from the renderer as of the last time
421 // an accessibility notification was received.
422 const ui::AXTree& ax_tree_for_testing() {
423 CHECK(ax_tree_.get());
424 return *ax_tree_.get();
427 // Set accessibility callbacks.
428 void SetAccessibilityLayoutCompleteCallbackForTesting(
429 const base::Closure& callback);
430 void SetAccessibilityLoadCompleteCallbackForTesting(
431 const base::Closure& callback);
432 void SetAccessibilityOtherCallbackForTesting(
433 const base::Closure& callback);
435 bool is_waiting_for_beforeunload_ack() {
436 return is_waiting_for_beforeunload_ack_;
439 // Whether the RVH is waiting for the unload ack from the renderer.
440 bool IsWaitingForUnloadACK() const;
442 void OnTextSurroundingSelectionResponse(const base::string16& content,
443 size_t start_offset,
444 size_t end_offset);
446 // Update the FrameTree to use this RenderViewHost's main frame
447 // RenderFrameHost. Called when the RenderViewHost is committed.
449 // TODO(ajwong): Remove once RenderViewHost no longer owns the main frame
450 // RenderFrameHost.
451 void AttachToFrameTree();
453 // Increases the refcounting on this RVH. This is done by the FrameTree on
454 // creation of a RenderFrameHost.
455 void increment_ref_count() { ++frames_ref_count_; }
457 // Decreases the refcounting on this RVH. This is done by the FrameTree on
458 // destruction of a RenderFrameHost.
459 void decrement_ref_count() { --frames_ref_count_; }
461 // Returns the refcount on this RVH, that is the number of RenderFrameHosts
462 // currently using it.
463 int ref_count() { return frames_ref_count_; }
465 // NOTE: Do not add functions that just send an IPC message that are called in
466 // one or two places. Have the caller send the IPC message directly (unless
467 // the caller places are in different platforms, in which case it's better
468 // to keep them consistent).
470 protected:
471 // RenderWidgetHost protected overrides.
472 virtual void OnUserGesture() OVERRIDE;
473 virtual void NotifyRendererUnresponsive() OVERRIDE;
474 virtual void NotifyRendererResponsive() OVERRIDE;
475 virtual void OnRenderAutoResized(const gfx::Size& size) OVERRIDE;
476 virtual void RequestToLockMouse(bool user_gesture,
477 bool last_unlocked_by_target) OVERRIDE;
478 virtual bool IsFullscreen() const OVERRIDE;
479 virtual void OnFocus() OVERRIDE;
480 virtual void OnBlur() OVERRIDE;
482 // IPC message handlers.
483 void OnShowView(int route_id,
484 WindowOpenDisposition disposition,
485 const gfx::Rect& initial_pos,
486 bool user_gesture);
487 void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
488 void OnShowFullscreenWidget(int route_id);
489 void OnRunModal(int opener_id, IPC::Message* reply_msg);
490 void OnRenderViewReady();
491 void OnRenderProcessGone(int status, int error_code);
492 void OnUpdateState(int32 page_id, const PageState& state);
493 void OnUpdateTargetURL(int32 page_id, const GURL& url);
494 void OnClose();
495 void OnRequestMove(const gfx::Rect& pos);
496 void OnDocumentAvailableInMainFrame(bool uses_temporary_zoom_level);
497 void OnToggleFullscreen(bool enter_fullscreen);
498 void OnDidContentsPreferredSizeChange(const gfx::Size& new_size);
499 void OnDidChangeScrollOffset();
500 void OnPasteFromSelectionClipboard();
501 void OnRouteCloseEvent();
502 void OnRouteMessageEvent(const ViewMsg_PostMessage_Params& params);
503 void OnStartDragging(const DropData& drop_data,
504 blink::WebDragOperationsMask operations_allowed,
505 const SkBitmap& bitmap,
506 const gfx::Vector2d& bitmap_offset_in_dip,
507 const DragEventSourceInfo& event_info);
508 void OnUpdateDragCursor(blink::WebDragOperation drag_operation);
509 void OnTargetDropACK();
510 void OnTakeFocus(bool reverse);
511 void OnFocusedNodeChanged(bool is_editable_node);
512 void OnUpdateInspectorSetting(const std::string& key,
513 const std::string& value);
514 void OnClosePageACK();
515 void OnAccessibilityEvents(
516 const std::vector<AccessibilityHostMsg_EventParams>& params);
517 void OnAccessibilityLocationChanges(
518 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
519 void OnDidZoomURL(double zoom_level, const GURL& url);
520 void OnRunFileChooser(const FileChooserParams& params);
521 void OnFocusedNodeTouched(bool editable);
523 #if defined(OS_MACOSX) || defined(OS_ANDROID)
524 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params);
525 void OnHidePopup();
526 #endif
528 private:
529 // TODO(nasko): Temporarily friend RenderFrameHostImpl, so we don't duplicate
530 // utility functions and state needed in both classes, while we move frame
531 // specific code away from this class.
532 friend class RenderFrameHostImpl;
533 friend class TestRenderViewHost;
534 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost);
535 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane);
537 // TODO(creis): Move to a private namespace on RenderFrameHostImpl.
538 // Delay to wait on closing the WebContents for a beforeunload/unload handler
539 // to fire.
540 static const int kUnloadTimeoutMS;
542 // Updates the state of this RenderViewHost and clears any waiting state
543 // that is no longer relevant.
544 void SetState(RenderViewHostImplState rvh_state);
546 bool CanAccessFilesOfPageState(const PageState& state) const;
548 // The number of RenderFrameHosts which have a reference to this RVH.
549 int frames_ref_count_;
551 // Our delegate, which wants to know about changes in the RenderView.
552 RenderViewHostDelegate* delegate_;
554 // The SiteInstance associated with this RenderViewHost. All pages drawn
555 // in this RenderViewHost are part of this SiteInstance. Should not change
556 // over time.
557 scoped_refptr<SiteInstanceImpl> instance_;
559 // true if we are currently waiting for a response for drag context
560 // information.
561 bool waiting_for_drag_context_response_;
563 // A bitwise OR of bindings types that have been enabled for this RenderView.
564 // See BindingsPolicy for details.
565 int enabled_bindings_;
567 // Whether we should buffer outgoing Navigate messages rather than sending
568 // them. This will be true when a RenderViewHost is created for a cross-site
569 // request, until we hear back from the onbeforeunload handler of the old
570 // RenderViewHost.
571 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
572 bool navigations_suspended_;
574 // We only buffer the params for a suspended navigation while we have a
575 // pending RVH for a WebContentsImpl. There will only ever be one suspended
576 // navigation, because WebContentsImpl will destroy the pending RVH and create
577 // a new one if a second navigation occurs.
578 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
579 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_;
581 // The current state of this RVH.
582 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
583 RenderViewHostImplState rvh_state_;
585 // Routing ID for the main frame's RenderFrameHost.
586 int main_frame_routing_id_;
588 // If we were asked to RunModal, then this will hold the reply_msg that we
589 // must return to the renderer to unblock it.
590 IPC::Message* run_modal_reply_msg_;
591 // This will hold the routing id of the RenderView that opened us.
592 int run_modal_opener_id_;
594 // Set to true when there is a pending ViewMsg_ShouldClose message. This
595 // ensures we don't spam the renderer with multiple beforeunload requests.
596 // When either this value or IsWaitingForUnloadACK is true, the value of
597 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
598 // cross-site transition or a tab close attempt.
599 // TODO(clamy): Remove this boolean and add one more state to the state
600 // machine.
601 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
602 bool is_waiting_for_beforeunload_ack_;
604 // Valid only when is_waiting_for_beforeunload_ack_ or
605 // IsWaitingForUnloadACK is true. This tells us if the unload request
606 // is for closing the entire tab ( = false), or only this RenderViewHost in
607 // the case of a cross-site transition ( = true).
608 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
609 bool unload_ack_is_for_cross_site_transition_;
611 // Accessibility callback for testing.
612 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_;
614 // The most recently received accessibility tree - for testing only.
615 scoped_ptr<ui::AXTree> ax_tree_;
617 // True if the render view can be shut down suddenly.
618 bool sudden_termination_allowed_;
620 // The termination status of the last render view that terminated.
621 base::TerminationStatus render_view_termination_status_;
623 // Set to true if we requested the on screen keyboard to be displayed.
624 bool virtual_keyboard_requested_;
626 #if defined(ENABLE_BROWSER_CDMS)
627 // Manages all the media player and CDM managers and forwards IPCs to them.
628 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_;
629 #endif
631 // Used to swap out or shutdown this RVH when the unload event is taking too
632 // long to execute, depending on the number of active views in the
633 // SiteInstance.
634 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
635 scoped_ptr<TimeoutMonitor> unload_event_monitor_timeout_;
637 // Called after receiving the SwapOutACK when the RVH is in state pending
638 // shutdown. Also called if the unload timer times out.
639 // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
640 base::Closure pending_shutdown_on_swap_out_;
642 base::WeakPtrFactory<RenderViewHostImpl> weak_factory_;
644 // True if the current focused element is editable.
645 bool is_focused_element_editable_;
647 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl);
650 #if defined(COMPILER_MSVC)
651 #pragma warning(pop)
652 #endif
654 } // namespace content
656 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_