Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / frame_host / render_frame_host_impl.h
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.
4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
7
8 #include <map>
9 #include <vector>
10
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/mojo/service_registry_impl.h"
22 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/common/javascript_message_type.h"
24 #include "net/http/http_response_headers.h"
25 #include "third_party/WebKit/public/web/WebTextDirection.h"
26 #include "ui/accessibility/ax_node_data.h"
27 #include "ui/base/page_transition_types.h"
28
29 #if defined(OS_ANDROID)
30 #include "content/browser/mojo/service_registry_android.h"
31 #endif
32
33 class GURL;
34 struct AccessibilityHostMsg_EventParams;
35 struct AccessibilityHostMsg_FindInPageResultParams;
36 struct AccessibilityHostMsg_LocationChangeParams;
37 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
38 struct FrameHostMsg_OpenURL_Params;
39 struct FrameHostMsg_BeginNavigation_Params;
40 struct FrameMsg_Navigate_Params;
41 #if defined(OS_MACOSX) || defined(OS_ANDROID)
42 struct FrameHostMsg_ShowPopup_Params;
43 #endif
44
45 namespace base {
46 class FilePath;
47 class ListValue;
48 }
49
50 namespace content {
51
52 class CrossProcessFrameConnector;
53 class CrossSiteTransferringRequest;
54 class FrameTree;
55 class FrameTreeNode;
56 class RenderFrameHostDelegate;
57 class RenderFrameProxyHost;
58 class RenderProcessHost;
59 class RenderViewHostImpl;
60 class RenderWidgetHostImpl;
61 class StreamHandle;
62 class TimeoutMonitor;
63 struct CommitNavigationParams;
64 struct CommonNavigationParams;
65 struct ContextMenuParams;
66 struct GlobalRequestID;
67 struct Referrer;
68 struct ResourceResponse;
69 struct ShowDesktopNotificationHostMsgParams;
70 struct TransitionLayerData;
71
72 class CONTENT_EXPORT RenderFrameHostImpl
73     : public RenderFrameHost,
74       public BrowserAccessibilityDelegate {
75  public:
76   // Keeps track of the state of the RenderFrameHostImpl, particularly with
77   // respect to swap out.
78   enum RenderFrameHostImplState {
79     // The standard state for a RFH handling the communication with an active
80     // RenderFrame.
81     STATE_DEFAULT = 0,
82     // The RFH has not received the SwapOutACK yet, but the new page has
83     // committed in a different RFH.  Upon reception of the SwapOutACK, the RFH
84     // will either enter STATE_SWAPPED_OUT (if it is a main frame and there are
85     // other active frames in its SiteInstance) or it will be deleted.
86     STATE_PENDING_SWAP_OUT,
87     // The RFH is swapped out and stored inside a RenderFrameProxyHost, being
88     // used as a placeholder to allow cross-process communication.  Only main
89     // frames can enter this state.
90     STATE_SWAPPED_OUT,
91   };
92   // Helper function to determine whether the RFH state should contribute to the
93   // number of active frames of a SiteInstance or not.
94   static bool IsRFHStateActive(RenderFrameHostImplState rfh_state);
95
96   // An accessibility reset is only allowed to prevent very rare corner cases
97   // or race conditions where the browser and renderer get out of sync. If
98   // this happens more than this many times, kill the renderer.
99   static const int kMaxAccessibilityResets = 5;
100
101   static RenderFrameHostImpl* FromID(int process_id, int routing_id);
102
103   ~RenderFrameHostImpl() override;
104
105   // RenderFrameHost
106   int GetRoutingID() override;
107   SiteInstanceImpl* GetSiteInstance() override;
108   RenderProcessHost* GetProcess() override;
109   RenderFrameHost* GetParent() override;
110   const std::string& GetFrameName() override;
111   bool IsCrossProcessSubframe() override;
112   GURL GetLastCommittedURL() override;
113   gfx::NativeView GetNativeView() override;
114   void ExecuteJavaScript(const base::string16& javascript) override;
115   void ExecuteJavaScript(const base::string16& javascript,
116                          const JavaScriptResultCallback& callback) override;
117   void ExecuteJavaScriptForTests(const base::string16& javascript) override;
118   RenderViewHost* GetRenderViewHost() override;
119   ServiceRegistry* GetServiceRegistry() override;
120   void ActivateFindInPageResultForAccessibility(int request_id) override;
121
122   // IPC::Sender
123   bool Send(IPC::Message* msg) override;
124
125   // IPC::Listener
126   bool OnMessageReceived(const IPC::Message& msg) override;
127
128   // BrowserAccessibilityDelegate
129   void AccessibilitySetFocus(int acc_obj_id) override;
130   void AccessibilityDoDefaultAction(int acc_obj_id) override;
131   void AccessibilityShowMenu(const gfx::Point& global_point) override;
132   void AccessibilityScrollToMakeVisible(int acc_obj_id,
133                                         const gfx::Rect& subfocus) override;
134   void AccessibilityScrollToPoint(int acc_obj_id,
135                                   const gfx::Point& point) override;
136   void AccessibilitySetTextSelection(int acc_obj_id,
137                                      int start_offset,
138                                      int end_offset) override;
139   void AccessibilitySetValue(int acc_obj_id, const base::string16& value)
140       override;
141   bool AccessibilityViewHasFocus() const override;
142   gfx::Rect AccessibilityGetViewBounds() const override;
143   gfx::Point AccessibilityOriginInScreen(
144       const gfx::Rect& bounds) const override;
145   void AccessibilityHitTest(const gfx::Point& point) override;
146   void AccessibilitySetAccessibilityFocus(int acc_obj_id) override;
147   void AccessibilityFatalError() override;
148   gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() override;
149   gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() override;
150   BrowserAccessibilityManager* AccessibilityGetChildFrame(
151       int accessibility_node_id) override;
152   BrowserAccessibility* AccessibilityGetParentFrame() override;
153
154   // Creates a RenderFrame in the renderer process.  Only called for
155   // cross-process subframe navigations in --site-per-process.
156   bool CreateRenderFrame(int parent_routing_id, int proxy_routing_id);
157
158   // Returns whether the RenderFrame in the renderer process has been created
159   // and still has a connection.  This is valid for all frames.
160   bool IsRenderFrameLive();
161
162   // Tracks whether the RenderFrame for this RenderFrameHost has been created in
163   // the renderer process.  This is currently only used for subframes.
164   // TODO(creis): Use this for main frames as well when RVH goes away.
165   void set_render_frame_created(bool created) {
166     render_frame_created_ = created;
167   }
168
169   // Called for renderer-created windows to resume requests from this frame,
170   // after they are blocked in RenderWidgetHelper::CreateNewWindow.
171   void Init();
172
173   int routing_id() const { return routing_id_; }
174   void OnCreateChildFrame(int new_routing_id,
175                           const std::string& frame_name);
176
177   RenderViewHostImpl* render_view_host() { return render_view_host_; }
178   RenderFrameHostDelegate* delegate() { return delegate_; }
179   FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
180   // TODO(nasko): The RenderWidgetHost will be owned by RenderFrameHost in
181   // the future, so update this accessor to return the right pointer.
182   RenderWidgetHostImpl* GetRenderWidgetHost();
183
184   // This function is called when this is a swapped out RenderFrameHost that
185   // lives in the same process as the parent frame. The
186   // |cross_process_frame_connector| allows the non-swapped-out
187   // RenderFrameHost for a frame to communicate with the parent process
188   // so that it may composite drawing data.
189   //
190   // Ownership is not transfered.
191   void set_cross_process_frame_connector(
192       CrossProcessFrameConnector* cross_process_frame_connector) {
193     cross_process_frame_connector_ = cross_process_frame_connector;
194   }
195
196   void set_render_frame_proxy_host(RenderFrameProxyHost* proxy) {
197     render_frame_proxy_host_ = proxy;
198   }
199
200   // Returns a bitwise OR of bindings types that have been enabled for this
201   // RenderFrameHostImpl's RenderView. See BindingsPolicy for details.
202   // TODO(creis): Make bindings frame-specific, to support cases like <webview>.
203   int GetEnabledBindings();
204
205   // Called on the pending RenderFrameHost when the network response is ready to
206   // commit.  We should ensure that the old RenderFrameHost runs its unload
207   // handler and determine whether a transfer to a different RenderFrameHost is
208   // needed.
209   void OnCrossSiteResponse(
210       const GlobalRequestID& global_request_id,
211       scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
212       const std::vector<GURL>& transfer_url_chain,
213       const Referrer& referrer,
214       ui::PageTransition page_transition,
215       bool should_replace_current_entry);
216
217   // Called on the current RenderFrameHost when the network response is first
218   // receieved.
219   void OnDeferredAfterResponseStarted(
220       const GlobalRequestID& global_request_id,
221       const TransitionLayerData& transition_data);
222
223   // Tells the renderer that this RenderFrame is being swapped out for one in a
224   // different renderer process.  It should run its unload handler and move to
225   // a blank document.  If |proxy| is not null, it should also create a
226   // RenderFrameProxy to replace the RenderFrame. The renderer should preserve
227   // the RenderFrameProxy object until it exits, in case we come back.  The
228   // renderer can exit if it has no other active RenderFrames, but not until
229   // WasSwappedOut is called.
230   void SwapOut(RenderFrameProxyHost* proxy);
231
232   bool is_waiting_for_beforeunload_ack() const {
233     return is_waiting_for_beforeunload_ack_;
234   }
235
236   // Whether the RFH is waiting for an unload ACK from the renderer.
237   bool IsWaitingForUnloadACK() const;
238
239   // Called when either the SwapOut request has been acknowledged or has timed
240   // out.
241   void OnSwappedOut();
242
243   // Whether this RenderFrameHost has been swapped out, such that the frame is
244   // now rendered by a RenderFrameHost in a different process.
245   bool is_swapped_out() const { return rfh_state_ == STATE_SWAPPED_OUT; }
246
247   // The current state of this RFH.
248   RenderFrameHostImplState rfh_state() const { return rfh_state_; }
249
250   // Sends the given navigation message. Use this rather than sending it
251   // yourself since this does the internal bookkeeping described below. This
252   // function takes ownership of the provided message pointer.
253   //
254   // If a cross-site request is in progress, we may be suspended while waiting
255   // for the onbeforeunload handler, so this function might buffer the message
256   // rather than sending it.
257   void Navigate(const FrameMsg_Navigate_Params& params);
258
259   // Load the specified URL; this is a shortcut for Navigate().
260   void NavigateToURL(const GURL& url);
261
262   // Treat this prospective navigation as thought it originated from the
263   // frame. Used, e.g., for a navigation request that originated from
264   // a RemoteFrame.
265   void OpenURL(const FrameHostMsg_OpenURL_Params& params);
266
267   // Stop the load in progress.
268   void Stop();
269
270   // Returns whether navigation messages are currently suspended for this
271   // RenderFrameHost. Only true during a cross-site navigation, while waiting
272   // for the onbeforeunload handler.
273   bool are_navigations_suspended() const { return navigations_suspended_; }
274
275   // Suspends (or unsuspends) any navigation messages from being sent from this
276   // RenderFrameHost. This is called when a pending RenderFrameHost is created
277   // for a cross-site navigation, because we must suspend any navigations until
278   // we hear back from the old renderer's onbeforeunload handler. Note that it
279   // is important that only one navigation event happen after calling this
280   // method with |suspend| equal to true. If |suspend| is false and there is a
281   // suspended_nav_message_, this will send the message. This function should
282   // only be called to toggle the state; callers should check
283   // are_navigations_suspended() first. If |suspend| is false, the time that the
284   // user decided the navigation should proceed should be passed as
285   // |proceed_time|.
286   void SetNavigationsSuspended(bool suspend,
287                                const base::TimeTicks& proceed_time);
288
289   // Clears any suspended navigation state after a cross-site navigation is
290   // canceled or suspended. This is important if we later return to this
291   // RenderFrameHost.
292   void CancelSuspendedNavigations();
293
294   // Runs the beforeunload handler for this frame. |for_cross_site_transition|
295   // indicates whether this call is for the current frame during a cross-process
296   // navigation. False means we're closing the entire tab.
297   void DispatchBeforeUnload(bool for_cross_site_transition);
298
299   // Set the frame's opener to null in the renderer process in response to an
300   // action in another renderer process.
301   void DisownOpener();
302
303   // Deletes the current selection plus the specified number of characters
304   // before and after the selection or caret.
305   void ExtendSelectionAndDelete(size_t before, size_t after);
306
307   // Notifies the RenderFrame that the JavaScript message that was shown was
308   // closed by the user.
309   void JavaScriptDialogClosed(IPC::Message* reply_msg,
310                               bool success,
311                               const base::string16& user_input,
312                               bool dialog_was_suppressed);
313
314   // Called when an HTML5 notification is closed.
315   void NotificationClosed(int notification_id);
316
317   // Clears any outstanding transition request. This is called when we hear the
318   // response or commit.
319   void ClearPendingTransitionRequestData();
320
321   // Send a message to the renderer process to change the accessibility mode.
322   void SetAccessibilityMode(AccessibilityMode AccessibilityMode);
323
324   // Turn on accessibility testing. The given callback will be run
325   // every time an accessibility notification is received from the
326   // renderer process, and the accessibility tree it sent can be
327   // retrieved using GetAXTreeForTesting().
328   void SetAccessibilityCallbackForTesting(
329       const base::Callback<void(ui::AXEvent, int)>& callback);
330
331   // Returns a snapshot of the accessibility tree received from the
332   // renderer as of the last time an accessibility notification was
333   // received.
334   const ui::AXTree* GetAXTreeForTesting();
335
336   // Access the BrowserAccessibilityManager if it already exists.
337   BrowserAccessibilityManager* browser_accessibility_manager() const {
338     return browser_accessibility_manager_.get();
339   }
340
341   // If accessibility is enabled, get the BrowserAccessibilityManager for
342   // this frame, or create one if it doesn't exist yet, otherwise return
343   // NULL.
344   BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager();
345
346   void set_no_create_browser_accessibility_manager_for_testing(bool flag) {
347     no_create_browser_accessibility_manager_for_testing_ = flag;
348   }
349
350 #if defined(OS_WIN)
351   void SetParentNativeViewAccessible(
352       gfx::NativeViewAccessible accessible_parent);
353   gfx::NativeViewAccessible GetParentNativeViewAccessible() const;
354 #elif defined(OS_MACOSX)
355   // Select popup menu related methods (for external popup menus).
356   void DidSelectPopupMenuItem(int selected_index);
357   void DidCancelPopupMenu();
358 #elif defined(OS_ANDROID)
359   void DidSelectPopupMenuItems(const std::vector<int>& selected_indices);
360   void DidCancelPopupMenu();
361 #endif
362
363   // PlzNavigate: Indicates that a navigation is ready to commit and can be
364   // handled by this RenderFrame.
365   void CommitNavigation(ResourceResponse* response,
366                         scoped_ptr<StreamHandle> body,
367                         const CommonNavigationParams& common_params,
368                         const CommitNavigationParams& commit_params);
369
370   // Sets up the Mojo connection between this instance and its associated render
371   // frame if it has not yet been set up.
372   void SetUpMojoIfNeeded();
373
374   // Tears down the browser-side state relating to the Mojo connection between
375   // this instance and its associated render frame.
376   void InvalidateMojoConnection();
377
378  protected:
379   friend class RenderFrameHostFactory;
380
381   // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
382   // should be the abstraction needed here, but we need RenderViewHost to pass
383   // into WebContentsObserver::FrameDetached for now.
384   RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
385                       RenderFrameHostDelegate* delegate,
386                       FrameTree* frame_tree,
387                       FrameTreeNode* frame_tree_node,
388                       int routing_id,
389                       bool is_swapped_out);
390
391  private:
392   friend class TestRenderFrameHost;
393   friend class TestRenderViewHost;
394
395   FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrashSubframe);
396
397   // IPC Message handlers.
398   void OnAddMessageToConsole(int32 level,
399                              const base::string16& message,
400                              int32 line_no,
401                              const base::string16& source_id);
402   void OnDetach();
403   void OnFrameFocused();
404   void OnOpenURL(const FrameHostMsg_OpenURL_Params& params);
405   void OnDocumentOnLoadCompleted();
406   void OnDidStartProvisionalLoadForFrame(const GURL& url,
407                                          bool is_transition_navigation);
408   void OnDidFailProvisionalLoadWithError(
409       const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params);
410   void OnDidFailLoadWithError(
411       const GURL& url,
412       int error_code,
413       const base::string16& error_description);
414   void OnDidCommitProvisionalLoad(const IPC::Message& msg);
415   void OnBeforeUnloadACK(
416       bool proceed,
417       const base::TimeTicks& renderer_before_unload_start_time,
418       const base::TimeTicks& renderer_before_unload_end_time);
419   void OnSwapOutACK();
420   void OnContextMenu(const ContextMenuParams& params);
421   void OnJavaScriptExecuteResponse(int id, const base::ListValue& result);
422   void OnRunJavaScriptMessage(const base::string16& message,
423                               const base::string16& default_prompt,
424                               const GURL& frame_url,
425                               JavaScriptMessageType type,
426                               IPC::Message* reply_msg);
427   void OnRunBeforeUnloadConfirm(const GURL& frame_url,
428                                 const base::string16& message,
429                                 bool is_reload,
430                                 IPC::Message* reply_msg);
431   void OnRequestPlatformNotificationPermission(const GURL& origin,
432                                                int request_id);
433   void OnShowDesktopNotification(
434       int notification_id,
435       const ShowDesktopNotificationHostMsgParams& params);
436   void OnCancelDesktopNotification(int notification_id);
437   void OnTextSurroundingSelectionResponse(const base::string16& content,
438                                           size_t start_offset,
439                                           size_t end_offset);
440   void OnDidAccessInitialDocument();
441   void OnDidDisownOpener();
442   void OnDidAssignPageId(int32 page_id);
443   void OnUpdateTitle(const base::string16& title,
444                      blink::WebTextDirection title_direction);
445   void OnUpdateEncoding(const std::string& encoding);
446   void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params,
447                          const CommonNavigationParams& common_params);
448   void OnAccessibilityEvents(
449       const std::vector<AccessibilityHostMsg_EventParams>& params,
450       int reset_token);
451   void OnAccessibilityLocationChanges(
452       const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
453   void OnAccessibilityFindInPageResult(
454       const AccessibilityHostMsg_FindInPageResultParams& params);
455   void OnRequestPushPermission(int request_id, bool user_gesture);
456
457 #if defined(OS_MACOSX) || defined(OS_ANDROID)
458   void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params);
459   void OnHidePopup();
460 #endif
461
462   // Registers Mojo services that this frame host makes available.
463   void RegisterMojoServices();
464
465   // Updates the state of this RenderFrameHost and clears any waiting state
466   // that is no longer relevant.
467   void SetState(RenderFrameHostImplState rfh_state);
468
469   // Returns whether the given URL is allowed to commit in the current process.
470   // This is a more conservative check than RenderProcessHost::FilterURL, since
471   // it will be used to kill processes that commit unauthorized URLs.
472   bool CanCommitURL(const GURL& url);
473
474   void PlatformNotificationPermissionRequestDone(int request_id, bool granted);
475
476   void PushPermissionRequestDone(int request_id, bool allowed);
477
478   // Update the the singleton FrameAccessibility instance with a map
479   // from accessibility node id to the frame routing id of a cross-process
480   // iframe.
481   void UpdateCrossProcessIframeAccessibility(
482       const std::map<int32, int>& node_to_frame_routing_id_map);
483
484   // Update the the singleton FrameAccessibility instance with a map
485   // from accessibility node id to the browser plugin instance id of a
486   // guest WebContents.
487   void UpdateGuestFrameAccessibility(
488       const std::map<int32, int>& node_to_browser_plugin_instance_id_map);
489
490   // Informs the content client that geolocation permissions were used.
491   void DidUseGeolocationPermission();
492
493   // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
494   // refcount that calls Shutdown when it reaches zero.  This allows each
495   // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
496   // we have a RenderViewHost for each RenderFrameHost.
497   // TODO(creis): RenderViewHost will eventually go away and be replaced with
498   // some form of page context.
499   RenderViewHostImpl* render_view_host_;
500
501   RenderFrameHostDelegate* delegate_;
502
503   // |cross_process_frame_connector_| passes messages from an out-of-process
504   // child frame to the parent process for compositing.
505   //
506   // This is only non-NULL when this is the swapped out RenderFrameHost in
507   // the same site instance as this frame's parent.
508   //
509   // See the class comment above CrossProcessFrameConnector for more
510   // information.
511   //
512   // This will move to RenderFrameProxyHost when that class is created.
513   CrossProcessFrameConnector* cross_process_frame_connector_;
514
515   // The proxy created for this RenderFrameHost. It is used to send and receive
516   // IPC messages while in swapped out state.
517   // TODO(nasko): This can be removed once we don't have a swapped out state on
518   // RenderFrameHosts. See https://crbug.com/357747.
519   RenderFrameProxyHost* render_frame_proxy_host_;
520
521   // Reference to the whole frame tree that this RenderFrameHost belongs to.
522   // Allows this RenderFrameHost to add and remove nodes in response to
523   // messages from the renderer requesting DOM manipulation.
524   FrameTree* frame_tree_;
525
526   // The FrameTreeNode which this RenderFrameHostImpl is hosted in.
527   FrameTreeNode* frame_tree_node_;
528
529   // The mapping of pending JavaScript calls created by
530   // ExecuteJavaScript and their corresponding callbacks.
531   std::map<int, JavaScriptResultCallback> javascript_callbacks_;
532
533   // Map from notification_id to a callback to cancel them.
534   std::map<int, base::Closure> cancel_notification_callbacks_;
535
536   int routing_id_;
537
538   // The current state of this RenderFrameHost.
539   RenderFrameHostImplState rfh_state_;
540
541   // Tracks whether the RenderFrame for this RenderFrameHost has been created in
542   // the renderer process.  Currently only used for subframes.
543   // TODO(creis): Use this for main frames as well when RVH goes away.
544   bool render_frame_created_;
545
546   // Whether we should buffer outgoing Navigate messages rather than sending
547   // them. This will be true when a RenderFrameHost is created for a cross-site
548   // request, until we hear back from the onbeforeunload handler of the old
549   // RenderFrameHost.
550   bool navigations_suspended_;
551
552   // We only buffer the params for a suspended navigation while this RFH is the
553   // pending RenderFrameHost of a RenderFrameHostManager. There will only ever
554   // be one suspended navigation, because RenderFrameHostManager will destroy
555   // the pending RenderFrameHost and create a new one if a second navigation
556   // occurs.
557   scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_;
558
559   // When the last BeforeUnload message was sent.
560   base::TimeTicks send_before_unload_start_time_;
561
562   // Set to true when there is a pending FrameMsg_ShouldClose message.  This
563   // ensures we don't spam the renderer with multiple beforeunload requests.
564   // When either this value or IsWaitingForUnloadACK is true, the value of
565   // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
566   // cross-site transition or a tab close attempt.
567   // TODO(clamy): Remove this boolean and add one more state to the state
568   // machine.
569   bool is_waiting_for_beforeunload_ack_;
570
571   // Valid only when is_waiting_for_beforeunload_ack_ or
572   // IsWaitingForUnloadACK is true.  This tells us if the unload request
573   // is for closing the entire tab ( = false), or only this RenderFrameHost in
574   // the case of a cross-site transition ( = true).
575   bool unload_ack_is_for_cross_site_transition_;
576
577   // Used to swap out or shut down this RFH when the unload event is taking too
578   // long to execute, depending on the number of active frames in the
579   // SiteInstance.
580   scoped_ptr<TimeoutMonitor> swapout_event_monitor_timeout_;
581
582   scoped_ptr<ServiceRegistryImpl> service_registry_;
583
584 #if defined(OS_ANDROID)
585   scoped_ptr<ServiceRegistryAndroid> service_registry_android_;
586 #endif
587
588   // The object managing the accessibility tree for this frame.
589   scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_;
590
591   // This is nonzero if we sent an accessibility reset to the renderer and
592   // we're waiting for an IPC containing this reset token (sequentially
593   // assigned) and a complete replacement accessibility tree.
594   int accessibility_reset_token_;
595
596   // A count of the number of times we needed to reset accessibility, so
597   // we don't keep trying to reset forever.
598   int accessibility_reset_count_;
599
600   // Callback when an event is received, for testing.
601   base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_;
602   // The most recently received accessibility tree - for testing only.
603   scoped_ptr<ui::AXTree> ax_tree_for_testing_;
604   // Flag to not create a BrowserAccessibilityManager, for testing. If one
605   // already exists it will still be used.
606   bool no_create_browser_accessibility_manager_for_testing_;
607
608   // PlzNavigate: Owns the stream used in navigations to store the body of the
609   // response once it has started.
610   scoped_ptr<StreamHandle> stream_handle_;
611
612   // NOTE: This must be the last member.
613   base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
614
615   DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
616 };
617
618 }  // namespace content
619
620 #endif  // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_