Chromium Code Reviews| 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 <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 public: | 114 public: |
| 115 // Initializes the given renderer if necessary and creates the view ID | 115 // Initializes the given renderer if necessary and creates the view ID |
| 116 // corresponding to this view host. If this method is not called and the | 116 // corresponding to this view host. If this method is not called and the |
| 117 // process is not shared, then the WebContentsImpl will act as though the | 117 // process is not shared, then the WebContentsImpl will act as though the |
| 118 // renderer is not running (i.e., it will render "sad tab"). This method is | 118 // renderer is not running (i.e., it will render "sad tab"). This method is |
| 119 // automatically called from LoadURL. |for_main_frame_navigation| indicates | 119 // automatically called from LoadURL. |for_main_frame_navigation| indicates |
| 120 // whether this RenderViewHost is used to render a top-level frame, so the | 120 // whether this RenderViewHost is used to render a top-level frame, so the |
| 121 // appropriate RenderWidgetHostView type is used. | 121 // appropriate RenderWidgetHostView type is used. |
| 122 virtual bool CreateRenderViewForRenderManager( | 122 virtual bool CreateRenderViewForRenderManager( |
| 123 RenderViewHost* render_view_host, | 123 RenderViewHost* render_view_host, |
| 124 int opener_route_id, | 124 int opener_frame_routing_id, |
| 125 int proxy_routing_id, | 125 int proxy_routing_id, |
| 126 const FrameReplicationState& replicated_frame_state, | 126 const FrameReplicationState& replicated_frame_state, |
| 127 bool for_main_frame_navigation) = 0; | 127 bool for_main_frame_navigation) = 0; |
| 128 virtual bool CreateRenderFrameForRenderManager( | 128 virtual bool CreateRenderFrameForRenderManager( |
| 129 RenderFrameHost* render_frame_host, | 129 RenderFrameHost* render_frame_host, |
| 130 int parent_routing_id, | 130 int parent_routing_id, |
| 131 int previous_sibling_routing_id, | 131 int previous_sibling_routing_id, |
| 132 int proxy_routing_id) = 0; | 132 int proxy_routing_id) = 0; |
| 133 virtual void BeforeUnloadFiredFromRenderManager( | 133 virtual void BeforeUnloadFiredFromRenderManager( |
| 134 bool proceed, const base::TimeTicks& proceed_time, | 134 bool proceed, const base::TimeTicks& proceed_time, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 | 346 |
| 347 // Creates and initializes a RenderFrameHost. The |web_ui| is an optional | 347 // Creates and initializes a RenderFrameHost. The |web_ui| is an optional |
| 348 // input parameter used to double check bindings when swapping back in a | 348 // input parameter used to double check bindings when swapping back in a |
| 349 // previously existing RenderFrameHost. If |flags| has the | 349 // previously existing RenderFrameHost. If |flags| has the |
| 350 // CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags enum, it will | 350 // CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags enum, it will |
| 351 // initially be placed on the swapped out hosts list. If |view_routing_id_ptr| | 351 // initially be placed on the swapped out hosts list. If |view_routing_id_ptr| |
| 352 // is not nullptr it will be set to the routing id of the view associated with | 352 // is not nullptr it will be set to the routing id of the view associated with |
| 353 // the frame. | 353 // the frame. |
| 354 scoped_ptr<RenderFrameHostImpl> CreateRenderFrame(SiteInstance* instance, | 354 scoped_ptr<RenderFrameHostImpl> CreateRenderFrame(SiteInstance* instance, |
| 355 WebUIImpl* web_ui, | 355 WebUIImpl* web_ui, |
| 356 int opener_route_id, | |
| 357 int flags, | 356 int flags, |
| 358 int* view_routing_id_ptr); | 357 int* view_routing_id_ptr); |
| 359 | 358 |
| 360 // Helper method to create and initialize a RenderFrameProxyHost and return | 359 // Helper method to create and initialize a RenderFrameProxyHost and return |
| 361 // its routing id. | 360 // its routing id. If |suppress_opener| is true, an opener frame won't be |
| 362 int CreateRenderFrameProxy(SiteInstance* instance); | 361 // assigned for the corresponding RenderFrameProxy even if the current |
| 362 // FrameTreeNode has an opener. | |
| 363 int CreateRenderFrameProxy(SiteInstance* instance, bool suppress_opener); | |
| 363 | 364 |
| 364 // Creates proxies for a new child frame at FrameTreeNode |child| in all | 365 // Creates proxies for a new child frame at FrameTreeNode |child| in all |
| 365 // SiteInstances for which the current frame has proxies. This method is | 366 // SiteInstances for which the current frame has proxies. This method is |
| 366 // called on the parent of a new child frame before the child leaves the | 367 // called on the parent of a new child frame before the child leaves the |
| 367 // SiteInstance. | 368 // SiteInstance. |
| 368 void CreateProxiesForChildFrame(FrameTreeNode* child); | 369 void CreateProxiesForChildFrame(FrameTreeNode* child); |
| 369 | 370 |
| 370 // Sets the passed passed interstitial as the currently showing interstitial. | 371 // Sets the passed passed interstitial as the currently showing interstitial. |
| 371 // |interstitial_page| should be non NULL (use the remove_interstitial_page | 372 // |interstitial_page| should be non NULL (use the remove_interstitial_page |
| 372 // method to unset the interstitial) and no interstitial page should be set | 373 // method to unset the interstitial) and no interstitial page should be set |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 bool IsPendingDeletion(RenderFrameHostImpl* render_frame_host); | 408 bool IsPendingDeletion(RenderFrameHostImpl* render_frame_host); |
| 408 | 409 |
| 409 // If |render_frame_host| is on the pending deletion list, this deletes it. | 410 // If |render_frame_host| is on the pending deletion list, this deletes it. |
| 410 // Returns whether it was deleted. | 411 // Returns whether it was deleted. |
| 411 bool DeleteFromPendingList(RenderFrameHostImpl* render_frame_host); | 412 bool DeleteFromPendingList(RenderFrameHostImpl* render_frame_host); |
| 412 | 413 |
| 413 // Deletes any proxy hosts associated with this node. Used during destruction | 414 // Deletes any proxy hosts associated with this node. Used during destruction |
| 414 // of WebContentsImpl. | 415 // of WebContentsImpl. |
| 415 void ResetProxyHosts(); | 416 void ResetProxyHosts(); |
| 416 | 417 |
| 417 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 418 // Returns the routing id for a RenderFrameHost or RenderFrameProxyHost |
|
nasko
2015/07/07 16:26:21
Nice catch!
| |
| 418 // that has the given SiteInstance and is associated with this | 419 // that has the given SiteInstance and is associated with this |
| 419 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 420 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
| 420 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 421 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
| 421 | 422 |
| 422 // PlzNavigate | 423 // PlzNavigate |
| 423 // Notifies the RenderFrameHostManager that a new NavigationRequest has been | 424 // Notifies the RenderFrameHostManager that a new NavigationRequest has been |
| 424 // created and set in the FrameTreeNode so that it can speculatively create a | 425 // created and set in the FrameTreeNode so that it can speculatively create a |
| 425 // new RenderFrameHost (and potentially a new process) if needed. | 426 // new RenderFrameHost (and potentially a new process) if needed. |
| 426 void DidCreateNavigationRequest(const NavigationRequest& request); | 427 void DidCreateNavigationRequest(const NavigationRequest& request); |
| 427 | 428 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 455 // origin. | 456 // origin. |
| 456 void OnDidUpdateOrigin(const url::Origin& origin); | 457 void OnDidUpdateOrigin(const url::Origin& origin); |
| 457 | 458 |
| 458 void EnsureRenderViewInitialized(RenderViewHostImpl* render_view_host, | 459 void EnsureRenderViewInitialized(RenderViewHostImpl* render_view_host, |
| 459 SiteInstance* instance); | 460 SiteInstance* instance); |
| 460 | 461 |
| 461 // Recursively creates swapped out RenderViews and RenderFrameProxies for | 462 // Recursively creates swapped out RenderViews and RenderFrameProxies for |
| 462 // this frame's FrameTree and for its opener chain in the given SiteInstance. | 463 // this frame's FrameTree and for its opener chain in the given SiteInstance. |
| 463 // This allows other tabs to send cross-process JavaScript calls to their | 464 // This allows other tabs to send cross-process JavaScript calls to their |
| 464 // opener(s) and to any other frames in the opener's FrameTree (e.g., | 465 // opener(s) and to any other frames in the opener's FrameTree (e.g., |
| 465 // supporting calls like window.opener.opener.frames[x][y]). Returns the | 466 // supporting calls like window.opener.opener.frames[x][y]). |
| 466 // route ID of this frame's RenderView for |instance|. | 467 void CreateOpenerProxies(SiteInstance* instance); |
| 467 // TODO(alexmos): Switch this to return RenderFrame routing IDs. | 468 |
| 468 int CreateOpenerProxies(SiteInstance* instance); | 469 // Returns a routing ID for the current FrameTreeNode's opener node in the |
| 470 // given SiteInstance. May return a routing ID of either a RenderFrame (if | |
|
nasko
2015/07/07 16:26:21
s/RenderFrame/RenderFrameHost/
alexmos
2015/07/08 04:42:18
Done.
| |
| 471 // opener's current or pending RFH has SiteInstance |instance|) or a | |
| 472 // RenderFrameProxy. Returns MSG_ROUTING_NONE if there is no opener, or if | |
|
nasko
2015/07/07 16:26:21
s/RenderFrameProxy/RenderFrameProxyHost/
alexmos
2015/07/08 04:42:18
Done.
| |
| 473 // the opener node doesn't have a proxy for |instance|. | |
| 474 int GetOpenerRoutingID(SiteInstance* instance); | |
| 469 | 475 |
| 470 // Called on the RFHM of the inner WebContents to create a | 476 // Called on the RFHM of the inner WebContents to create a |
| 471 // RenderFrameProxyHost in its outer WebContents's SiteInstance, | 477 // RenderFrameProxyHost in its outer WebContents's SiteInstance, |
| 472 // |outer_contents_site_instance|. The frame in outer WebContents that is | 478 // |outer_contents_site_instance|. The frame in outer WebContents that is |
| 473 // hosting the inner WebContents is |render_frame_host|, and the frame will | 479 // hosting the inner WebContents is |render_frame_host|, and the frame will |
| 474 // be swapped out with the proxy. | 480 // be swapped out with the proxy. |
| 475 void CreateOuterDelegateProxy(SiteInstance* outer_contents_site_instance, | 481 void CreateOuterDelegateProxy(SiteInstance* outer_contents_site_instance, |
| 476 RenderFrameHostImpl* render_frame_host); | 482 RenderFrameHostImpl* render_frame_host); |
| 477 | 483 |
| 478 // Sets the child RenderWidgetHostView for this frame, which must be part of | 484 // Sets the child RenderWidgetHostView for this frame, which must be part of |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 void CreatePendingRenderFrameHost(SiteInstance* old_instance, | 610 void CreatePendingRenderFrameHost(SiteInstance* old_instance, |
| 605 SiteInstance* new_instance, | 611 SiteInstance* new_instance, |
| 606 bool is_main_frame); | 612 bool is_main_frame); |
| 607 | 613 |
| 608 // Ensure that we have created all needed proxies for a new RFH with | 614 // Ensure that we have created all needed proxies for a new RFH with |
| 609 // SiteInstance |new_instance|: (1) create swapped-out RVHs and proxies for | 615 // SiteInstance |new_instance|: (1) create swapped-out RVHs and proxies for |
| 610 // the new RFH's opener chain if we are staying in the same BrowsingInstance; | 616 // the new RFH's opener chain if we are staying in the same BrowsingInstance; |
| 611 // (2) Create proxies for the new RFH's SiteInstance in its own frame tree; | 617 // (2) Create proxies for the new RFH's SiteInstance in its own frame tree; |
| 612 // (3) set any additional flags for the new RenderFrame with | 618 // (3) set any additional flags for the new RenderFrame with |
| 613 // |create_render_frame_flags|. | 619 // |create_render_frame_flags|. |
| 614 // Returns the opener's RVH route ID to be used for the new RenderFrame. | 620 void CreateProxiesForNewRenderFrameHost(SiteInstance* old_instance, |
| 615 // TODO(alexmos): switch this to return opener's RFH routing ID instead. | 621 SiteInstance* new_instance, |
| 616 int CreateProxiesForNewRenderFrameHost(SiteInstance* old_instance, | 622 int* create_render_frame_flags); |
| 617 SiteInstance* new_instance, | |
| 618 int* create_render_frame_flags); | |
| 619 | 623 |
| 620 // Create swapped out RenderViews and RenderFrameProxies in the given | 624 // Create swapped out RenderViews and RenderFrameProxies in the given |
| 621 // SiteInstance for all frames on the opener chain of this frame. Same as | 625 // SiteInstance for all frames on the opener chain of this frame. Same as |
| 622 // CreateOpenerProxies, but starts from this frame's opener, returning | 626 // CreateOpenerProxies, but starts from this frame's opener, calling |
| 623 // MSG_ROUTING_NONE if it doesn't exist, and calling CreateOpenerProxies if | 627 // CreateOpenerProxies on it if it exists and returning otherwise. |
| 624 // it does. | 628 void CreateOpenerProxiesIfNeeded(SiteInstance* instance); |
| 625 // TODO(alexmos): Switch this to return RenderFrame routing IDs. | |
| 626 int CreateOpenerProxiesIfNeeded(SiteInstance* instance); | |
| 627 | 629 |
| 628 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 630 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
| 629 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 631 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
| 630 int view_routing_id, | 632 int view_routing_id, |
| 631 int frame_routing_id, | 633 int frame_routing_id, |
| 632 int flags); | 634 int flags); |
| 633 | 635 |
| 634 // PlzNavigate | 636 // PlzNavigate |
| 635 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an | 637 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an |
| 636 // ongoing navigation. They might be destroyed and re-created later if the | 638 // ongoing navigation. They might be destroyed and re-created later if the |
| 637 // navigation is redirected to a different SiteInstance. | 639 // navigation is redirected to a different SiteInstance. |
| 638 bool CreateSpeculativeRenderFrameHost(const GURL& url, | 640 bool CreateSpeculativeRenderFrameHost(const GURL& url, |
| 639 SiteInstance* old_instance, | 641 SiteInstance* old_instance, |
| 640 SiteInstance* new_instance, | 642 SiteInstance* new_instance, |
| 641 int bindings); | 643 int bindings); |
| 642 | 644 |
| 643 // Sets up the necessary state for a new RenderViewHost with the given opener, | 645 // Sets up the necessary state for a new RenderViewHost. Creates a |
| 644 // if necessary. It creates a RenderFrameProxy in the target renderer process | 646 // RenderFrameProxy in the target renderer process with the given |
| 645 // with the given |proxy_routing_id|, which is used to route IPC messages when | 647 // |proxy_routing_id|, which is used to route IPC messages when in swapped |
| 646 // in swapped out state. Returns early if the RenderViewHost has already been | 648 // out state. Returns early if the RenderViewHost has already been |
| 647 // initialized for another RenderFrameHost. | 649 // initialized for another RenderFrameHost. If |suppress_opener| is true, |
| 648 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 650 // an opener won't be assigned for the RenderView's main frame. |
| 649 // be for the RenderFrame, since frames can have openers. | |
| 650 bool InitRenderView(RenderViewHostImpl* render_view_host, | 651 bool InitRenderView(RenderViewHostImpl* render_view_host, |
| 651 int opener_route_id, | |
| 652 int proxy_routing_id, | 652 int proxy_routing_id, |
| 653 bool for_main_frame_navigation); | 653 bool for_main_frame_navigation, |
| 654 bool suppress_opener); | |
| 654 | 655 |
| 655 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 656 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
| 656 // above. | 657 // above. |
| 657 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 658 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
| 658 | 659 |
| 659 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 660 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
| 660 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 661 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
| 661 // since there could be Web UI switching as well. Call this for every commit. | 662 // since there could be Web UI switching as well. Call this for every commit. |
| 662 // If PlzNavigate is enabled the method will set the speculative (not pending) | 663 // If PlzNavigate is enabled the method will set the speculative (not pending) |
| 663 // RenderFrameHost to be the active one. | 664 // RenderFrameHost to be the active one. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 bool should_reuse_web_ui_; | 803 bool should_reuse_web_ui_; |
| 803 | 804 |
| 804 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 805 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 805 | 806 |
| 806 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 807 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 807 }; | 808 }; |
| 808 | 809 |
| 809 } // namespace content | 810 } // namespace content |
| 810 | 811 |
| 811 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 812 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |