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 #include "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 | 390 |
391 // If the current render_frame_host_ isn't live, we should create it so | 391 // If the current render_frame_host_ isn't live, we should create it so |
392 // that we don't show a sad tab while the dest_render_frame_host fetches | 392 // that we don't show a sad tab while the dest_render_frame_host fetches |
393 // its first page. (Bug 1145340) | 393 // its first page. (Bug 1145340) |
394 if (dest_render_frame_host != render_frame_host_ && | 394 if (dest_render_frame_host != render_frame_host_ && |
395 !render_frame_host_->IsRenderFrameLive()) { | 395 !render_frame_host_->IsRenderFrameLive()) { |
396 // Note: we don't call InitRenderView here because we are navigating away | 396 // Note: we don't call InitRenderView here because we are navigating away |
397 // soon anyway, and we don't have the NavigationEntry for this host. | 397 // soon anyway, and we don't have the NavigationEntry for this host. |
398 delegate_->CreateRenderViewForRenderManager( | 398 delegate_->CreateRenderViewForRenderManager( |
399 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, | 399 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, |
400 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state(), | 400 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state()); |
401 frame_tree_node_->IsMainFrame()); | |
402 } | 401 } |
403 | 402 |
404 // If the renderer crashed, then try to create a new one to satisfy this | 403 // If the renderer crashed, then try to create a new one to satisfy this |
405 // navigation request. | 404 // navigation request. |
406 if (!dest_render_frame_host->IsRenderFrameLive()) { | 405 if (!dest_render_frame_host->IsRenderFrameLive()) { |
407 // Instruct the destination render frame host to set up a Mojo connection | 406 // Instruct the destination render frame host to set up a Mojo connection |
408 // with the new render frame if necessary. Note that this call needs to | 407 // with the new render frame if necessary. Note that this call needs to |
409 // occur before initializing the RenderView; the flow of creating the | 408 // occur before initializing the RenderView; the flow of creating the |
410 // RenderView can cause browser-side code to execute that expects the this | 409 // RenderView can cause browser-side code to execute that expects the this |
411 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI | 410 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI |
412 // site that is handled via Mojo, then Mojo WebUI code in //chrome will | 411 // site that is handled via Mojo, then Mojo WebUI code in //chrome will |
413 // add a service to this RFH's ServiceRegistry). | 412 // add a service to this RFH's ServiceRegistry). |
414 dest_render_frame_host->SetUpMojoIfNeeded(); | 413 dest_render_frame_host->SetUpMojoIfNeeded(); |
415 | 414 |
416 // Recreate the opener chain. | 415 // Recreate the opener chain. |
417 CreateOpenerProxiesIfNeeded(dest_render_frame_host->GetSiteInstance()); | 416 CreateOpenerProxiesIfNeeded(dest_render_frame_host->GetSiteInstance()); |
418 if (!InitRenderView(dest_render_frame_host->render_view_host(), | 417 if (!InitRenderView(dest_render_frame_host->render_view_host(), |
419 MSG_ROUTING_NONE, | 418 MSG_ROUTING_NONE)) |
420 frame_tree_node_->IsMainFrame())) | |
421 return nullptr; | 419 return nullptr; |
422 | 420 |
423 // Now that we've created a new renderer, be sure to hide it if it isn't | 421 // Now that we've created a new renderer, be sure to hide it if it isn't |
424 // our primary one. Otherwise, we might crash if we try to call Show() | 422 // our primary one. Otherwise, we might crash if we try to call Show() |
425 // on it later. | 423 // on it later. |
426 if (dest_render_frame_host != render_frame_host_) { | 424 if (dest_render_frame_host != render_frame_host_) { |
427 if (dest_render_frame_host->GetView()) | 425 if (dest_render_frame_host->GetView()) |
428 dest_render_frame_host->GetView()->Hide(); | 426 dest_render_frame_host->GetView()->Hide(); |
429 } else { | 427 } else { |
430 // TODO(nasko): This is a very ugly hack. The Chrome extensions process | 428 // TODO(nasko): This is a very ugly hack. The Chrome extensions process |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1033 } | 1031 } |
1034 DCHECK(navigation_rfh && | 1032 DCHECK(navigation_rfh && |
1035 (navigation_rfh == render_frame_host_.get() || | 1033 (navigation_rfh == render_frame_host_.get() || |
1036 navigation_rfh == speculative_render_frame_host_.get())); | 1034 navigation_rfh == speculative_render_frame_host_.get())); |
1037 | 1035 |
1038 // If the RenderFrame that needs to navigate is not live (its process was just | 1036 // If the RenderFrame that needs to navigate is not live (its process was just |
1039 // created or has crashed), initialize it. | 1037 // created or has crashed), initialize it. |
1040 if (!navigation_rfh->IsRenderFrameLive()) { | 1038 if (!navigation_rfh->IsRenderFrameLive()) { |
1041 // Recreate the opener chain. | 1039 // Recreate the opener chain. |
1042 CreateOpenerProxiesIfNeeded(navigation_rfh->GetSiteInstance()); | 1040 CreateOpenerProxiesIfNeeded(navigation_rfh->GetSiteInstance()); |
1043 if (!InitRenderView(navigation_rfh->render_view_host(), MSG_ROUTING_NONE, | 1041 if (!InitRenderView(navigation_rfh->render_view_host(), MSG_ROUTING_NONE)) { |
1044 frame_tree_node_->IsMainFrame())) { | |
1045 return nullptr; | 1042 return nullptr; |
1046 } | 1043 } |
1047 | 1044 |
1048 if (navigation_rfh == render_frame_host_) { | 1045 if (navigation_rfh == render_frame_host_) { |
1049 // TODO(nasko): This is a very ugly hack. The Chrome extensions process | 1046 // TODO(nasko): This is a very ugly hack. The Chrome extensions process |
1050 // manager still uses NotificationService and expects to see a | 1047 // manager still uses NotificationService and expects to see a |
1051 // RenderViewHost changed notification after WebContents and | 1048 // RenderViewHost changed notification after WebContents and |
1052 // RenderFrameHostManager are completely initialized. This should be | 1049 // RenderFrameHostManager are completely initialized. This should be |
1053 // removed once the process manager moves away from NotificationService. | 1050 // removed once the process manager moves away from NotificationService. |
1054 // See https://crbug.com/462682. | 1051 // See https://crbug.com/462682. |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 // to open a new tab to an interstitial-inducing URL, and then navigates | 1534 // to open a new tab to an interstitial-inducing URL, and then navigates |
1538 // the page to a different same-site URL. (This seems very unlikely in | 1535 // the page to a different same-site URL. (This seems very unlikely in |
1539 // practice.) | 1536 // practice.) |
1540 if (current_entry) | 1537 if (current_entry) |
1541 return current_entry->GetURL(); | 1538 return current_entry->GetURL(); |
1542 return current_instance->GetSiteURL(); | 1539 return current_instance->GetSiteURL(); |
1543 } | 1540 } |
1544 | 1541 |
1545 void RenderFrameHostManager::CreatePendingRenderFrameHost( | 1542 void RenderFrameHostManager::CreatePendingRenderFrameHost( |
1546 SiteInstance* old_instance, | 1543 SiteInstance* old_instance, |
1547 SiteInstance* new_instance, | 1544 SiteInstance* new_instance) { |
1548 bool is_main_frame) { | |
1549 int create_render_frame_flags = 0; | 1545 int create_render_frame_flags = 0; |
1550 if (is_main_frame) | |
1551 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | |
1552 | |
1553 if (delegate_->IsHidden()) | 1546 if (delegate_->IsHidden()) |
1554 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1547 create_render_frame_flags |= CREATE_RF_HIDDEN; |
1555 | 1548 |
1556 if (pending_render_frame_host_) | 1549 if (pending_render_frame_host_) |
1557 CancelPending(); | 1550 CancelPending(); |
1558 | 1551 |
1559 // The process for the new SiteInstance may (if we're sharing a process with | 1552 // The process for the new SiteInstance may (if we're sharing a process with |
1560 // another host that already initialized it) or may not (we have our own | 1553 // another host that already initialized it) or may not (we have our own |
1561 // process or the existing process crashed) have been initialized. Calling | 1554 // process or the existing process crashed) have been initialized. Calling |
1562 // Init multiple times will be ignored, so this is safe. | 1555 // Init multiple times will be ignored, so this is safe. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1675 // another host that already initialized it) or may not (we have our own | 1668 // another host that already initialized it) or may not (we have our own |
1676 // process or the existing process crashed) have been initialized. Calling | 1669 // process or the existing process crashed) have been initialized. Calling |
1677 // Init multiple times will be ignored, so this is safe. | 1670 // Init multiple times will be ignored, so this is safe. |
1678 if (!new_instance->GetProcess()->Init()) | 1671 if (!new_instance->GetProcess()->Init()) |
1679 return false; | 1672 return false; |
1680 | 1673 |
1681 int create_render_frame_flags = 0; | 1674 int create_render_frame_flags = 0; |
1682 CreateProxiesForNewRenderFrameHost(old_instance, new_instance, | 1675 CreateProxiesForNewRenderFrameHost(old_instance, new_instance, |
1683 &create_render_frame_flags); | 1676 &create_render_frame_flags); |
1684 | 1677 |
1685 if (frame_tree_node_->IsMainFrame()) | |
1686 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | |
1687 if (delegate_->IsHidden()) | 1678 if (delegate_->IsHidden()) |
1688 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1679 create_render_frame_flags |= CREATE_RF_HIDDEN; |
1689 speculative_render_frame_host_ = | 1680 speculative_render_frame_host_ = |
1690 CreateRenderFrame(new_instance, speculative_web_ui_.get(), | 1681 CreateRenderFrame(new_instance, speculative_web_ui_.get(), |
1691 create_render_frame_flags, nullptr); | 1682 create_render_frame_flags, nullptr); |
1692 | 1683 |
1693 if (!speculative_render_frame_host_) { | 1684 if (!speculative_render_frame_host_) { |
1694 speculative_web_ui_.reset(); | 1685 speculative_web_ui_.reset(); |
1695 return false; | 1686 return false; |
1696 } | 1687 } |
(...skipping 24 matching lines...) Expand all Loading... | |
1721 | 1712 |
1722 // We are creating a pending, speculative or swapped out RFH here. We should | 1713 // We are creating a pending, speculative or swapped out RFH here. We should |
1723 // never create it in the same SiteInstance as our current RFH. | 1714 // never create it in the same SiteInstance as our current RFH. |
1724 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 1715 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
1725 | 1716 |
1726 // Check if we've already created an RFH for this SiteInstance. If so, try | 1717 // Check if we've already created an RFH for this SiteInstance. If so, try |
1727 // to re-use the existing one, which has already been initialized. We'll | 1718 // to re-use the existing one, which has already been initialized. We'll |
1728 // remove it from the list of proxy hosts below if it will be active. | 1719 // remove it from the list of proxy hosts below if it will be active. |
1729 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1720 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1730 if (proxy && proxy->render_frame_host()) { | 1721 if (proxy && proxy->render_frame_host()) { |
1722 RenderViewHost* render_view_host = proxy->GetRenderViewHost(); | |
1731 CHECK(!swapped_out_forbidden); | 1723 CHECK(!swapped_out_forbidden); |
1732 if (view_routing_id_ptr) | 1724 if (view_routing_id_ptr) |
1733 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); | 1725 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); |
1734 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 1726 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
1735 // Prevent the process from exiting while we're trying to use it. | 1727 // Prevent the process from exiting while we're trying to use it. |
1736 if (!swapped_out) { | 1728 if (!swapped_out) { |
1737 new_render_frame_host = proxy->PassFrameHostOwnership(); | 1729 new_render_frame_host = proxy->PassFrameHostOwnership(); |
1738 new_render_frame_host->GetProcess()->AddPendingView(); | 1730 new_render_frame_host->GetProcess()->AddPendingView(); |
1739 | 1731 |
1740 proxy_hosts_->Remove(instance->GetId()); | 1732 proxy_hosts_->Remove(instance->GetId()); |
1741 // NB |proxy| is deleted at this point. | 1733 // NB |proxy| is deleted at this point. |
1742 } | 1734 } |
1735 if (!render_view_host->GetView()) { | |
1736 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host, | |
1737 false); | |
Charlie Reis
2015/08/31 19:02:51
How do we know main_frame_is_proxy is false? This
lfg
2015/09/02 00:32:16
You're right, we don't know that. What ends up hap
| |
1738 } | |
1743 } else { | 1739 } else { |
1744 // Create a new RenderFrameHost if we don't find an existing one. | 1740 // Create a new RenderFrameHost if we don't find an existing one. |
1745 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, | 1741 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, |
1746 MSG_ROUTING_NONE, flags); | 1742 MSG_ROUTING_NONE, flags); |
1747 RenderViewHostImpl* render_view_host = | 1743 RenderViewHostImpl* render_view_host = |
1748 new_render_frame_host->render_view_host(); | 1744 new_render_frame_host->render_view_host(); |
1749 int proxy_routing_id = MSG_ROUTING_NONE; | 1745 int proxy_routing_id = MSG_ROUTING_NONE; |
1750 | 1746 |
1751 // Prevent the process from exiting while we're trying to navigate in it. | 1747 // Prevent the process from exiting while we're trying to navigate in it. |
1752 // Otherwise, if the new RFH is swapped out already, store it. | 1748 // Otherwise, if the new RFH is swapped out already, store it. |
1753 if (!swapped_out) { | 1749 if (!swapped_out) { |
1754 new_render_frame_host->GetProcess()->AddPendingView(); | 1750 new_render_frame_host->GetProcess()->AddPendingView(); |
1755 } else { | 1751 } else { |
1756 proxy = new RenderFrameProxyHost( | 1752 proxy = new RenderFrameProxyHost( |
1757 new_render_frame_host->GetSiteInstance(), | 1753 new_render_frame_host->GetSiteInstance(), |
1758 new_render_frame_host->render_view_host(), frame_tree_node_); | 1754 new_render_frame_host->render_view_host(), frame_tree_node_); |
1759 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); | 1755 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); |
1760 proxy_routing_id = proxy->GetRoutingID(); | 1756 proxy_routing_id = proxy->GetRoutingID(); |
1761 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 1757 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
1762 } | 1758 } |
1763 | 1759 |
1764 success = InitRenderView(render_view_host, proxy_routing_id, | 1760 success = InitRenderView(render_view_host, proxy_routing_id); |
1765 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); | 1761 if (proxy_routing_id == MSG_ROUTING_NONE && !render_view_host->GetView()) { |
Charlie Reis
2015/08/31 19:02:51
Maybe using |!swapped_out| would be clearer than |
lfg
2015/09/02 00:32:16
Done.
| |
1762 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host, | |
1763 false); | |
Charlie Reis
2015/08/31 19:02:51
Again, this could be a subframe, so I'm not sure h
lfg
2015/09/02 00:32:16
Same as above. I've added a IsMainFrame() check, w
| |
1764 } | |
1765 | |
1766 if (success) { | 1766 if (success) { |
1767 // Remember that InitRenderView also created the RenderFrameProxy. | 1767 // Remember that InitRenderView also created the RenderFrameProxy. |
1768 if (swapped_out) | 1768 if (swapped_out) |
1769 proxy->set_render_frame_proxy_created(true); | 1769 proxy->set_render_frame_proxy_created(true); |
1770 if (frame_tree_node_->IsMainFrame()) { | 1770 if (frame_tree_node_->IsMainFrame()) { |
1771 // Don't show the main frame's view until we get a DidNavigate from it. | 1771 // Don't show the main frame's view until we get a DidNavigate from it. |
1772 // Only the RenderViewHost for the top-level RenderFrameHost has a | 1772 // Only the RenderViewHost for the top-level RenderFrameHost has a |
1773 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes | 1773 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes |
1774 // will be created later and hidden. | 1774 // will be created later and hidden. |
1775 if (render_view_host->GetView()) | 1775 if (render_view_host->GetView()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1840 return proxy->GetRoutingID(); | 1840 return proxy->GetRoutingID(); |
1841 | 1841 |
1842 if (!proxy) { | 1842 if (!proxy) { |
1843 proxy = | 1843 proxy = |
1844 new RenderFrameProxyHost(instance, render_view_host, frame_tree_node_); | 1844 new RenderFrameProxyHost(instance, render_view_host, frame_tree_node_); |
1845 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); | 1845 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); |
1846 } | 1846 } |
1847 | 1847 |
1848 if (SiteIsolationPolicy::IsSwappedOutStateForbidden() && | 1848 if (SiteIsolationPolicy::IsSwappedOutStateForbidden() && |
1849 frame_tree_node_->IsMainFrame()) { | 1849 frame_tree_node_->IsMainFrame()) { |
1850 InitRenderView(render_view_host, proxy->GetRoutingID(), true); | 1850 InitRenderView(render_view_host, proxy->GetRoutingID()); |
1851 proxy->set_render_frame_proxy_created(true); | 1851 proxy->set_render_frame_proxy_created(true); |
1852 } else { | 1852 } else { |
1853 proxy->InitRenderFrameProxy(); | 1853 proxy->InitRenderFrameProxy(); |
1854 } | 1854 } |
1855 | 1855 |
1856 return proxy->GetRoutingID(); | 1856 return proxy->GetRoutingID(); |
1857 } | 1857 } |
1858 | 1858 |
1859 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { | 1859 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { |
1860 for (const auto& pair : *proxy_hosts_) { | 1860 for (const auto& pair : *proxy_hosts_) { |
(...skipping 17 matching lines...) Expand all Loading... | |
1878 | 1878 |
1879 // Recreate the opener chain. | 1879 // Recreate the opener chain. |
1880 CreateOpenerProxiesIfNeeded(instance); | 1880 CreateOpenerProxiesIfNeeded(instance); |
1881 | 1881 |
1882 // If the proxy in |instance| doesn't exist, this RenderView is not swapped | 1882 // If the proxy in |instance| doesn't exist, this RenderView is not swapped |
1883 // out and shouldn't be reinitialized here. | 1883 // out and shouldn't be reinitialized here. |
1884 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1884 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1885 if (!proxy) | 1885 if (!proxy) |
1886 return; | 1886 return; |
1887 | 1887 |
1888 InitRenderView(render_view_host, proxy->GetRoutingID(), false); | 1888 InitRenderView(render_view_host, proxy->GetRoutingID()); |
1889 proxy->set_render_frame_proxy_created(true); | 1889 proxy->set_render_frame_proxy_created(true); |
1890 } | 1890 } |
1891 | 1891 |
1892 void RenderFrameHostManager::CreateOuterDelegateProxy( | 1892 void RenderFrameHostManager::CreateOuterDelegateProxy( |
1893 SiteInstance* outer_contents_site_instance, | 1893 SiteInstance* outer_contents_site_instance, |
1894 RenderFrameHostImpl* render_frame_host) { | 1894 RenderFrameHostImpl* render_frame_host) { |
1895 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1895 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
1896 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 1896 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
1897 outer_contents_site_instance, nullptr, frame_tree_node_); | 1897 outer_contents_site_instance, nullptr, frame_tree_node_); |
1898 proxy_hosts_->Add(outer_contents_site_instance->GetId(), | 1898 proxy_hosts_->Add(outer_contents_site_instance->GetId(), |
(...skipping 14 matching lines...) Expand all Loading... | |
1913 } | 1913 } |
1914 | 1914 |
1915 void RenderFrameHostManager::SetRWHViewForInnerContents( | 1915 void RenderFrameHostManager::SetRWHViewForInnerContents( |
1916 RenderWidgetHostView* child_rwhv) { | 1916 RenderWidgetHostView* child_rwhv) { |
1917 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame()); | 1917 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame()); |
1918 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv); | 1918 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv); |
1919 } | 1919 } |
1920 | 1920 |
1921 bool RenderFrameHostManager::InitRenderView( | 1921 bool RenderFrameHostManager::InitRenderView( |
1922 RenderViewHostImpl* render_view_host, | 1922 RenderViewHostImpl* render_view_host, |
1923 int proxy_routing_id, | 1923 int proxy_routing_id) { |
1924 bool for_main_frame_navigation) { | |
1925 // Ensure the renderer process is initialized before creating the | 1924 // Ensure the renderer process is initialized before creating the |
1926 // RenderView. | 1925 // RenderView. |
1927 if (!render_view_host->GetProcess()->Init()) | 1926 if (!render_view_host->GetProcess()->Init()) |
1928 return false; | 1927 return false; |
1929 | 1928 |
1930 // We may have initialized this RenderViewHost for another RenderFrameHost. | 1929 // We may have initialized this RenderViewHost for another RenderFrameHost. |
1931 if (render_view_host->IsRenderViewLive()) | 1930 if (render_view_host->IsRenderViewLive()) |
1932 return true; | 1931 return true; |
1933 | 1932 |
1934 // If the ongoing navigation is to a WebUI and the RenderView is not in a | 1933 // If the ongoing navigation is to a WebUI and the RenderView is not in a |
(...skipping 16 matching lines...) Expand all Loading... | |
1951 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 1950 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
1952 render_view_host->GetProcess()->GetID())); | 1951 render_view_host->GetProcess()->GetID())); |
1953 } | 1952 } |
1954 } | 1953 } |
1955 | 1954 |
1956 int opener_frame_routing_id = | 1955 int opener_frame_routing_id = |
1957 GetOpenerRoutingID(render_view_host->GetSiteInstance()); | 1956 GetOpenerRoutingID(render_view_host->GetSiteInstance()); |
1958 | 1957 |
1959 return delegate_->CreateRenderViewForRenderManager( | 1958 return delegate_->CreateRenderViewForRenderManager( |
1960 render_view_host, opener_frame_routing_id, proxy_routing_id, | 1959 render_view_host, opener_frame_routing_id, proxy_routing_id, |
1961 frame_tree_node_->current_replication_state(), for_main_frame_navigation); | 1960 frame_tree_node_->current_replication_state()); |
1962 } | 1961 } |
1963 | 1962 |
1964 bool RenderFrameHostManager::InitRenderFrame( | 1963 bool RenderFrameHostManager::InitRenderFrame( |
1965 RenderFrameHostImpl* render_frame_host) { | 1964 RenderFrameHostImpl* render_frame_host) { |
1966 if (render_frame_host->IsRenderFrameLive()) | 1965 if (render_frame_host->IsRenderFrameLive()) |
1967 return true; | 1966 return true; |
1968 | 1967 |
1969 int parent_routing_id = MSG_ROUTING_NONE; | 1968 int parent_routing_id = MSG_ROUTING_NONE; |
1970 int previous_sibling_routing_id = MSG_ROUTING_NONE; | 1969 int previous_sibling_routing_id = MSG_ROUTING_NONE; |
1971 int proxy_routing_id = MSG_ROUTING_NONE; | 1970 int proxy_routing_id = MSG_ROUTING_NONE; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2261 | 2260 |
2262 // New SiteInstance: create a pending RFH to navigate. | 2261 // New SiteInstance: create a pending RFH to navigate. |
2263 | 2262 |
2264 // This will possibly create (set to nullptr) a Web UI object for the | 2263 // This will possibly create (set to nullptr) a Web UI object for the |
2265 // pending page. We'll use this later to give the page special access. This | 2264 // pending page. We'll use this later to give the page special access. This |
2266 // must happen before the new renderer is created below so it will get | 2265 // must happen before the new renderer is created below so it will get |
2267 // bindings. It must also happen after the above conditional call to | 2266 // bindings. It must also happen after the above conditional call to |
2268 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_ | 2267 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_ |
2269 // and the page will not have its bindings set appropriately. | 2268 // and the page will not have its bindings set appropriately. |
2270 SetPendingWebUI(dest_url, bindings); | 2269 SetPendingWebUI(dest_url, bindings); |
2271 CreatePendingRenderFrameHost(current_instance, new_instance.get(), | 2270 CreatePendingRenderFrameHost(current_instance, new_instance.get()); |
2272 frame_tree_node_->IsMainFrame()); | |
2273 if (!pending_render_frame_host_) | 2271 if (!pending_render_frame_host_) |
2274 return nullptr; | 2272 return nullptr; |
2275 | 2273 |
2276 // Check if our current RFH is live before we set up a transition. | 2274 // Check if our current RFH is live before we set up a transition. |
2277 if (!render_frame_host_->IsRenderFrameLive()) { | 2275 if (!render_frame_host_->IsRenderFrameLive()) { |
2278 // The current RFH is not live. There's no reason to sit around with a | 2276 // The current RFH is not live. There's no reason to sit around with a |
2279 // sad tab or a newly created RFH while we wait for the pending RFH to | 2277 // sad tab or a newly created RFH while we wait for the pending RFH to |
2280 // navigate. Just switch to the pending RFH now and go back to normal. | 2278 // navigate. Just switch to the pending RFH now and go back to normal. |
2281 // (Note that we don't care about on{before}unload handlers if the current | 2279 // (Note that we don't care about on{before}unload handlers if the current |
2282 // RFH isn't live.) | 2280 // RFH isn't live.) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2543 // Ensure that all the nodes in the opener's frame tree have | 2541 // Ensure that all the nodes in the opener's frame tree have |
2544 // RenderFrameProxyHosts for the new SiteInstance. | 2542 // RenderFrameProxyHosts for the new SiteInstance. |
2545 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); | 2543 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); |
2546 } else if (rvh && !rvh->IsRenderViewLive()) { | 2544 } else if (rvh && !rvh->IsRenderViewLive()) { |
2547 EnsureRenderViewInitialized(rvh, instance); | 2545 EnsureRenderViewInitialized(rvh, instance); |
2548 } else { | 2546 } else { |
2549 // Create a swapped out RenderView in the given SiteInstance if none exists, | 2547 // Create a swapped out RenderView in the given SiteInstance if none exists, |
2550 // setting its opener to the given route_id. Since the opener can point to | 2548 // setting its opener to the given route_id. Since the opener can point to |
2551 // a subframe, do this on the root frame of the opener's frame tree. | 2549 // a subframe, do this on the root frame of the opener's frame tree. |
2552 // Return the new view's route_id. | 2550 // Return the new view's route_id. |
2553 frame_tree->root()->render_manager()-> | 2551 frame_tree->root()->render_manager()->CreateRenderFrame( |
2554 CreateRenderFrame(instance, nullptr, | 2552 instance, nullptr, CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr); |
2555 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | | |
2556 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, | |
2557 nullptr); | |
2558 } | 2553 } |
2559 } | 2554 } |
2560 | 2555 |
2561 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2556 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
2562 if (!frame_tree_node_->opener()) | 2557 if (!frame_tree_node_->opener()) |
2563 return MSG_ROUTING_NONE; | 2558 return MSG_ROUTING_NONE; |
2564 | 2559 |
2565 return frame_tree_node_->opener() | 2560 return frame_tree_node_->opener() |
2566 ->render_manager() | 2561 ->render_manager() |
2567 ->GetRoutingIdForSiteInstance(instance); | 2562 ->GetRoutingIdForSiteInstance(instance); |
2568 } | 2563 } |
2569 | 2564 |
2570 } // namespace content | 2565 } // namespace content |
OLD | NEW |