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/public/browser/render_frame_host.h"
25 #include "content/public/common/javascript_message_type.h"
26 #include "net/http/http_response_headers.h"
27 #include "third_party/WebKit/public/web/WebTextDirection.h"
28 #include "ui/accessibility/ax_node_data.h"
29 #include "ui/base/page_transition_types.h"
31 #if defined(OS_ANDROID)
32 #include "content/browser/mojo/service_registry_android.h"
36 struct AccessibilityHostMsg_EventParams
;
37 struct AccessibilityHostMsg_FindInPageResultParams
;
38 struct AccessibilityHostMsg_LocationChangeParams
;
39 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params
;
40 struct FrameHostMsg_OpenURL_Params
;
41 struct FrameHostMsg_BeginNavigation_Params
;
42 struct FrameMsg_Navigate_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 BeginNavigationParams
;
70 struct CommitNavigationParams
;
71 struct CommonNavigationParams
;
72 struct ContextMenuParams
;
73 struct GlobalRequestID
;
75 struct ResourceResponse
;
76 struct TransitionLayerData
;
78 // Flag arguments for RenderFrameHost creation.
79 enum CreateRenderFrameFlags
{
80 // The RFH will be initially placed on the swapped out hosts list.
81 CREATE_RF_SWAPPED_OUT
= 1 << 0,
82 // The new RenderFrame is being created for a navigation of the
84 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION
= 1 << 1,
85 // The RenderFrame is initially hidden.
86 CREATE_RF_HIDDEN
= 1 << 2,
87 // The RenderFrameHost will have a new RenderWidgetHost created and
88 // attached to it. This is used when the RenderFrameHost is in a different
89 // process from its parent frame.
90 CREATE_RF_NEEDS_RENDER_WIDGET_HOST
= 1 << 3
93 class CONTENT_EXPORT RenderFrameHostImpl
94 : public RenderFrameHost
,
95 public BrowserAccessibilityDelegate
{
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 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one,
207 // or else it returns nullptr.
208 // If the RenderFrameHost is the page's main frame, this returns instead a
209 // pointer to the RenderViewHost (which inherits RenderWidgetHost).
210 RenderWidgetHostImpl
* GetRenderWidgetHost();
212 // This returns the RenderWidgetHostView that can be used to control
213 // focus and visibility for this frame.
214 RenderWidgetHostView
* GetView();
216 // This function is called when this is a swapped out RenderFrameHost that
217 // lives in the same process as the parent frame. The
218 // |cross_process_frame_connector| allows the non-swapped-out
219 // RenderFrameHost for a frame to communicate with the parent process
220 // so that it may composite drawing data.
222 // Ownership is not transfered.
223 void set_cross_process_frame_connector(
224 CrossProcessFrameConnector
* cross_process_frame_connector
) {
225 cross_process_frame_connector_
= cross_process_frame_connector
;
228 void set_render_frame_proxy_host(RenderFrameProxyHost
* proxy
) {
229 render_frame_proxy_host_
= proxy
;
232 // Returns a bitwise OR of bindings types that have been enabled for this
233 // RenderFrameHostImpl's RenderView. See BindingsPolicy for details.
234 // TODO(creis): Make bindings frame-specific, to support cases like <webview>.
235 int GetEnabledBindings();
237 // Called on the pending RenderFrameHost when the network response is ready to
238 // commit. We should ensure that the old RenderFrameHost runs its unload
239 // handler and determine whether a transfer to a different RenderFrameHost is
241 void OnCrossSiteResponse(
242 const GlobalRequestID
& global_request_id
,
243 scoped_ptr
<CrossSiteTransferringRequest
> cross_site_transferring_request
,
244 const std::vector
<GURL
>& transfer_url_chain
,
245 const Referrer
& referrer
,
246 ui::PageTransition page_transition
,
247 bool should_replace_current_entry
);
249 // Called on the current RenderFrameHost when the network response is first
251 void OnDeferredAfterResponseStarted(
252 const GlobalRequestID
& global_request_id
,
253 const TransitionLayerData
& transition_data
);
255 // Tells the renderer that this RenderFrame is being swapped out for one in a
256 // different renderer process. It should run its unload handler and move to
257 // a blank document. If |proxy| is not null, it should also create a
258 // RenderFrameProxy to replace the RenderFrame and set it to |is_loading|
259 // state. The renderer should preserve the RenderFrameProxy object until it
260 // exits, in case we come back. The renderer can exit if it has no other
261 // active RenderFrames, but not until WasSwappedOut is called.
262 void SwapOut(RenderFrameProxyHost
* proxy
, bool is_loading
);
264 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the
265 // RenderFrame. Currently this only happens in cross-site navigations.
266 // PlzNavigate: this happens in every browser-initiated navigation that is not
268 bool IsWaitingForBeforeUnloadACK() const;
270 // Whether the RFH is waiting for an unload ACK from the renderer.
271 bool IsWaitingForUnloadACK() const;
273 // Whether sudden termination is allowed for this frame. This is true if there
274 // are no BeforeUnload handlers or no Unload handlers registered for the
275 // frame, or it was overriden by the browser to be always true.
276 bool SuddenTerminationAllowed() const;
278 // Called by the browser to override (or not) the sudden termination status of
279 // the frame. When overriden, sudden termination is always allowed, even if
280 // it would otherwise be prevented.
281 void set_override_sudden_termination_status(bool enabled
) {
282 override_sudden_termination_status_
= enabled
;
285 // Called when either the SwapOut request has been acknowledged or has timed
289 // Whether this RenderFrameHost has been swapped out, such that the frame is
290 // now rendered by a RenderFrameHost in a different process.
291 bool is_swapped_out() const { return rfh_state_
== STATE_SWAPPED_OUT
; }
293 // The current state of this RFH.
294 RenderFrameHostImplState
rfh_state() const { return rfh_state_
; }
296 // Sends the given navigation message. Use this rather than sending it
297 // yourself since this does the internal bookkeeping described below. This
298 // function takes ownership of the provided message pointer.
300 // If a cross-site request is in progress, we may be suspended while waiting
301 // for the onbeforeunload handler, so this function might buffer the message
302 // rather than sending it.
303 void Navigate(const FrameMsg_Navigate_Params
& params
);
305 // Load the specified URL; this is a shortcut for Navigate().
306 void NavigateToURL(const GURL
& url
);
308 // Treat this prospective navigation as though it originated from the frame.
309 // Used, e.g., for a navigation request that originated from a RemoteFrame.
310 // |source_site_instance| is the SiteInstance of the frame that initiated the
312 // TODO(creis): Remove this method and have RenderFrameProxyHost call
313 // RequestOpenURL with its FrameTreeNode.
314 void OpenURL(const FrameHostMsg_OpenURL_Params
& params
,
315 SiteInstance
* source_site_instance
);
317 // Stop the load in progress.
320 // Returns whether navigation messages are currently suspended for this
321 // RenderFrameHost. Only true during a cross-site navigation, while waiting
322 // for the onbeforeunload handler.
323 bool are_navigations_suspended() const { return navigations_suspended_
; }
325 // Suspends (or unsuspends) any navigation messages from being sent from this
326 // RenderFrameHost. This is called when a pending RenderFrameHost is created
327 // for a cross-site navigation, because we must suspend any navigations until
328 // we hear back from the old renderer's onbeforeunload handler. Note that it
329 // is important that only one navigation event happen after calling this
330 // method with |suspend| equal to true. If |suspend| is false and there is a
331 // suspended_nav_message_, this will send the message. This function should
332 // only be called to toggle the state; callers should check
333 // are_navigations_suspended() first. If |suspend| is false, the time that the
334 // user decided the navigation should proceed should be passed as
336 void SetNavigationsSuspended(bool suspend
,
337 const base::TimeTicks
& proceed_time
);
339 // Clears any suspended navigation state after a cross-site navigation is
340 // canceled or suspended. This is important if we later return to this
342 void CancelSuspendedNavigations();
344 // Runs the beforeunload handler for this frame. |for_navigation| indicates
345 // whether this call is for the current frame during a cross-process
346 // navigation. False means we're closing the entire tab.
347 // PlzNavigate: this call happens on all browser-initiated navigations.
348 void DispatchBeforeUnload(bool for_navigation
);
350 // Set the frame's opener to null in the renderer process in response to an
351 // action in another renderer process.
354 // Deletes the current selection plus the specified number of characters
355 // before and after the selection or caret.
356 void ExtendSelectionAndDelete(size_t before
, size_t after
);
358 // Notifies the RenderFrame that the JavaScript message that was shown was
359 // closed by the user.
360 void JavaScriptDialogClosed(IPC::Message
* reply_msg
,
362 const base::string16
& user_input
,
363 bool dialog_was_suppressed
);
365 // Clears any outstanding transition request. This is called when we hear the
366 // response or commit.
367 void ClearPendingTransitionRequestData();
369 // Send a message to the renderer process to change the accessibility mode.
370 void SetAccessibilityMode(AccessibilityMode AccessibilityMode
);
372 // Turn on accessibility testing. The given callback will be run
373 // every time an accessibility notification is received from the
374 // renderer process, and the accessibility tree it sent can be
375 // retrieved using GetAXTreeForTesting().
376 void SetAccessibilityCallbackForTesting(
377 const base::Callback
<void(ui::AXEvent
, int)>& callback
);
379 // Returns a snapshot of the accessibility tree received from the
380 // renderer as of the last time an accessibility notification was
382 const ui::AXTree
* GetAXTreeForTesting();
384 // Access the BrowserAccessibilityManager if it already exists.
385 BrowserAccessibilityManager
* browser_accessibility_manager() const {
386 return browser_accessibility_manager_
.get();
389 // If accessibility is enabled, get the BrowserAccessibilityManager for
390 // this frame, or create one if it doesn't exist yet, otherwise return
392 BrowserAccessibilityManager
* GetOrCreateBrowserAccessibilityManager();
394 void set_no_create_browser_accessibility_manager_for_testing(bool flag
) {
395 no_create_browser_accessibility_manager_for_testing_
= flag
;
399 void SetParentNativeViewAccessible(
400 gfx::NativeViewAccessible accessible_parent
);
401 gfx::NativeViewAccessible
GetParentNativeViewAccessible() const;
402 #elif defined(OS_MACOSX)
403 // Select popup menu related methods (for external popup menus).
404 void DidSelectPopupMenuItem(int selected_index
);
405 void DidCancelPopupMenu();
406 #elif defined(OS_ANDROID)
407 void DidSelectPopupMenuItems(const std::vector
<int>& selected_indices
);
408 void DidCancelPopupMenu();
411 // PlzNavigate: Indicates that a navigation is ready to commit and can be
412 // handled by this RenderFrame.
413 void CommitNavigation(ResourceResponse
* response
,
414 scoped_ptr
<StreamHandle
> body
,
415 const CommonNavigationParams
& common_params
,
416 const CommitNavigationParams
& commit_params
);
418 // Sets up the Mojo connection between this instance and its associated render
419 // frame if it has not yet been set up.
420 void SetUpMojoIfNeeded();
422 // Tears down the browser-side state relating to the Mojo connection between
423 // this instance and its associated render frame.
424 void InvalidateMojoConnection();
426 // Returns whether the frame is focused. A frame is considered focused when it
427 // is the parent chain of the focused frame within the frame tree. In
428 // addition, its associated RenderWidgetHost has to be focused.
432 friend class RenderFrameHostFactory
;
434 // |flags| is a combination of CreateRenderFrameFlags.
435 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
436 // should be the abstraction needed here, but we need RenderViewHost to pass
437 // into WebContentsObserver::FrameDetached for now.
438 RenderFrameHostImpl(SiteInstance
* site_instance
,
439 RenderViewHostImpl
* render_view_host
,
440 RenderFrameHostDelegate
* delegate
,
441 RenderWidgetHostDelegate
* rwh_delegate
,
442 FrameTree
* frame_tree
,
443 FrameTreeNode
* frame_tree_node
,
448 friend class TestRenderFrameHost
;
449 friend class TestRenderViewHost
;
451 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest
, CrashSubframe
);
453 // IPC Message handlers.
454 void OnAddMessageToConsole(int32 level
,
455 const base::string16
& message
,
457 const base::string16
& source_id
);
459 void OnFrameFocused();
460 void OnOpenURL(const FrameHostMsg_OpenURL_Params
& params
);
461 void OnDocumentOnLoadCompleted(
462 FrameMsg_UILoadMetricsReportType::Value report_type
,
463 base::TimeTicks ui_timestamp
);
464 void OnDidStartProvisionalLoadForFrame(const GURL
& url
,
465 bool is_transition_navigation
);
466 void OnDidFailProvisionalLoadWithError(
467 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
);
468 void OnDidFailLoadWithError(
471 const base::string16
& error_description
);
472 void OnDidCommitProvisionalLoad(const IPC::Message
& msg
);
473 void OnDidDropNavigation();
474 void OnBeforeUnloadACK(
476 const base::TimeTicks
& renderer_before_unload_start_time
,
477 const base::TimeTicks
& renderer_before_unload_end_time
);
479 void OnRenderProcessGone(int status
, int error_code
);
480 void OnContextMenu(const ContextMenuParams
& params
);
481 void OnJavaScriptExecuteResponse(int id
, const base::ListValue
& result
);
482 void OnVisualStateResponse(uint64 id
);
483 void OnRunJavaScriptMessage(const base::string16
& message
,
484 const base::string16
& default_prompt
,
485 const GURL
& frame_url
,
486 JavaScriptMessageType type
,
487 IPC::Message
* reply_msg
);
488 void OnRunBeforeUnloadConfirm(const GURL
& frame_url
,
489 const base::string16
& message
,
491 IPC::Message
* reply_msg
);
492 void OnTextSurroundingSelectionResponse(const base::string16
& content
,
495 void OnDidAccessInitialDocument();
496 void OnDidDisownOpener();
497 void OnDidAssignPageId(int32 page_id
);
498 void OnUpdateTitle(const base::string16
& title
,
499 blink::WebTextDirection title_direction
);
500 void OnUpdateEncoding(const std::string
& encoding
);
501 void OnBeginNavigation(const CommonNavigationParams
& common_params
,
502 const BeginNavigationParams
& begin_params
,
503 scoped_refptr
<ResourceRequestBody
> body
);
504 void OnAccessibilityEvents(
505 const std::vector
<AccessibilityHostMsg_EventParams
>& params
,
507 void OnAccessibilityLocationChanges(
508 const std::vector
<AccessibilityHostMsg_LocationChangeParams
>& params
);
509 void OnAccessibilityFindInPageResult(
510 const AccessibilityHostMsg_FindInPageResultParams
& params
);
511 void OnToggleFullscreen(bool enter_fullscreen
);
512 void OnBeforeUnloadHandlersPresent(bool present
);
513 void OnUnloadHandlersPresent(bool present
);
515 #if defined(OS_MACOSX) || defined(OS_ANDROID)
516 void OnShowPopup(const FrameHostMsg_ShowPopup_Params
& params
);
520 // Registers Mojo services that this frame host makes available.
521 void RegisterMojoServices();
523 // Updates the state of this RenderFrameHost and clears any waiting state
524 // that is no longer relevant.
525 void SetState(RenderFrameHostImplState rfh_state
);
527 // Returns whether the given URL is allowed to commit in the current process.
528 // This is a more conservative check than RenderProcessHost::FilterURL, since
529 // it will be used to kill processes that commit unauthorized URLs.
530 bool CanCommitURL(const GURL
& url
);
532 // Update the the singleton FrameAccessibility instance with a map
533 // from accessibility node id to the frame routing id of a cross-process
535 void UpdateCrossProcessIframeAccessibility(
536 const std::map
<int32
, int>& node_to_frame_routing_id_map
);
538 // Update the the singleton FrameAccessibility instance with a map
539 // from accessibility node id to the browser plugin instance id of a
540 // guest WebContents.
541 void UpdateGuestFrameAccessibility(
542 const std::map
<int32
, int>& node_to_browser_plugin_instance_id_map
);
544 // Asserts that the given RenderFrameHostImpl is part of the same browser
545 // context (and crashes if not), then returns whether the given frame is
546 // part of the same site instance.
547 bool IsSameSiteInstance(RenderFrameHostImpl
* other_render_frame_host
);
549 // Informs the content client that geolocation permissions were used.
550 void DidUseGeolocationPermission();
552 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
553 // refcount that calls Shutdown when it reaches zero. This allows each
554 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
555 // we have a RenderViewHost for each RenderFrameHost.
556 // TODO(creis): RenderViewHost will eventually go away and be replaced with
557 // some form of page context.
558 RenderViewHostImpl
* render_view_host_
;
560 RenderFrameHostDelegate
* delegate_
;
562 // The SiteInstance associated with this RenderFrameHost. All content drawn
563 // in this RenderFrameHost is part of this SiteInstance. Cannot change over
565 scoped_refptr
<SiteInstanceImpl
> site_instance_
;
567 // The renderer process this RenderFrameHost is associated with. It is
568 // equivalent to the result of site_instance_->GetProcess(), but that
569 // method has the side effect of creating the process if it doesn't exist.
570 // Cache a pointer to avoid unnecessary process creation.
571 RenderProcessHost
* process_
;
573 // |cross_process_frame_connector_| passes messages from an out-of-process
574 // child frame to the parent process for compositing.
576 // This is only non-NULL when this is the swapped out RenderFrameHost in
577 // the same site instance as this frame's parent.
579 // See the class comment above CrossProcessFrameConnector for more
582 // This will move to RenderFrameProxyHost when that class is created.
583 CrossProcessFrameConnector
* cross_process_frame_connector_
;
585 // The proxy created for this RenderFrameHost. It is used to send and receive
586 // IPC messages while in swapped out state.
587 // TODO(nasko): This can be removed once we don't have a swapped out state on
588 // RenderFrameHosts. See https://crbug.com/357747.
589 RenderFrameProxyHost
* render_frame_proxy_host_
;
591 // Reference to the whole frame tree that this RenderFrameHost belongs to.
592 // Allows this RenderFrameHost to add and remove nodes in response to
593 // messages from the renderer requesting DOM manipulation.
594 FrameTree
* frame_tree_
;
596 // The FrameTreeNode which this RenderFrameHostImpl is hosted in.
597 FrameTreeNode
* frame_tree_node_
;
599 // The mapping of pending JavaScript calls created by
600 // ExecuteJavaScript and their corresponding callbacks.
601 std::map
<int, JavaScriptResultCallback
> javascript_callbacks_
;
602 std::map
<uint64
, VisualStateCallback
> visual_state_callbacks_
;
604 // RenderFrameHosts that need management of the rendering and input events
605 // for their frame subtrees require RenderWidgetHosts. This typically
606 // means frames that are rendered in different processes from their parent
608 // TODO(kenrb): Later this will also be used on the top-level frame, when
609 // RenderFrameHost owns its RenderViewHost.
610 scoped_ptr
<RenderWidgetHostImpl
> render_widget_host_
;
614 // The current state of this RenderFrameHost.
615 RenderFrameHostImplState rfh_state_
;
617 // Tracks whether the RenderFrame for this RenderFrameHost has been created in
618 // the renderer process. Currently only used for subframes.
619 // TODO(creis): Use this for main frames as well when RVH goes away.
620 bool render_frame_created_
;
622 // Whether we should buffer outgoing Navigate messages rather than sending
623 // them. This will be true when a RenderFrameHost is created for a cross-site
624 // request, until we hear back from the onbeforeunload handler of the old
626 bool navigations_suspended_
;
628 // We only buffer the params for a suspended navigation while this RFH is the
629 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever
630 // be one suspended navigation, because RenderFrameHostManager will destroy
631 // the pending RenderFrameHost and create a new one if a second navigation
633 scoped_ptr
<FrameMsg_Navigate_Params
> suspended_nav_params_
;
635 // When the last BeforeUnload message was sent.
636 base::TimeTicks send_before_unload_start_time_
;
638 // Used to track whether sudden termination is allowed for this frame.
639 // has_beforeunload_handlers_ and has_unload_handlers_ are also used to avoid
640 // asking the renderer process to run BeforeUnload or Unload during
641 // navigation. The browser can set override_sudden_termination_status_ to
642 // true, in which case sudden termination will be allowed. This is used when a
643 // renderer executing BeforeUnload or Unload is unresponsive. All other values
644 // are modified based on IPCs received from the renderer.
645 bool has_beforeunload_handlers_
;
646 bool has_unload_handlers_
;
647 bool override_sudden_termination_status_
;
649 // Set to true when there is a pending FrameMsg_ShouldClose message. This
650 // ensures we don't spam the renderer with multiple beforeunload requests.
651 // When either this value or IsWaitingForUnloadACK is true, the value of
652 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
653 // cross-site transition or a tab close attempt.
654 // TODO(clamy): Remove this boolean and add one more state to the state
656 bool is_waiting_for_beforeunload_ack_
;
658 // Valid only when is_waiting_for_beforeunload_ack_ or
659 // IsWaitingForUnloadACK is true. This tells us if the unload request
660 // is for closing the entire tab ( = false), or only this RenderFrameHost in
661 // the case of a navigation ( = true). Currently only cross-site navigations
662 // require a beforeUnload/unload ACK.
663 // PlzNavigate: all navigations require a beforeUnload ACK.
664 bool unload_ack_is_for_navigation_
;
666 // Used to swap out or shut down this RFH when the unload event is taking too
667 // long to execute, depending on the number of active frames in the
669 scoped_ptr
<TimeoutMonitor
> swapout_event_monitor_timeout_
;
671 scoped_ptr
<ServiceRegistryImpl
> service_registry_
;
673 #if defined(OS_ANDROID)
674 scoped_ptr
<ServiceRegistryAndroid
> service_registry_android_
;
677 // The object managing the accessibility tree for this frame.
678 scoped_ptr
<BrowserAccessibilityManager
> browser_accessibility_manager_
;
680 // This is nonzero if we sent an accessibility reset to the renderer and
681 // we're waiting for an IPC containing this reset token (sequentially
682 // assigned) and a complete replacement accessibility tree.
683 int accessibility_reset_token_
;
685 // A count of the number of times we needed to reset accessibility, so
686 // we don't keep trying to reset forever.
687 int accessibility_reset_count_
;
689 // Callback when an event is received, for testing.
690 base::Callback
<void(ui::AXEvent
, int)> accessibility_testing_callback_
;
691 // The most recently received accessibility tree - for testing only.
692 scoped_ptr
<ui::AXTree
> ax_tree_for_testing_
;
693 // Flag to not create a BrowserAccessibilityManager, for testing. If one
694 // already exists it will still be used.
695 bool no_create_browser_accessibility_manager_for_testing_
;
697 // PlzNavigate: Owns the stream used in navigations to store the body of the
698 // response once it has started.
699 scoped_ptr
<StreamHandle
> stream_handle_
;
701 // Context shared for each PermissionService instance created for this RFH.
702 scoped_ptr
<PermissionServiceContext
> permission_service_context_
;
704 // NOTE: This must be the last member.
705 base::WeakPtrFactory
<RenderFrameHostImpl
> weak_ptr_factory_
;
707 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl
);
710 } // namespace content
712 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_