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