1 // Copyright 2013 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_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h"
16 #include "base/time/time.h"
17 #include "content/browser/accessibility/browser_accessibility_manager.h"
18 #include "content/browser/site_instance_impl.h"
19 #include "content/common/accessibility_mode_enums.h"
20 #include "content/common/content_export.h"
21 #include "content/common/frame_message_enums.h"
22 #include "content/common/frame_replication_state.h"
23 #include "content/common/mojo/service_registry_impl.h"
24 #include "content/common/navigation_params.h"
25 #include "content/public/browser/render_frame_host.h"
26 #include "content/public/common/javascript_message_type.h"
27 #include "net/http/http_response_headers.h"
28 #include "third_party/WebKit/public/web/WebTextDirection.h"
29 #include "ui/accessibility/ax_node_data.h"
30 #include "ui/base/page_transition_types.h"
32 #if defined(OS_ANDROID)
33 #include "content/browser/mojo/service_registry_android.h"
37 struct AccessibilityHostMsg_EventParams
;
38 struct AccessibilityHostMsg_FindInPageResultParams
;
39 struct AccessibilityHostMsg_LocationChangeParams
;
40 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params
;
41 struct FrameHostMsg_OpenURL_Params
;
42 struct FrameMsg_TextTrackSettings_Params
;
43 #if defined(OS_MACOSX) || defined(OS_ANDROID)
44 struct FrameHostMsg_ShowPopup_Params
;
54 class CrossProcessFrameConnector
;
55 class CrossSiteTransferringRequest
;
58 class PermissionServiceContext
;
59 class RenderFrameHostDelegate
;
60 class RenderFrameProxyHost
;
61 class RenderProcessHost
;
62 class RenderViewHostImpl
;
63 class RenderWidgetHostDelegate
;
64 class RenderWidgetHostImpl
;
65 class RenderWidgetHostView
;
66 class ResourceRequestBody
;
69 struct ContextMenuParams
;
70 struct GlobalRequestID
;
72 struct ResourceResponse
;
73 struct TransitionLayerData
;
75 // Flag arguments for RenderFrameHost creation.
76 enum CreateRenderFrameFlags
{
77 // The RFH will be initially placed on the swapped out hosts list.
78 CREATE_RF_SWAPPED_OUT
= 1 << 0,
79 // The new RenderFrame is being created for a navigation of the
81 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION
= 1 << 1,
82 // The RenderFrame is initially hidden.
83 CREATE_RF_HIDDEN
= 1 << 2,
84 // The RenderFrameHost will have a new RenderWidgetHost created and
85 // attached to it. This is used when the RenderFrameHost is in a different
86 // process from its parent frame.
87 CREATE_RF_NEEDS_RENDER_WIDGET_HOST
= 1 << 3
90 class CONTENT_EXPORT RenderFrameHostImpl
91 : public RenderFrameHost
,
92 public BrowserAccessibilityDelegate
{
94 typedef base::Callback
<void(const ui::AXTreeUpdate
&)>
95 AXTreeSnapshotCallback
;
97 // Keeps track of the state of the RenderFrameHostImpl, particularly with
98 // respect to swap out.
99 enum RenderFrameHostImplState
{
100 // The standard state for a RFH handling the communication with an active
103 // The RFH has not received the SwapOutACK yet, but the new page has
104 // committed in a different RFH. Upon reception of the SwapOutACK, the RFH
105 // will either enter STATE_SWAPPED_OUT (if it is a main frame and there are
106 // other active frames in its SiteInstance) or it will be deleted.
107 STATE_PENDING_SWAP_OUT
,
108 // The RFH is swapped out and stored inside a RenderFrameProxyHost, being
109 // used as a placeholder to allow cross-process communication. Only main
110 // frames can enter this state.
113 // Helper function to determine whether the RFH state should contribute to the
114 // number of active frames of a SiteInstance or not.
115 static bool IsRFHStateActive(RenderFrameHostImplState rfh_state
);
117 // An accessibility reset is only allowed to prevent very rare corner cases
118 // or race conditions where the browser and renderer get out of sync. If
119 // this happens more than this many times, kill the renderer.
120 static const int kMaxAccessibilityResets
= 5;
122 static RenderFrameHostImpl
* FromID(int process_id
, int routing_id
);
124 ~RenderFrameHostImpl() override
;
127 int GetRoutingID() override
;
128 SiteInstanceImpl
* GetSiteInstance() override
;
129 RenderProcessHost
* GetProcess() override
;
130 RenderFrameHost
* GetParent() override
;
131 const std::string
& GetFrameName() override
;
132 bool IsCrossProcessSubframe() override
;
133 GURL
GetLastCommittedURL() override
;
134 gfx::NativeView
GetNativeView() override
;
135 void ExecuteJavaScript(const base::string16
& javascript
) override
;
136 void ExecuteJavaScript(const base::string16
& javascript
,
137 const JavaScriptResultCallback
& callback
) override
;
138 void ExecuteJavaScriptForTests(const base::string16
& javascript
) override
;
139 void ActivateFindInPageResultForAccessibility(int request_id
) override
;
140 RenderViewHost
* GetRenderViewHost() override
;
141 ServiceRegistry
* GetServiceRegistry() override
;
142 blink::WebPageVisibilityState
GetVisibilityState() override
;
143 void InsertVisualStateCallback(
144 const VisualStateCallback
& callback
) override
;
147 bool Send(IPC::Message
* msg
) override
;
150 bool OnMessageReceived(const IPC::Message
& msg
) override
;
152 // BrowserAccessibilityDelegate
153 void AccessibilitySetFocus(int acc_obj_id
) override
;
154 void AccessibilityDoDefaultAction(int acc_obj_id
) override
;
155 void AccessibilityShowMenu(const gfx::Point
& global_point
) override
;
156 void AccessibilityScrollToMakeVisible(int acc_obj_id
,
157 const gfx::Rect
& subfocus
) override
;
158 void AccessibilityScrollToPoint(int acc_obj_id
,
159 const gfx::Point
& point
) override
;
160 void AccessibilitySetTextSelection(int acc_obj_id
,
162 int end_offset
) override
;
163 void AccessibilitySetValue(int acc_obj_id
, const base::string16
& value
)
165 bool AccessibilityViewHasFocus() const override
;
166 gfx::Rect
AccessibilityGetViewBounds() const override
;
167 gfx::Point
AccessibilityOriginInScreen(
168 const gfx::Rect
& bounds
) const override
;
169 void AccessibilityHitTest(const gfx::Point
& point
) override
;
170 void AccessibilitySetAccessibilityFocus(int acc_obj_id
) override
;
171 void AccessibilityFatalError() override
;
172 gfx::AcceleratedWidget
AccessibilityGetAcceleratedWidget() override
;
173 gfx::NativeViewAccessible
AccessibilityGetNativeViewAccessible() override
;
174 BrowserAccessibilityManager
* AccessibilityGetChildFrame(
175 int accessibility_node_id
) override
;
176 void AccessibilityGetAllChildFrames(
177 std::vector
<BrowserAccessibilityManager
*>* child_frames
) override
;
178 BrowserAccessibility
* AccessibilityGetParentFrame() override
;
180 // Creates a RenderFrame in the renderer process. Only called for
181 // cross-process subframe navigations in --site-per-process.
182 bool CreateRenderFrame(int parent_routing_id
, int proxy_routing_id
);
184 // Returns whether the RenderFrame in the renderer process has been created
185 // and still has a connection. This is valid for all frames.
186 bool IsRenderFrameLive();
188 // Tracks whether the RenderFrame for this RenderFrameHost has been created in
189 // the renderer process. This is currently only used for subframes.
190 // TODO(creis): Use this for main frames as well when RVH goes away.
191 void SetRenderFrameCreated(bool created
);
193 // Called for renderer-created windows to resume requests from this frame,
194 // after they are blocked in RenderWidgetHelper::CreateNewWindow.
197 int routing_id() const { return routing_id_
; }
198 void OnCreateChildFrame(int new_routing_id
,
199 const std::string
& frame_name
,
200 SandboxFlags sandbox_flags
);
202 RenderViewHostImpl
* render_view_host() { return render_view_host_
; }
203 RenderFrameHostDelegate
* delegate() { return delegate_
; }
204 FrameTreeNode
* frame_tree_node() { return frame_tree_node_
; }
206 // Returns this RenderFrameHost's loading state. This method is only used by
207 // FrameTreeNode. The proper way to check whether a frame is loading is to
208 // call FrameTreeNode::IsLoading.
209 bool is_loading() const { return is_loading_
; }
211 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one,
212 // or else it returns nullptr.
213 // If the RenderFrameHost is the page's main frame, this returns instead a
214 // pointer to the RenderViewHost (which inherits RenderWidgetHost).
215 RenderWidgetHostImpl
* GetRenderWidgetHost();
217 // This returns the RenderWidgetHostView that can be used to control
218 // focus and visibility for this frame.
219 RenderWidgetHostView
* GetView();
221 // This function is called when this is a swapped out RenderFrameHost that
222 // lives in the same process as the parent frame. The
223 // |cross_process_frame_connector| allows the non-swapped-out
224 // RenderFrameHost for a frame to communicate with the parent process
225 // so that it may composite drawing data.
227 // Ownership is not transfered.
228 void set_cross_process_frame_connector(
229 CrossProcessFrameConnector
* cross_process_frame_connector
) {
230 cross_process_frame_connector_
= cross_process_frame_connector
;
233 void set_render_frame_proxy_host(RenderFrameProxyHost
* proxy
) {
234 render_frame_proxy_host_
= proxy
;
237 // Returns a bitwise OR of bindings types that have been enabled for this
238 // RenderFrameHostImpl's RenderView. See BindingsPolicy for details.
239 // TODO(creis): Make bindings frame-specific, to support cases like <webview>.
240 int GetEnabledBindings();
242 // Called on the pending RenderFrameHost when the network response is ready to
243 // commit. We should ensure that the old RenderFrameHost runs its unload
244 // handler and determine whether a transfer to a different RenderFrameHost is
246 void OnCrossSiteResponse(
247 const GlobalRequestID
& global_request_id
,
248 scoped_ptr
<CrossSiteTransferringRequest
> cross_site_transferring_request
,
249 const std::vector
<GURL
>& transfer_url_chain
,
250 const Referrer
& referrer
,
251 ui::PageTransition page_transition
,
252 bool should_replace_current_entry
);
254 // Called on the current RenderFrameHost when the network response is first
256 void OnDeferredAfterResponseStarted(
257 const GlobalRequestID
& global_request_id
,
258 const TransitionLayerData
& transition_data
);
260 // Tells the renderer that this RenderFrame is being swapped out for one in a
261 // different renderer process. It should run its unload handler and move to
262 // a blank document. If |proxy| is not null, it should also create a
263 // RenderFrameProxy to replace the RenderFrame and set it to |is_loading|
264 // state. The renderer should preserve the RenderFrameProxy object until it
265 // exits, in case we come back. The renderer can exit if it has no other
266 // active RenderFrames, but not until WasSwappedOut is called.
267 void SwapOut(RenderFrameProxyHost
* proxy
, bool is_loading
);
269 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the
270 // RenderFrame. Currently this only happens in cross-site navigations.
271 // PlzNavigate: this happens in every browser-initiated navigation that is not
273 bool IsWaitingForBeforeUnloadACK() const;
275 // Whether the RFH is waiting for an unload ACK from the renderer.
276 bool IsWaitingForUnloadACK() const;
278 // Called when either the SwapOut request has been acknowledged or has timed
282 // Whether this RenderFrameHost has been swapped out, such that the frame is
283 // now rendered by a RenderFrameHost in a different process.
284 bool is_swapped_out() const { return rfh_state_
== STATE_SWAPPED_OUT
; }
286 // The current state of this RFH.
287 RenderFrameHostImplState
rfh_state() const { return rfh_state_
; }
289 // Sends the given navigation message. Use this rather than sending it
290 // yourself since this does the internal bookkeeping described below. This
291 // function takes ownership of the provided message pointer.
293 // If a cross-site request is in progress, we may be suspended while waiting
294 // for the onbeforeunload handler, so this function might buffer the message
295 // rather than sending it.
296 void Navigate(const CommonNavigationParams
& common_params
,
297 const StartNavigationParams
& start_params
,
298 const RequestNavigationParams
& request_params
);
300 // Load the specified URL; this is a shortcut for Navigate().
301 void NavigateToURL(const GURL
& url
);
303 // Treat this prospective navigation as though it originated from the frame.
304 // Used, e.g., for a navigation request that originated from a RemoteFrame.
305 // |source_site_instance| is the SiteInstance of the frame that initiated the
307 // TODO(creis): Remove this method and have RenderFrameProxyHost call
308 // RequestOpenURL with its FrameTreeNode.
309 void OpenURL(const FrameHostMsg_OpenURL_Params
& params
,
310 SiteInstance
* source_site_instance
);
312 // Stop the load in progress.
315 // Returns whether navigation messages are currently suspended for this
316 // RenderFrameHost. Only true during a cross-site navigation, while waiting
317 // for the onbeforeunload handler.
318 bool are_navigations_suspended() const { return navigations_suspended_
; }
320 // Suspends (or unsuspends) any navigation messages from being sent from this
321 // RenderFrameHost. This is called when a pending RenderFrameHost is created
322 // for a cross-site navigation, because we must suspend any navigations until
323 // we hear back from the old renderer's onbeforeunload handler. Note that it
324 // is important that only one navigation event happen after calling this
325 // method with |suspend| equal to true. If |suspend| is false and there is a
326 // suspended_nav_message_, this will send the message. This function should
327 // only be called to toggle the state; callers should check
328 // are_navigations_suspended() first. If |suspend| is false, the time that the
329 // user decided the navigation should proceed should be passed as
331 void SetNavigationsSuspended(bool suspend
,
332 const base::TimeTicks
& proceed_time
);
334 // Clears any suspended navigation state after a cross-site navigation is
335 // canceled or suspended. This is important if we later return to this
337 void CancelSuspendedNavigations();
339 // Runs the beforeunload handler for this frame. |for_navigation| indicates
340 // whether this call is for the current frame during a cross-process
341 // navigation. False means we're closing the entire tab.
342 // PlzNavigate: this call happens on all browser-initiated navigations.
343 void DispatchBeforeUnload(bool for_navigation
);
345 // Set the frame's opener to null in the renderer process in response to an
346 // action in another renderer process.
349 // Deletes the current selection plus the specified number of characters
350 // before and after the selection or caret.
351 void ExtendSelectionAndDelete(size_t before
, size_t after
);
353 // Notifies the RenderFrame that the JavaScript message that was shown was
354 // closed by the user.
355 void JavaScriptDialogClosed(IPC::Message
* reply_msg
,
357 const base::string16
& user_input
,
358 bool dialog_was_suppressed
);
360 // Clears any outstanding transition request. This is called when we hear the
361 // response or commit.
362 void ClearPendingTransitionRequestData();
364 // Send a message to the renderer process to change the accessibility mode.
365 void SetAccessibilityMode(AccessibilityMode AccessibilityMode
);
367 // Request a one-time snapshot of the accessibility tree without changing
368 // the accessibility mode.
369 void RequestAXTreeSnapshot(AXTreeSnapshotCallback callback
);
371 // Turn on accessibility testing. The given callback will be run
372 // every time an accessibility notification is received from the
373 // renderer process, and the accessibility tree it sent can be
374 // retrieved using GetAXTreeForTesting().
375 void SetAccessibilityCallbackForTesting(
376 const base::Callback
<void(ui::AXEvent
, int)>& callback
);
378 // Send a message to the render process to change text track style settings.
379 void SetTextTrackSettings(const FrameMsg_TextTrackSettings_Params
& params
);
381 // Returns a snapshot of the accessibility tree received from the
382 // renderer as of the last time an accessibility notification was
384 const ui::AXTree
* GetAXTreeForTesting();
386 // Access the BrowserAccessibilityManager if it already exists.
387 BrowserAccessibilityManager
* browser_accessibility_manager() const {
388 return browser_accessibility_manager_
.get();
391 // If accessibility is enabled, get the BrowserAccessibilityManager for
392 // this frame, or create one if it doesn't exist yet, otherwise return
394 BrowserAccessibilityManager
* GetOrCreateBrowserAccessibilityManager();
396 void set_no_create_browser_accessibility_manager_for_testing(bool flag
) {
397 no_create_browser_accessibility_manager_for_testing_
= flag
;
401 void SetParentNativeViewAccessible(
402 gfx::NativeViewAccessible accessible_parent
);
403 gfx::NativeViewAccessible
GetParentNativeViewAccessible() const;
404 #elif defined(OS_MACOSX)
405 // Select popup menu related methods (for external popup menus).
406 void DidSelectPopupMenuItem(int selected_index
);
407 void DidCancelPopupMenu();
408 #elif defined(OS_ANDROID)
409 void DidSelectPopupMenuItems(const std::vector
<int>& selected_indices
);
410 void DidCancelPopupMenu();
413 // PlzNavigate: Indicates that a navigation is ready to commit and can be
414 // handled by this RenderFrame.
415 void CommitNavigation(ResourceResponse
* response
,
416 scoped_ptr
<StreamHandle
> body
,
417 const CommonNavigationParams
& common_params
,
418 const RequestNavigationParams
& request_params
);
421 // Indicates that a navigation failed and that this RenderFrame should display
423 void FailedNavigation(const CommonNavigationParams
& common_params
,
424 const RequestNavigationParams
& request_params
,
425 bool has_stale_copy_in_cache
,
428 // Sets up the Mojo connection between this instance and its associated render
429 // frame if it has not yet been set up.
430 void SetUpMojoIfNeeded();
432 // Tears down the browser-side state relating to the Mojo connection between
433 // this instance and its associated render frame.
434 void InvalidateMojoConnection();
436 // Returns whether the frame is focused. A frame is considered focused when it
437 // is the parent chain of the focused frame within the frame tree. In
438 // addition, its associated RenderWidgetHost has to be focused.
442 friend class RenderFrameHostFactory
;
444 // |flags| is a combination of CreateRenderFrameFlags.
445 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
446 // should be the abstraction needed here, but we need RenderViewHost to pass
447 // into WebContentsObserver::FrameDetached for now.
448 RenderFrameHostImpl(SiteInstance
* site_instance
,
449 RenderViewHostImpl
* render_view_host
,
450 RenderFrameHostDelegate
* delegate
,
451 RenderWidgetHostDelegate
* rwh_delegate
,
452 FrameTree
* frame_tree
,
453 FrameTreeNode
* frame_tree_node
,
458 friend class TestRenderFrameHost
;
459 friend class TestRenderViewHost
;
461 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest
, CrashSubframe
);
463 // IPC Message handlers.
464 void OnAddMessageToConsole(int32 level
,
465 const base::string16
& message
,
467 const base::string16
& source_id
);
469 void OnFrameFocused();
470 void OnOpenURL(const FrameHostMsg_OpenURL_Params
& params
);
471 void OnDocumentOnLoadCompleted(
472 FrameMsg_UILoadMetricsReportType::Value report_type
,
473 base::TimeTicks ui_timestamp
);
474 void OnDidStartProvisionalLoadForFrame(const GURL
& url
,
475 bool is_transition_navigation
);
476 void OnDidFailProvisionalLoadWithError(
477 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
);
478 void OnDidFailLoadWithError(
481 const base::string16
& error_description
);
482 void OnDidCommitProvisionalLoad(const IPC::Message
& msg
);
483 void OnDidDropNavigation();
484 void OnBeforeUnloadACK(
486 const base::TimeTicks
& renderer_before_unload_start_time
,
487 const base::TimeTicks
& renderer_before_unload_end_time
);
489 void OnRenderProcessGone(int status
, int error_code
);
490 void OnContextMenu(const ContextMenuParams
& params
);
491 void OnJavaScriptExecuteResponse(int id
, const base::ListValue
& result
);
492 void OnVisualStateResponse(uint64 id
);
493 void OnRunJavaScriptMessage(const base::string16
& message
,
494 const base::string16
& default_prompt
,
495 const GURL
& frame_url
,
496 JavaScriptMessageType type
,
497 IPC::Message
* reply_msg
);
498 void OnRunBeforeUnloadConfirm(const GURL
& frame_url
,
499 const base::string16
& message
,
501 IPC::Message
* reply_msg
);
502 void OnTextSurroundingSelectionResponse(const base::string16
& content
,
505 void OnDidAccessInitialDocument();
506 void OnDidDisownOpener();
507 void OnDidChangeName(const std::string
& name
);
508 void OnDidAssignPageId(int32 page_id
);
509 void OnDidChangeSandboxFlags(int32 frame_routing_id
, SandboxFlags flags
);
510 void OnUpdateTitle(const base::string16
& title
,
511 blink::WebTextDirection title_direction
);
512 void OnUpdateEncoding(const std::string
& encoding
);
513 void OnBeginNavigation(const CommonNavigationParams
& common_params
,
514 const BeginNavigationParams
& begin_params
,
515 scoped_refptr
<ResourceRequestBody
> body
);
516 void OnDispatchLoad();
517 void OnAccessibilityEvents(
518 const std::vector
<AccessibilityHostMsg_EventParams
>& params
,
520 void OnAccessibilityLocationChanges(
521 const std::vector
<AccessibilityHostMsg_LocationChangeParams
>& params
);
522 void OnAccessibilityFindInPageResult(
523 const AccessibilityHostMsg_FindInPageResultParams
& params
);
524 void OnAccessibilitySnapshotResponse(int callback_id
,
525 const ui::AXTreeUpdate
& snapshot
);
526 void OnToggleFullscreen(bool enter_fullscreen
);
527 void OnDidStartLoading(bool to_different_document
);
528 void OnDidStopLoading();
529 void OnDidChangeLoadProgress(double load_progress
);
531 #if defined(OS_MACOSX) || defined(OS_ANDROID)
532 void OnShowPopup(const FrameHostMsg_ShowPopup_Params
& params
);
536 // Registers Mojo services that this frame host makes available.
537 void RegisterMojoServices();
539 // Updates the state of this RenderFrameHost and clears any waiting state
540 // that is no longer relevant.
541 void SetState(RenderFrameHostImplState rfh_state
);
543 // Returns whether the given URL is allowed to commit in the current process.
544 // This is a more conservative check than RenderProcessHost::FilterURL, since
545 // it will be used to kill processes that commit unauthorized URLs.
546 bool CanCommitURL(const GURL
& url
);
548 // Update the the singleton FrameAccessibility instance with a map
549 // from accessibility node id to the frame routing id of a cross-process
551 void UpdateCrossProcessIframeAccessibility(
552 const std::map
<int32
, int>& node_to_frame_routing_id_map
);
554 // Update the the singleton FrameAccessibility instance with a map
555 // from accessibility node id to the browser plugin instance id of a
556 // guest WebContents.
557 void UpdateGuestFrameAccessibility(
558 const std::map
<int32
, int>& node_to_browser_plugin_instance_id_map
);
560 // Asserts that the given RenderFrameHostImpl is part of the same browser
561 // context (and crashes if not), then returns whether the given frame is
562 // part of the same site instance.
563 bool IsSameSiteInstance(RenderFrameHostImpl
* other_render_frame_host
);
565 // Informs the content client that geolocation permissions were used.
566 void DidUseGeolocationPermission();
568 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
569 // refcount that calls Shutdown when it reaches zero. This allows each
570 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
571 // we have a RenderViewHost for each RenderFrameHost.
572 // TODO(creis): RenderViewHost will eventually go away and be replaced with
573 // some form of page context.
574 RenderViewHostImpl
* render_view_host_
;
576 RenderFrameHostDelegate
* delegate_
;
578 // The SiteInstance associated with this RenderFrameHost. All content drawn
579 // in this RenderFrameHost is part of this SiteInstance. Cannot change over
581 scoped_refptr
<SiteInstanceImpl
> site_instance_
;
583 // The renderer process this RenderFrameHost is associated with. It is
584 // equivalent to the result of site_instance_->GetProcess(), but that
585 // method has the side effect of creating the process if it doesn't exist.
586 // Cache a pointer to avoid unnecessary process creation.
587 RenderProcessHost
* process_
;
589 // |cross_process_frame_connector_| passes messages from an out-of-process
590 // child frame to the parent process for compositing.
592 // This is only non-NULL when this is the swapped out RenderFrameHost in
593 // the same site instance as this frame's parent.
595 // See the class comment above CrossProcessFrameConnector for more
598 // This will move to RenderFrameProxyHost when that class is created.
599 CrossProcessFrameConnector
* cross_process_frame_connector_
;
601 // The proxy created for this RenderFrameHost. It is used to send and receive
602 // IPC messages while in swapped out state.
603 // TODO(nasko): This can be removed once we don't have a swapped out state on
604 // RenderFrameHosts. See https://crbug.com/357747.
605 RenderFrameProxyHost
* render_frame_proxy_host_
;
607 // Reference to the whole frame tree that this RenderFrameHost belongs to.
608 // Allows this RenderFrameHost to add and remove nodes in response to
609 // messages from the renderer requesting DOM manipulation.
610 FrameTree
* frame_tree_
;
612 // The FrameTreeNode which this RenderFrameHostImpl is hosted in.
613 FrameTreeNode
* frame_tree_node_
;
615 // The mapping of pending JavaScript calls created by
616 // ExecuteJavaScript and their corresponding callbacks.
617 std::map
<int, JavaScriptResultCallback
> javascript_callbacks_
;
618 std::map
<uint64
, VisualStateCallback
> visual_state_callbacks_
;
620 // RenderFrameHosts that need management of the rendering and input events
621 // for their frame subtrees require RenderWidgetHosts. This typically
622 // means frames that are rendered in different processes from their parent
624 // TODO(kenrb): Later this will also be used on the top-level frame, when
625 // RenderFrameHost owns its RenderViewHost.
626 scoped_ptr
<RenderWidgetHostImpl
> render_widget_host_
;
630 // The current state of this RenderFrameHost.
631 RenderFrameHostImplState rfh_state_
;
633 // Tracks whether the RenderFrame for this RenderFrameHost has been created in
634 // the renderer process. Currently only used for subframes.
635 // TODO(creis): Use this for main frames as well when RVH goes away.
636 bool render_frame_created_
;
638 // Whether we should buffer outgoing Navigate messages rather than sending
639 // them. This will be true when a RenderFrameHost is created for a cross-site
640 // request, until we hear back from the onbeforeunload handler of the old
642 bool navigations_suspended_
;
644 // Holds the parameters for a suspended navigation. This can only happen while
645 // this RFH is the pending RenderFrameHost of a RenderFrameHostManager. There
646 // will only ever be one suspended navigation, because RenderFrameHostManager
647 // will destroy the pending RenderFrameHost and create a new one if a second
648 // navigation occurs.
649 // PlzNavigate: unused as navigations are never suspended.
650 scoped_ptr
<NavigationParams
> suspended_nav_params_
;
652 // When the last BeforeUnload message was sent.
653 base::TimeTicks send_before_unload_start_time_
;
655 // Set to true when there is a pending FrameMsg_ShouldClose message. This
656 // ensures we don't spam the renderer with multiple beforeunload requests.
657 // When either this value or IsWaitingForUnloadACK is true, the value of
658 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
659 // cross-site transition or a tab close attempt.
660 // TODO(clamy): Remove this boolean and add one more state to the state
662 bool is_waiting_for_beforeunload_ack_
;
664 // Valid only when is_waiting_for_beforeunload_ack_ or
665 // IsWaitingForUnloadACK is true. This tells us if the unload request
666 // is for closing the entire tab ( = false), or only this RenderFrameHost in
667 // the case of a navigation ( = true). Currently only cross-site navigations
668 // require a beforeUnload/unload ACK.
669 // PlzNavigate: all navigations require a beforeUnload ACK.
670 bool unload_ack_is_for_navigation_
;
672 // Indicates whether this RenderFrameHost is in the process of loading a
677 // Used to track whether a commit is expected in this frame. Only used in
679 bool pending_commit_
;
681 // Used to swap out or shut down this RFH when the unload event is taking too
682 // long to execute, depending on the number of active frames in the
684 scoped_ptr
<TimeoutMonitor
> swapout_event_monitor_timeout_
;
686 scoped_ptr
<ServiceRegistryImpl
> service_registry_
;
688 #if defined(OS_ANDROID)
689 scoped_ptr
<ServiceRegistryAndroid
> service_registry_android_
;
692 // The object managing the accessibility tree for this frame.
693 scoped_ptr
<BrowserAccessibilityManager
> browser_accessibility_manager_
;
695 // This is nonzero if we sent an accessibility reset to the renderer and
696 // we're waiting for an IPC containing this reset token (sequentially
697 // assigned) and a complete replacement accessibility tree.
698 int accessibility_reset_token_
;
700 // A count of the number of times we needed to reset accessibility, so
701 // we don't keep trying to reset forever.
702 int accessibility_reset_count_
;
704 // The mapping from callback id to corresponding callback for pending
705 // accessibility tree snapshot calls created by RequestAXTreeSnapshot.
706 std::map
<int, AXTreeSnapshotCallback
> ax_tree_snapshot_callbacks_
;
708 // Callback when an event is received, for testing.
709 base::Callback
<void(ui::AXEvent
, int)> accessibility_testing_callback_
;
710 // The most recently received accessibility tree - for testing only.
711 scoped_ptr
<ui::AXTree
> ax_tree_for_testing_
;
712 // Flag to not create a BrowserAccessibilityManager, for testing. If one
713 // already exists it will still be used.
714 bool no_create_browser_accessibility_manager_for_testing_
;
716 // PlzNavigate: Owns the stream used in navigations to store the body of the
717 // response once it has started.
718 scoped_ptr
<StreamHandle
> stream_handle_
;
720 // Context shared for each PermissionService instance created for this RFH.
721 scoped_ptr
<PermissionServiceContext
> permission_service_context_
;
723 // NOTE: This must be the last member.
724 base::WeakPtrFactory
<RenderFrameHostImpl
> weak_ptr_factory_
;
726 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl
);
729 } // namespace content
731 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_