OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class CrossProcessFrameConnector; | 24 class CrossProcessFrameConnector; |
25 class CrossSiteTransferringRequest; | 25 class CrossSiteTransferringRequest; |
26 class InterstitialPageImpl; | 26 class InterstitialPageImpl; |
27 class FrameTreeNode; | 27 class FrameTreeNode; |
28 class NavigationControllerImpl; | 28 class NavigationControllerImpl; |
29 class NavigationEntry; | 29 class NavigationEntry; |
30 class NavigationEntryImpl; | 30 class NavigationEntryImpl; |
31 class NavigationRequest; | 31 class NavigationRequest; |
32 class RenderFrameHost; | 32 class RenderFrameHost; |
33 class RenderFrameHostDelegate; | 33 class RenderFrameHostDelegate; |
34 class RenderFrameHost; | |
35 class RenderFrameHostImpl; | 34 class RenderFrameHostImpl; |
36 class RenderFrameHostManagerTest; | 35 class RenderFrameHostManagerTest; |
37 class RenderFrameProxyHost; | 36 class RenderFrameProxyHost; |
38 class RenderViewHost; | 37 class RenderViewHost; |
39 class RenderViewHostImpl; | 38 class RenderViewHostImpl; |
40 class RenderWidgetHostDelegate; | 39 class RenderWidgetHostDelegate; |
41 class RenderWidgetHostView; | 40 class RenderWidgetHostView; |
42 class TestWebContents; | 41 class TestWebContents; |
43 class WebUIImpl; | 42 class WebUIImpl; |
44 | 43 |
45 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state | 44 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state |
46 // machine to make cross-process navigations in a frame possible. | 45 // machine to make cross-process navigations in a frame possible. |
47 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { | 46 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
48 public: | 47 public: |
49 // Functions implemented by our owner that we need. | 48 // Functions implemented by our owner that we need. |
50 // | 49 // |
51 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl | 50 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl |
52 // that are required to run this class. The design should probably be better | 51 // that are required to run this class. The design should probably be better |
53 // such that these are more clear. | 52 // such that these are more clear. |
54 // | 53 // |
55 // There is additional complexity that some of the functions we need in | 54 // There is additional complexity that some of the functions we need in |
56 // WebContentsImpl are inherited and non-virtual. These are named with | 55 // WebContentsImpl are inherited and non-virtual. These are named with |
57 // "RenderManager" so that the duplicate implementation of them will be clear. | 56 // "RenderManager" so that the duplicate implementation of them will be clear. |
58 class CONTENT_EXPORT Delegate { | 57 class CONTENT_EXPORT Delegate { |
59 public: | 58 public: |
60 // Initializes the given renderer if necessary and creates the view ID | 59 // Initializes the given renderer if necessary and creates the view ID |
61 // corresponding to this view host. If this method is not called and the | 60 // corresponding to this view host. If this method is not called and the |
62 // process is not shared, then the WebContentsImpl will act as though the | 61 // process is not shared, then the WebContentsImpl will act as though the |
63 // renderer is not running (i.e., it will render "sad tab"). This method is | 62 // renderer is not running (i.e., it will render "sad tab"). This method is |
64 // automatically called from LoadURL. |for_main_frame_navigation| indicates | 63 // automatically called from LoadURL. |for_main_frame| indicates whether |
65 // whether this RenderViewHost is used to render a top-level frame, so the | 64 // this RenderViewHost is used to render a top-level frame, so the |
66 // appropriate RenderWidgetHostView type is used. | 65 // appropriate RenderWidgetHostView type is used. |
67 virtual bool CreateRenderViewForRenderManager( | 66 virtual bool CreateRenderViewForRenderManager( |
68 RenderViewHost* render_view_host, | 67 RenderViewHost* render_view_host, |
69 int opener_route_id, | 68 int opener_route_id, |
70 int proxy_routing_id, | 69 int proxy_routing_id, |
71 bool for_main_frame_navigation) = 0; | 70 bool for_main_frame) = 0; |
72 virtual bool CreateRenderFrameForRenderManager( | |
73 RenderFrameHost* render_frame_host, | |
74 int parent_routing_id) = 0; | |
75 virtual void BeforeUnloadFiredFromRenderManager( | 71 virtual void BeforeUnloadFiredFromRenderManager( |
76 bool proceed, const base::TimeTicks& proceed_time, | 72 bool proceed, const base::TimeTicks& proceed_time, |
77 bool* proceed_to_fire_unload) = 0; | 73 bool* proceed_to_fire_unload) = 0; |
78 virtual void RenderProcessGoneFromRenderManager( | 74 virtual void RenderProcessGoneFromRenderManager( |
79 RenderViewHost* render_view_host) = 0; | 75 RenderViewHost* render_view_host) = 0; |
80 virtual void UpdateRenderViewSizeForRenderManager() = 0; | 76 virtual void UpdateRenderViewSizeForRenderManager() = 0; |
81 virtual void CancelModalDialogsForRenderManager() = 0; | 77 virtual void CancelModalDialogsForRenderManager() = 0; |
82 virtual void NotifySwappedFromRenderManager(RenderFrameHost* old_host, | 78 virtual void NotifySwappedFromRenderManager(RenderFrameHost* old_host, |
83 RenderFrameHost* new_host, | 79 RenderFrameHost* new_host, |
84 bool is_main_frame) = 0; | 80 bool is_main_frame) = 0; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Called when a renderer sets its opener to null. | 244 // Called when a renderer sets its opener to null. |
249 void DidDisownOpener(RenderViewHost* render_view_host); | 245 void DidDisownOpener(RenderViewHost* render_view_host); |
250 | 246 |
251 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| | 247 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
252 // is true, it will be initially placed on the swapped out hosts list. | 248 // is true, it will be initially placed on the swapped out hosts list. |
253 // Otherwise, it will be used for a pending cross-site navigation. | 249 // Otherwise, it will be used for a pending cross-site navigation. |
254 // Returns the routing id of the *view* associated with the frame. | 250 // Returns the routing id of the *view* associated with the frame. |
255 int CreateRenderFrame(SiteInstance* instance, | 251 int CreateRenderFrame(SiteInstance* instance, |
256 int opener_route_id, | 252 int opener_route_id, |
257 bool swapped_out, | 253 bool swapped_out, |
258 bool for_main_frame_navigation, | |
259 bool hidden); | 254 bool hidden); |
260 | 255 |
261 // Helper method to create and initialize a RenderFrameProxyHost and return | |
262 // its routing id. | |
263 int CreateRenderFrameProxy(SiteInstance* instance); | |
264 | |
265 // Sets the passed passed interstitial as the currently showing interstitial. | 256 // Sets the passed passed interstitial as the currently showing interstitial. |
266 // |interstitial_page| should be non NULL (use the remove_interstitial_page | 257 // |interstitial_page| should be non NULL (use the remove_interstitial_page |
267 // method to unset the interstitial) and no interstitial page should be set | 258 // method to unset the interstitial) and no interstitial page should be set |
268 // when there is already a non NULL interstitial page set. | 259 // when there is already a non NULL interstitial page set. |
269 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { | 260 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { |
270 DCHECK(!interstitial_page_ && interstitial_page); | 261 DCHECK(!interstitial_page_ && interstitial_page); |
271 interstitial_page_ = interstitial_page; | 262 interstitial_page_ = interstitial_page; |
272 } | 263 } |
273 | 264 |
274 // Unsets the currently showing interstitial. | 265 // Unsets the currently showing interstitial. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, | 298 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, |
308 RenderFrameHostImpl* rfh); | 299 RenderFrameHostImpl* rfh); |
309 | 300 |
310 // Deletes any proxy hosts associated with this node. Used during destruction | 301 // Deletes any proxy hosts associated with this node. Used during destruction |
311 // of WebContentsImpl. | 302 // of WebContentsImpl. |
312 void ResetProxyHosts(); | 303 void ResetProxyHosts(); |
313 | 304 |
314 // Used to start a navigation, part of browser-side navigation project. | 305 // Used to start a navigation, part of browser-side navigation project. |
315 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); | 306 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); |
316 | 307 |
317 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | |
318 // that has the given SiteInstance and is associated with this | |
319 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | |
320 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | |
321 | |
322 private: | 308 private: |
323 friend class RenderFrameHostManagerTest; | 309 friend class RenderFrameHostManagerTest; |
324 friend class TestWebContents; | 310 friend class TestWebContents; |
325 | 311 |
326 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | |
327 CreateCrossProcessSubframeProxies); | |
328 | |
329 // Tracks information about a navigation while a cross-process transition is | 312 // Tracks information about a navigation while a cross-process transition is |
330 // in progress, in case we need to transfer it to a new RenderFrameHost. | 313 // in progress, in case we need to transfer it to a new RenderFrameHost. |
331 // When a request is being transferred, deleting the PendingNavigationParams, | 314 // When a request is being transferred, deleting the PendingNavigationParams, |
332 // and thus |cross_site_transferring_request|, will cancel the request being | 315 // and thus |cross_site_transferring_request|, will cancel the request being |
333 // transferred, unless its ReleaseRequest method has been called. | 316 // transferred, unless its ReleaseRequest method has been called. |
334 struct PendingNavigationParams { | 317 struct PendingNavigationParams { |
335 PendingNavigationParams( | 318 PendingNavigationParams( |
336 const GlobalRequestID& global_request_id, | 319 const GlobalRequestID& global_request_id, |
337 scoped_ptr<CrossSiteTransferringRequest> | 320 scoped_ptr<CrossSiteTransferringRequest> |
338 cross_site_transferring_request, | 321 cross_site_transferring_request, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Sets up the necessary state for a new RenderViewHost with the given opener, | 404 // Sets up the necessary state for a new RenderViewHost with the given opener, |
422 // if necessary. It creates a RenderFrameProxy in the target renderer process | 405 // if necessary. It creates a RenderFrameProxy in the target renderer process |
423 // with the given |proxy_routing_id|, which is used to route IPC messages when | 406 // with the given |proxy_routing_id|, which is used to route IPC messages when |
424 // in swapped out state. Returns early if the RenderViewHost has already been | 407 // in swapped out state. Returns early if the RenderViewHost has already been |
425 // initialized for another RenderFrameHost. | 408 // initialized for another RenderFrameHost. |
426 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 409 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
427 // be for the RenderFrame, since frames can have openers. | 410 // be for the RenderFrame, since frames can have openers. |
428 bool InitRenderView(RenderViewHost* render_view_host, | 411 bool InitRenderView(RenderViewHost* render_view_host, |
429 int opener_route_id, | 412 int opener_route_id, |
430 int proxy_routing_id, | 413 int proxy_routing_id, |
431 bool for_main_frame_navigation); | 414 bool for_main_frame); |
432 | |
433 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | |
434 // above. | |
435 bool InitRenderFrame(RenderFrameHost* render_frame_host); | |
436 | 415 |
437 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 416 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
438 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 417 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
439 // since there could be Web UI switching as well. Call this for every commit. | 418 // since there could be Web UI switching as well. Call this for every commit. |
440 void CommitPending(); | 419 void CommitPending(); |
441 | 420 |
442 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to | 421 // Shutdown all RenderFrameHosts in a SiteInstance. This is called to shutdown |
443 // shutdown frames when all the frames in a SiteInstance are confirmed to be | 422 // frames when all the frames in a SiteInstance are confirmed to be swapped |
444 // swapped out. | 423 // out. |
445 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); | 424 void ShutdownRenderFrameHostsInSiteInstance(int32 site_instance_id); |
446 | 425 |
447 // Helper method to terminate the pending RenderViewHost. | 426 // Helper method to terminate the pending RenderViewHost. |
448 void CancelPending(); | 427 void CancelPending(); |
449 | 428 |
450 // Helper method to set the active RenderFrameHost. Returns the old | 429 // Helper method to set the active RenderFrameHost. Returns the old |
451 // RenderFrameHost and updates counts. | 430 // RenderFrameHost and updates counts. |
452 scoped_ptr<RenderFrameHostImpl> SetRenderFrameHost( | 431 scoped_ptr<RenderFrameHostImpl> SetRenderFrameHost( |
453 scoped_ptr<RenderFrameHostImpl> render_frame_host); | 432 scoped_ptr<RenderFrameHostImpl> render_frame_host); |
454 | 433 |
455 RenderFrameHostImpl* UpdateStateForNavigate( | 434 RenderFrameHostImpl* UpdateStateForNavigate( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 scoped_ptr<NavigationRequest> navigation_request_; | 508 scoped_ptr<NavigationRequest> navigation_request_; |
530 | 509 |
531 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 510 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
532 | 511 |
533 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 512 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
534 }; | 513 }; |
535 | 514 |
536 } // namespace content | 515 } // namespace content |
537 | 516 |
538 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 517 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |