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. |
362 int CreateRenderFrameProxy(SiteInstance* instance); | 361 int CreateRenderFrameProxy(SiteInstance* instance); |
363 | 362 |
364 // Creates proxies for a new child frame at FrameTreeNode |child| in all | 363 // Creates proxies for a new child frame at FrameTreeNode |child| in all |
365 // SiteInstances for which the current frame has proxies. This method is | 364 // 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 | 365 // called on the parent of a new child frame before the child leaves the |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 bool IsPendingDeletion(RenderFrameHostImpl* render_frame_host); | 406 bool IsPendingDeletion(RenderFrameHostImpl* render_frame_host); |
408 | 407 |
409 // If |render_frame_host| is on the pending deletion list, this deletes it. | 408 // If |render_frame_host| is on the pending deletion list, this deletes it. |
410 // Returns whether it was deleted. | 409 // Returns whether it was deleted. |
411 bool DeleteFromPendingList(RenderFrameHostImpl* render_frame_host); | 410 bool DeleteFromPendingList(RenderFrameHostImpl* render_frame_host); |
412 | 411 |
413 // Deletes any proxy hosts associated with this node. Used during destruction | 412 // Deletes any proxy hosts associated with this node. Used during destruction |
414 // of WebContentsImpl. | 413 // of WebContentsImpl. |
415 void ResetProxyHosts(); | 414 void ResetProxyHosts(); |
416 | 415 |
417 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 416 // Returns the routing id for a RenderFrameHost or RenderFrameProxyHost |
418 // that has the given SiteInstance and is associated with this | 417 // that has the given SiteInstance and is associated with this |
419 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 418 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
420 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 419 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
421 | 420 |
422 // PlzNavigate | 421 // PlzNavigate |
423 // Notifies the RenderFrameHostManager that a new NavigationRequest has been | 422 // Notifies the RenderFrameHostManager that a new NavigationRequest has been |
424 // created and set in the FrameTreeNode so that it can speculatively create a | 423 // created and set in the FrameTreeNode so that it can speculatively create a |
425 // new RenderFrameHost (and potentially a new process) if needed. | 424 // new RenderFrameHost (and potentially a new process) if needed. |
426 void DidCreateNavigationRequest(const NavigationRequest& request); | 425 void DidCreateNavigationRequest(const NavigationRequest& request); |
427 | 426 |
(...skipping 27 matching lines...) Expand all Loading... |
455 // origin. | 454 // origin. |
456 void OnDidUpdateOrigin(const url::Origin& origin); | 455 void OnDidUpdateOrigin(const url::Origin& origin); |
457 | 456 |
458 void EnsureRenderViewInitialized(RenderViewHostImpl* render_view_host, | 457 void EnsureRenderViewInitialized(RenderViewHostImpl* render_view_host, |
459 SiteInstance* instance); | 458 SiteInstance* instance); |
460 | 459 |
461 // Recursively creates swapped out RenderViews and RenderFrameProxies for | 460 // Recursively creates swapped out RenderViews and RenderFrameProxies for |
462 // this frame's FrameTree and for its opener chain in the given SiteInstance. | 461 // 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 | 462 // 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., | 463 // 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 | 464 // supporting calls like window.opener.opener.frames[x][y]). |
466 // route ID of this frame's RenderView for |instance|. | 465 void CreateOpenerProxies(SiteInstance* instance); |
467 // TODO(alexmos): Switch this to return RenderFrame routing IDs. | 466 |
468 int CreateOpenerProxies(SiteInstance* instance); | 467 // Returns a routing ID for the current FrameTreeNode's opener node in the |
| 468 // given SiteInstance. May return a routing ID of either a RenderFrameHost |
| 469 // (if opener's current or pending RFH has SiteInstance |instance|) or a |
| 470 // RenderFrameProxyHost. Returns MSG_ROUTING_NONE if there is no opener, or |
| 471 // if the opener node doesn't have a proxy for |instance|. |
| 472 int GetOpenerRoutingID(SiteInstance* instance); |
469 | 473 |
470 // Called on the RFHM of the inner WebContents to create a | 474 // Called on the RFHM of the inner WebContents to create a |
471 // RenderFrameProxyHost in its outer WebContents's SiteInstance, | 475 // RenderFrameProxyHost in its outer WebContents's SiteInstance, |
472 // |outer_contents_site_instance|. The frame in outer WebContents that is | 476 // |outer_contents_site_instance|. The frame in outer WebContents that is |
473 // hosting the inner WebContents is |render_frame_host|, and the frame will | 477 // hosting the inner WebContents is |render_frame_host|, and the frame will |
474 // be swapped out with the proxy. | 478 // be swapped out with the proxy. |
475 void CreateOuterDelegateProxy(SiteInstance* outer_contents_site_instance, | 479 void CreateOuterDelegateProxy(SiteInstance* outer_contents_site_instance, |
476 RenderFrameHostImpl* render_frame_host); | 480 RenderFrameHostImpl* render_frame_host); |
477 | 481 |
478 // Sets the child RenderWidgetHostView for this frame, which must be part of | 482 // 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, | 608 void CreatePendingRenderFrameHost(SiteInstance* old_instance, |
605 SiteInstance* new_instance, | 609 SiteInstance* new_instance, |
606 bool is_main_frame); | 610 bool is_main_frame); |
607 | 611 |
608 // Ensure that we have created all needed proxies for a new RFH with | 612 // 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 | 613 // 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; | 614 // 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; | 615 // (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 | 616 // (3) set any additional flags for the new RenderFrame with |
613 // |create_render_frame_flags|. | 617 // |create_render_frame_flags|. |
614 // Returns the opener's RVH route ID to be used for the new RenderFrame. | 618 void CreateProxiesForNewRenderFrameHost(SiteInstance* old_instance, |
615 // TODO(alexmos): switch this to return opener's RFH routing ID instead. | 619 SiteInstance* new_instance, |
616 int CreateProxiesForNewRenderFrameHost(SiteInstance* old_instance, | 620 int* create_render_frame_flags); |
617 SiteInstance* new_instance, | |
618 int* create_render_frame_flags); | |
619 | 621 |
620 // Create swapped out RenderViews and RenderFrameProxies in the given | 622 // Create swapped out RenderViews and RenderFrameProxies in the given |
621 // SiteInstance for all frames on the opener chain of this frame. Same as | 623 // SiteInstance for all frames on the opener chain of this frame. Same as |
622 // CreateOpenerProxies, but starts from this frame's opener, returning | 624 // CreateOpenerProxies, but starts from this frame's opener, calling |
623 // MSG_ROUTING_NONE if it doesn't exist, and calling CreateOpenerProxies if | 625 // CreateOpenerProxies on it if it exists and returning otherwise. |
624 // it does. | 626 void CreateOpenerProxiesIfNeeded(SiteInstance* instance); |
625 // TODO(alexmos): Switch this to return RenderFrame routing IDs. | |
626 int CreateOpenerProxiesIfNeeded(SiteInstance* instance); | |
627 | 627 |
628 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 628 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
629 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 629 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
630 int view_routing_id, | 630 int view_routing_id, |
631 int frame_routing_id, | 631 int frame_routing_id, |
632 int flags); | 632 int flags); |
633 | 633 |
634 // PlzNavigate | 634 // PlzNavigate |
635 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an | 635 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an |
636 // ongoing navigation. They might be destroyed and re-created later if the | 636 // ongoing navigation. They might be destroyed and re-created later if the |
637 // navigation is redirected to a different SiteInstance. | 637 // navigation is redirected to a different SiteInstance. |
638 bool CreateSpeculativeRenderFrameHost(const GURL& url, | 638 bool CreateSpeculativeRenderFrameHost(const GURL& url, |
639 SiteInstance* old_instance, | 639 SiteInstance* old_instance, |
640 SiteInstance* new_instance, | 640 SiteInstance* new_instance, |
641 int bindings); | 641 int bindings); |
642 | 642 |
643 // Sets up the necessary state for a new RenderViewHost with the given opener, | 643 // Sets up the necessary state for a new RenderViewHost. Creates a |
644 // if necessary. It creates a RenderFrameProxy in the target renderer process | 644 // RenderFrameProxy in the target renderer process with the given |
645 // with the given |proxy_routing_id|, which is used to route IPC messages when | 645 // |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 | 646 // out state. Returns early if the RenderViewHost has already been |
647 // initialized for another RenderFrameHost. | 647 // initialized for another RenderFrameHost. |
648 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | |
649 // be for the RenderFrame, since frames can have openers. | |
650 bool InitRenderView(RenderViewHostImpl* render_view_host, | 648 bool InitRenderView(RenderViewHostImpl* render_view_host, |
651 int opener_route_id, | |
652 int proxy_routing_id, | 649 int proxy_routing_id, |
653 bool for_main_frame_navigation); | 650 bool for_main_frame_navigation); |
654 | 651 |
655 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 652 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
656 // above. | 653 // above. |
657 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 654 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
658 | 655 |
659 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 656 // 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, | 657 // 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. | 658 // since there could be Web UI switching as well. Call this for every commit. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 bool should_reuse_web_ui_; | 799 bool should_reuse_web_ui_; |
803 | 800 |
804 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 801 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
805 | 802 |
806 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 803 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
807 }; | 804 }; |
808 | 805 |
809 } // namespace content | 806 } // namespace content |
810 | 807 |
811 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 808 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |