Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / frame_host / render_frame_host_impl.h
blob283be24ef7bcbd431ae8bec34dc477a1823255b4
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_
8 #include <map>
9 #include <vector>
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"
34 #endif
36 class GURL;
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;
45 #endif
47 namespace base {
48 class FilePath;
49 class ListValue;
52 namespace content {
54 class CrossProcessFrameConnector;
55 class CrossSiteTransferringRequest;
56 class FrameTree;
57 class FrameTreeNode;
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;
67 class StreamHandle;
68 class TimeoutMonitor;
69 struct ContextMenuParams;
70 struct GlobalRequestID;
71 struct Referrer;
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
80 // top-level frame.
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 {
93 public:
94 // Keeps track of the state of the RenderFrameHostImpl, particularly with
95 // respect to swap out.
96 enum RenderFrameHostImplState {
97 // The standard state for a RFH handling the communication with an active
98 // RenderFrame.
99 STATE_DEFAULT = 0,
100 // The RFH has not received the SwapOutACK yet, but the new page has
101 // committed in a different RFH. Upon reception of the SwapOutACK, the RFH
102 // will either enter STATE_SWAPPED_OUT (if it is a main frame and there are
103 // other active frames in its SiteInstance) or it will be deleted.
104 STATE_PENDING_SWAP_OUT,
105 // The RFH is swapped out and stored inside a RenderFrameProxyHost, being
106 // used as a placeholder to allow cross-process communication. Only main
107 // frames can enter this state.
108 STATE_SWAPPED_OUT,
110 // Helper function to determine whether the RFH state should contribute to the
111 // number of active frames of a SiteInstance or not.
112 static bool IsRFHStateActive(RenderFrameHostImplState rfh_state);
114 // An accessibility reset is only allowed to prevent very rare corner cases
115 // or race conditions where the browser and renderer get out of sync. If
116 // this happens more than this many times, kill the renderer.
117 static const int kMaxAccessibilityResets = 5;
119 static RenderFrameHostImpl* FromID(int process_id, int routing_id);
121 ~RenderFrameHostImpl() override;
123 // RenderFrameHost
124 int GetRoutingID() override;
125 SiteInstanceImpl* GetSiteInstance() override;
126 RenderProcessHost* GetProcess() override;
127 RenderFrameHost* GetParent() override;
128 const std::string& GetFrameName() override;
129 bool IsCrossProcessSubframe() override;
130 GURL GetLastCommittedURL() override;
131 gfx::NativeView GetNativeView() override;
132 void ExecuteJavaScript(const base::string16& javascript) override;
133 void ExecuteJavaScript(const base::string16& javascript,
134 const JavaScriptResultCallback& callback) override;
135 void ExecuteJavaScriptForTests(const base::string16& javascript) override;
136 void ActivateFindInPageResultForAccessibility(int request_id) override;
137 RenderViewHost* GetRenderViewHost() override;
138 ServiceRegistry* GetServiceRegistry() override;
139 blink::WebPageVisibilityState GetVisibilityState() override;
140 void InsertVisualStateCallback(
141 const VisualStateCallback& callback) override;
143 // IPC::Sender
144 bool Send(IPC::Message* msg) override;
146 // IPC::Listener
147 bool OnMessageReceived(const IPC::Message& msg) override;
149 // BrowserAccessibilityDelegate
150 void AccessibilitySetFocus(int acc_obj_id) override;
151 void AccessibilityDoDefaultAction(int acc_obj_id) override;
152 void AccessibilityShowMenu(const gfx::Point& global_point) override;
153 void AccessibilityScrollToMakeVisible(int acc_obj_id,
154 const gfx::Rect& subfocus) override;
155 void AccessibilityScrollToPoint(int acc_obj_id,
156 const gfx::Point& point) override;
157 void AccessibilitySetTextSelection(int acc_obj_id,
158 int start_offset,
159 int end_offset) override;
160 void AccessibilitySetValue(int acc_obj_id, const base::string16& value)
161 override;
162 bool AccessibilityViewHasFocus() const override;
163 gfx::Rect AccessibilityGetViewBounds() const override;
164 gfx::Point AccessibilityOriginInScreen(
165 const gfx::Rect& bounds) const override;
166 void AccessibilityHitTest(const gfx::Point& point) override;
167 void AccessibilitySetAccessibilityFocus(int acc_obj_id) override;
168 void AccessibilityFatalError() override;
169 gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() override;
170 gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() override;
171 BrowserAccessibilityManager* AccessibilityGetChildFrame(
172 int accessibility_node_id) override;
173 void AccessibilityGetAllChildFrames(
174 std::vector<BrowserAccessibilityManager*>* child_frames) override;
175 BrowserAccessibility* AccessibilityGetParentFrame() override;
177 // Creates a RenderFrame in the renderer process. Only called for
178 // cross-process subframe navigations in --site-per-process.
179 bool CreateRenderFrame(int parent_routing_id, int proxy_routing_id);
181 // Returns whether the RenderFrame in the renderer process has been created
182 // and still has a connection. This is valid for all frames.
183 bool IsRenderFrameLive();
185 // Tracks whether the RenderFrame for this RenderFrameHost has been created in
186 // the renderer process. This is currently only used for subframes.
187 // TODO(creis): Use this for main frames as well when RVH goes away.
188 void SetRenderFrameCreated(bool created);
190 // Called for renderer-created windows to resume requests from this frame,
191 // after they are blocked in RenderWidgetHelper::CreateNewWindow.
192 void Init();
194 int routing_id() const { return routing_id_; }
195 void OnCreateChildFrame(int new_routing_id,
196 const std::string& frame_name,
197 SandboxFlags sandbox_flags);
199 RenderViewHostImpl* render_view_host() { return render_view_host_; }
200 RenderFrameHostDelegate* delegate() { return delegate_; }
201 FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
203 // Sets this RenderFrameHost's loading state.
204 void set_is_loading(bool is_loading) {
205 is_loading_ = is_loading;
208 // Returns this RenderFrameHost's loading state. This method is only used by
209 // FrameTreeNode. The proper way to check whether a frame is loading is to
210 // call FrameTreeNode::IsLoading.
211 bool is_loading() const { return is_loading_; }
213 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one,
214 // or else it returns nullptr.
215 // If the RenderFrameHost is the page's main frame, this returns instead a
216 // pointer to the RenderViewHost (which inherits RenderWidgetHost).
217 RenderWidgetHostImpl* GetRenderWidgetHost();
219 // This returns the RenderWidgetHostView that can be used to control
220 // focus and visibility for this frame.
221 RenderWidgetHostView* GetView();
223 // This function is called when this is a swapped out RenderFrameHost that
224 // lives in the same process as the parent frame. The
225 // |cross_process_frame_connector| allows the non-swapped-out
226 // RenderFrameHost for a frame to communicate with the parent process
227 // so that it may composite drawing data.
229 // Ownership is not transfered.
230 void set_cross_process_frame_connector(
231 CrossProcessFrameConnector* cross_process_frame_connector) {
232 cross_process_frame_connector_ = cross_process_frame_connector;
235 void set_render_frame_proxy_host(RenderFrameProxyHost* proxy) {
236 render_frame_proxy_host_ = proxy;
239 // Returns a bitwise OR of bindings types that have been enabled for this
240 // RenderFrameHostImpl's RenderView. See BindingsPolicy for details.
241 // TODO(creis): Make bindings frame-specific, to support cases like <webview>.
242 int GetEnabledBindings();
244 // Called on the pending RenderFrameHost when the network response is ready to
245 // commit. We should ensure that the old RenderFrameHost runs its unload
246 // handler and determine whether a transfer to a different RenderFrameHost is
247 // needed.
248 void OnCrossSiteResponse(
249 const GlobalRequestID& global_request_id,
250 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
251 const std::vector<GURL>& transfer_url_chain,
252 const Referrer& referrer,
253 ui::PageTransition page_transition,
254 bool should_replace_current_entry);
256 // Called on the current RenderFrameHost when the network response is first
257 // receieved.
258 void OnDeferredAfterResponseStarted(
259 const GlobalRequestID& global_request_id,
260 const TransitionLayerData& transition_data);
262 // Tells the renderer that this RenderFrame is being swapped out for one in a
263 // different renderer process. It should run its unload handler and move to
264 // a blank document. If |proxy| is not null, it should also create a
265 // RenderFrameProxy to replace the RenderFrame and set it to |is_loading|
266 // state. The renderer should preserve the RenderFrameProxy object until it
267 // exits, in case we come back. The renderer can exit if it has no other
268 // active RenderFrames, but not until WasSwappedOut is called.
269 void SwapOut(RenderFrameProxyHost* proxy, bool is_loading);
271 // Whether an ongoing navigation is waiting for a BeforeUnload ACK from the
272 // RenderFrame. Currently this only happens in cross-site navigations.
273 // PlzNavigate: this happens in every browser-initiated navigation that is not
274 // same-page.
275 bool IsWaitingForBeforeUnloadACK() const;
277 // Whether the RFH is waiting for an unload ACK from the renderer.
278 bool IsWaitingForUnloadACK() const;
280 // Called when either the SwapOut request has been acknowledged or has timed
281 // out.
282 void OnSwappedOut();
284 // Whether this RenderFrameHost has been swapped out, such that the frame is
285 // now rendered by a RenderFrameHost in a different process.
286 bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; }
288 // The current state of this RFH.
289 RenderFrameHostImplState rfh_state() const { return rfh_state_; }
291 // Sends the given navigation message. Use this rather than sending it
292 // yourself since this does the internal bookkeeping described below. This
293 // function takes ownership of the provided message pointer.
295 // If a cross-site request is in progress, we may be suspended while waiting
296 // for the onbeforeunload handler, so this function might buffer the message
297 // rather than sending it.
298 void Navigate(const CommonNavigationParams& common_params,
299 const StartNavigationParams& start_params,
300 const RequestNavigationParams& request_params);
302 // Load the specified URL; this is a shortcut for Navigate().
303 void NavigateToURL(const GURL& url);
305 // Treat this prospective navigation as though it originated from the frame.
306 // Used, e.g., for a navigation request that originated from a RemoteFrame.
307 // |source_site_instance| is the SiteInstance of the frame that initiated the
308 // navigation.
309 // TODO(creis): Remove this method and have RenderFrameProxyHost call
310 // RequestOpenURL with its FrameTreeNode.
311 void OpenURL(const FrameHostMsg_OpenURL_Params& params,
312 SiteInstance* source_site_instance);
314 // Stop the load in progress.
315 void Stop();
317 // Returns whether navigation messages are currently suspended for this
318 // RenderFrameHost. Only true during a cross-site navigation, while waiting
319 // for the onbeforeunload handler.
320 bool are_navigations_suspended() const { return navigations_suspended_; }
322 // Suspends (or unsuspends) any navigation messages from being sent from this
323 // RenderFrameHost. This is called when a pending RenderFrameHost is created
324 // for a cross-site navigation, because we must suspend any navigations until
325 // we hear back from the old renderer's onbeforeunload handler. Note that it
326 // is important that only one navigation event happen after calling this
327 // method with |suspend| equal to true. If |suspend| is false and there is a
328 // suspended_nav_message_, this will send the message. This function should
329 // only be called to toggle the state; callers should check
330 // are_navigations_suspended() first. If |suspend| is false, the time that the
331 // user decided the navigation should proceed should be passed as
332 // |proceed_time|.
333 void SetNavigationsSuspended(bool suspend,
334 const base::TimeTicks& proceed_time);
336 // Clears any suspended navigation state after a cross-site navigation is
337 // canceled or suspended. This is important if we later return to this
338 // RenderFrameHost.
339 void CancelSuspendedNavigations();
341 // Runs the beforeunload handler for this frame. |for_navigation| indicates
342 // whether this call is for the current frame during a cross-process
343 // navigation. False means we're closing the entire tab.
344 // PlzNavigate: this call happens on all browser-initiated navigations.
345 void DispatchBeforeUnload(bool for_navigation);
347 // Set the frame's opener to null in the renderer process in response to an
348 // action in another renderer process.
349 void DisownOpener();
351 // Deletes the current selection plus the specified number of characters
352 // before and after the selection or caret.
353 void ExtendSelectionAndDelete(size_t before, size_t after);
355 // Notifies the RenderFrame that the JavaScript message that was shown was
356 // closed by the user.
357 void JavaScriptDialogClosed(IPC::Message* reply_msg,
358 bool success,
359 const base::string16& user_input,
360 bool dialog_was_suppressed);
362 // Clears any outstanding transition request. This is called when we hear the
363 // response or commit.
364 void ClearPendingTransitionRequestData();
366 // Send a message to the renderer process to change the accessibility mode.
367 void SetAccessibilityMode(AccessibilityMode AccessibilityMode);
369 // Turn on accessibility testing. The given callback will be run
370 // every time an accessibility notification is received from the
371 // renderer process, and the accessibility tree it sent can be
372 // retrieved using GetAXTreeForTesting().
373 void SetAccessibilityCallbackForTesting(
374 const base::Callback<void(ui::AXEvent, int)>& callback);
376 // Send a message to the render process to change text track style settings.
377 void SetTextTrackSettings(const FrameMsg_TextTrackSettings_Params& params);
379 // Returns a snapshot of the accessibility tree received from the
380 // renderer as of the last time an accessibility notification was
381 // received.
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
391 // NULL.
392 BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager();
394 void set_no_create_browser_accessibility_manager_for_testing(bool flag) {
395 no_create_browser_accessibility_manager_for_testing_ = flag;
398 #if defined(OS_WIN)
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();
409 #endif
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 RequestNavigationParams& request_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.
429 bool IsFocused();
431 protected:
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,
444 int routing_id,
445 int flags);
447 private:
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,
456 int32 line_no,
457 const base::string16& source_id);
458 void OnDetach();
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(
469 const GURL& url,
470 int error_code,
471 const base::string16& error_description);
472 void OnDidCommitProvisionalLoad(const IPC::Message& msg);
473 void OnDidDropNavigation();
474 void OnBeforeUnloadACK(
475 bool proceed,
476 const base::TimeTicks& renderer_before_unload_start_time,
477 const base::TimeTicks& renderer_before_unload_end_time);
478 void OnSwapOutACK();
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,
490 bool is_reload,
491 IPC::Message* reply_msg);
492 void OnTextSurroundingSelectionResponse(const base::string16& content,
493 size_t start_offset,
494 size_t end_offset);
495 void OnDidAccessInitialDocument();
496 void OnDidDisownOpener();
497 void OnDidChangeName(const std::string& name);
498 void OnDidAssignPageId(int32 page_id);
499 void OnDidChangeSandboxFlags(int32 frame_routing_id, SandboxFlags flags);
500 void OnUpdateTitle(const base::string16& title,
501 blink::WebTextDirection title_direction);
502 void OnUpdateEncoding(const std::string& encoding);
503 void OnBeginNavigation(const CommonNavigationParams& common_params,
504 const BeginNavigationParams& begin_params,
505 scoped_refptr<ResourceRequestBody> body);
506 void OnDispatchLoad();
507 void OnAccessibilityEvents(
508 const std::vector<AccessibilityHostMsg_EventParams>& params,
509 int reset_token);
510 void OnAccessibilityLocationChanges(
511 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
512 void OnAccessibilityFindInPageResult(
513 const AccessibilityHostMsg_FindInPageResultParams& params);
514 void OnToggleFullscreen(bool enter_fullscreen);
516 #if defined(OS_MACOSX) || defined(OS_ANDROID)
517 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params);
518 void OnHidePopup();
519 #endif
521 // Registers Mojo services that this frame host makes available.
522 void RegisterMojoServices();
524 // Updates the state of this RenderFrameHost and clears any waiting state
525 // that is no longer relevant.
526 void SetState(RenderFrameHostImplState rfh_state);
528 // Returns whether the given URL is allowed to commit in the current process.
529 // This is a more conservative check than RenderProcessHost::FilterURL, since
530 // it will be used to kill processes that commit unauthorized URLs.
531 bool CanCommitURL(const GURL& url);
533 // Update the the singleton FrameAccessibility instance with a map
534 // from accessibility node id to the frame routing id of a cross-process
535 // iframe.
536 void UpdateCrossProcessIframeAccessibility(
537 const std::map<int32, int>& node_to_frame_routing_id_map);
539 // Update the the singleton FrameAccessibility instance with a map
540 // from accessibility node id to the browser plugin instance id of a
541 // guest WebContents.
542 void UpdateGuestFrameAccessibility(
543 const std::map<int32, int>& node_to_browser_plugin_instance_id_map);
545 // Asserts that the given RenderFrameHostImpl is part of the same browser
546 // context (and crashes if not), then returns whether the given frame is
547 // part of the same site instance.
548 bool IsSameSiteInstance(RenderFrameHostImpl* other_render_frame_host);
550 // Informs the content client that geolocation permissions were used.
551 void DidUseGeolocationPermission();
553 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
554 // refcount that calls Shutdown when it reaches zero. This allows each
555 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
556 // we have a RenderViewHost for each RenderFrameHost.
557 // TODO(creis): RenderViewHost will eventually go away and be replaced with
558 // some form of page context.
559 RenderViewHostImpl* render_view_host_;
561 RenderFrameHostDelegate* delegate_;
563 // The SiteInstance associated with this RenderFrameHost. All content drawn
564 // in this RenderFrameHost is part of this SiteInstance. Cannot change over
565 // time.
566 scoped_refptr<SiteInstanceImpl> site_instance_;
568 // The renderer process this RenderFrameHost is associated with. It is
569 // equivalent to the result of site_instance_->GetProcess(), but that
570 // method has the side effect of creating the process if it doesn't exist.
571 // Cache a pointer to avoid unnecessary process creation.
572 RenderProcessHost* process_;
574 // |cross_process_frame_connector_| passes messages from an out-of-process
575 // child frame to the parent process for compositing.
577 // This is only non-NULL when this is the swapped out RenderFrameHost in
578 // the same site instance as this frame's parent.
580 // See the class comment above CrossProcessFrameConnector for more
581 // information.
583 // This will move to RenderFrameProxyHost when that class is created.
584 CrossProcessFrameConnector* cross_process_frame_connector_;
586 // The proxy created for this RenderFrameHost. It is used to send and receive
587 // IPC messages while in swapped out state.
588 // TODO(nasko): This can be removed once we don't have a swapped out state on
589 // RenderFrameHosts. See https://crbug.com/357747.
590 RenderFrameProxyHost* render_frame_proxy_host_;
592 // Reference to the whole frame tree that this RenderFrameHost belongs to.
593 // Allows this RenderFrameHost to add and remove nodes in response to
594 // messages from the renderer requesting DOM manipulation.
595 FrameTree* frame_tree_;
597 // The FrameTreeNode which this RenderFrameHostImpl is hosted in.
598 FrameTreeNode* frame_tree_node_;
600 // The mapping of pending JavaScript calls created by
601 // ExecuteJavaScript and their corresponding callbacks.
602 std::map<int, JavaScriptResultCallback> javascript_callbacks_;
603 std::map<uint64, VisualStateCallback> visual_state_callbacks_;
605 // RenderFrameHosts that need management of the rendering and input events
606 // for their frame subtrees require RenderWidgetHosts. This typically
607 // means frames that are rendered in different processes from their parent
608 // frames.
609 // TODO(kenrb): Later this will also be used on the top-level frame, when
610 // RenderFrameHost owns its RenderViewHost.
611 scoped_ptr<RenderWidgetHostImpl> render_widget_host_;
613 int routing_id_;
615 // The current state of this RenderFrameHost.
616 RenderFrameHostImplState rfh_state_;
618 // Tracks whether the RenderFrame for this RenderFrameHost has been created in
619 // the renderer process. Currently only used for subframes.
620 // TODO(creis): Use this for main frames as well when RVH goes away.
621 bool render_frame_created_;
623 // Whether we should buffer outgoing Navigate messages rather than sending
624 // them. This will be true when a RenderFrameHost is created for a cross-site
625 // request, until we hear back from the onbeforeunload handler of the old
626 // RenderFrameHost.
627 bool navigations_suspended_;
629 // Holds the parameters for a suspended navigation. This can only happen while
630 // this RFH is the pending RenderFrameHost of a RenderFrameHostManager. There
631 // will only ever be one suspended navigation, because RenderFrameHostManager
632 // will destroy the pending RenderFrameHost and create a new one if a second
633 // navigation occurs.
634 // PlzNavigate: unused as navigations are never suspended.
635 scoped_ptr<NavigationParams> suspended_nav_params_;
637 // When the last BeforeUnload message was sent.
638 base::TimeTicks send_before_unload_start_time_;
640 // Set to true when there is a pending FrameMsg_ShouldClose message. This
641 // ensures we don't spam the renderer with multiple beforeunload requests.
642 // When either this value or IsWaitingForUnloadACK is true, the value of
643 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
644 // cross-site transition or a tab close attempt.
645 // TODO(clamy): Remove this boolean and add one more state to the state
646 // machine.
647 bool is_waiting_for_beforeunload_ack_;
649 // Valid only when is_waiting_for_beforeunload_ack_ or
650 // IsWaitingForUnloadACK is true. This tells us if the unload request
651 // is for closing the entire tab ( = false), or only this RenderFrameHost in
652 // the case of a navigation ( = true). Currently only cross-site navigations
653 // require a beforeUnload/unload ACK.
654 // PlzNavigate: all navigations require a beforeUnload ACK.
655 bool unload_ack_is_for_navigation_;
657 // Indicates whether this RenderFrameHost is in the process of loading a
658 // document or not.
659 bool is_loading_;
661 // Used to swap out or shut down this RFH when the unload event is taking too
662 // long to execute, depending on the number of active frames in the
663 // SiteInstance.
664 scoped_ptr<TimeoutMonitor> swapout_event_monitor_timeout_;
666 scoped_ptr<ServiceRegistryImpl> service_registry_;
668 #if defined(OS_ANDROID)
669 scoped_ptr<ServiceRegistryAndroid> service_registry_android_;
670 #endif
672 // The object managing the accessibility tree for this frame.
673 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_;
675 // This is nonzero if we sent an accessibility reset to the renderer and
676 // we're waiting for an IPC containing this reset token (sequentially
677 // assigned) and a complete replacement accessibility tree.
678 int accessibility_reset_token_;
680 // A count of the number of times we needed to reset accessibility, so
681 // we don't keep trying to reset forever.
682 int accessibility_reset_count_;
684 // Callback when an event is received, for testing.
685 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_;
686 // The most recently received accessibility tree - for testing only.
687 scoped_ptr<ui::AXTree> ax_tree_for_testing_;
688 // Flag to not create a BrowserAccessibilityManager, for testing. If one
689 // already exists it will still be used.
690 bool no_create_browser_accessibility_manager_for_testing_;
692 // PlzNavigate: Owns the stream used in navigations to store the body of the
693 // response once it has started.
694 scoped_ptr<StreamHandle> stream_handle_;
696 // Context shared for each PermissionService instance created for this RFH.
697 scoped_ptr<PermissionServiceContext> permission_service_context_;
699 // NOTE: This must be the last member.
700 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
702 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
705 } // namespace content
707 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_