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 #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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1010 } | 1008 } |
| 1011 DCHECK(navigation_rfh && | 1009 DCHECK(navigation_rfh && |
| 1012 (navigation_rfh == render_frame_host_.get() || | 1010 (navigation_rfh == render_frame_host_.get() || |
| 1013 navigation_rfh == speculative_render_frame_host_.get())); | 1011 navigation_rfh == speculative_render_frame_host_.get())); |
| 1014 | 1012 |
| 1015 // If the RenderFrame that needs to navigate is not live (its process was just | 1013 // If the RenderFrame that needs to navigate is not live (its process was just |
| 1016 // created or has crashed), initialize it. | 1014 // created or has crashed), initialize it. |
| 1017 if (!navigation_rfh->IsRenderFrameLive()) { | 1015 if (!navigation_rfh->IsRenderFrameLive()) { |
| 1018 // Recreate the opener chain. | 1016 // Recreate the opener chain. |
| 1019 CreateOpenerProxiesIfNeeded(navigation_rfh->GetSiteInstance()); | 1017 CreateOpenerProxiesIfNeeded(navigation_rfh->GetSiteInstance()); |
| 1020 if (!InitRenderView(navigation_rfh->render_view_host(), MSG_ROUTING_NONE, | 1018 if (!InitRenderView(navigation_rfh->render_view_host(), MSG_ROUTING_NONE)) { |
| 1021 frame_tree_node_->IsMainFrame())) { | |
| 1022 return nullptr; | 1019 return nullptr; |
| 1023 } | 1020 } |
| 1024 | 1021 |
| 1025 if (navigation_rfh == render_frame_host_) { | 1022 if (navigation_rfh == render_frame_host_) { |
| 1026 // TODO(nasko): This is a very ugly hack. The Chrome extensions process | 1023 // TODO(nasko): This is a very ugly hack. The Chrome extensions process |
| 1027 // manager still uses NotificationService and expects to see a | 1024 // manager still uses NotificationService and expects to see a |
| 1028 // RenderViewHost changed notification after WebContents and | 1025 // RenderViewHost changed notification after WebContents and |
| 1029 // RenderFrameHostManager are completely initialized. This should be | 1026 // RenderFrameHostManager are completely initialized. This should be |
| 1030 // removed once the process manager moves away from NotificationService. | 1027 // removed once the process manager moves away from NotificationService. |
| 1031 // See https://crbug.com/462682. | 1028 // See https://crbug.com/462682. |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1514 // to open a new tab to an interstitial-inducing URL, and then navigates | 1511 // to open a new tab to an interstitial-inducing URL, and then navigates |
| 1515 // the page to a different same-site URL. (This seems very unlikely in | 1512 // the page to a different same-site URL. (This seems very unlikely in |
| 1516 // practice.) | 1513 // practice.) |
| 1517 if (current_entry) | 1514 if (current_entry) |
| 1518 return current_entry->GetURL(); | 1515 return current_entry->GetURL(); |
| 1519 return current_instance->GetSiteURL(); | 1516 return current_instance->GetSiteURL(); |
| 1520 } | 1517 } |
| 1521 | 1518 |
| 1522 void RenderFrameHostManager::CreatePendingRenderFrameHost( | 1519 void RenderFrameHostManager::CreatePendingRenderFrameHost( |
| 1523 SiteInstance* old_instance, | 1520 SiteInstance* old_instance, |
| 1524 SiteInstance* new_instance, | 1521 SiteInstance* new_instance) { |
| 1525 bool is_main_frame) { | |
| 1526 int create_render_frame_flags = 0; | 1522 int create_render_frame_flags = 0; |
| 1527 if (is_main_frame) | |
| 1528 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | |
| 1529 | |
| 1530 if (delegate_->IsHidden()) | 1523 if (delegate_->IsHidden()) |
| 1531 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1524 create_render_frame_flags |= CREATE_RF_HIDDEN; |
| 1532 | 1525 |
| 1533 if (pending_render_frame_host_) | 1526 if (pending_render_frame_host_) |
| 1534 CancelPending(); | 1527 CancelPending(); |
| 1535 | 1528 |
| 1536 // The process for the new SiteInstance may (if we're sharing a process with | 1529 // The process for the new SiteInstance may (if we're sharing a process with |
| 1537 // another host that already initialized it) or may not (we have our own | 1530 // another host that already initialized it) or may not (we have our own |
| 1538 // process or the existing process crashed) have been initialized. Calling | 1531 // process or the existing process crashed) have been initialized. Calling |
| 1539 // Init multiple times will be ignored, so this is safe. | 1532 // Init multiple times will be ignored, so this is safe. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1652 // another host that already initialized it) or may not (we have our own | 1645 // another host that already initialized it) or may not (we have our own |
| 1653 // process or the existing process crashed) have been initialized. Calling | 1646 // process or the existing process crashed) have been initialized. Calling |
| 1654 // Init multiple times will be ignored, so this is safe. | 1647 // Init multiple times will be ignored, so this is safe. |
| 1655 if (!new_instance->GetProcess()->Init()) | 1648 if (!new_instance->GetProcess()->Init()) |
| 1656 return false; | 1649 return false; |
| 1657 | 1650 |
| 1658 int create_render_frame_flags = 0; | 1651 int create_render_frame_flags = 0; |
| 1659 CreateProxiesForNewRenderFrameHost(old_instance, new_instance, | 1652 CreateProxiesForNewRenderFrameHost(old_instance, new_instance, |
| 1660 &create_render_frame_flags); | 1653 &create_render_frame_flags); |
| 1661 | 1654 |
| 1662 if (frame_tree_node_->IsMainFrame()) | |
| 1663 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | |
| 1664 if (delegate_->IsHidden()) | 1655 if (delegate_->IsHidden()) |
| 1665 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1656 create_render_frame_flags |= CREATE_RF_HIDDEN; |
| 1666 speculative_render_frame_host_ = | 1657 speculative_render_frame_host_ = |
| 1667 CreateRenderFrame(new_instance, speculative_web_ui_.get(), | 1658 CreateRenderFrame(new_instance, speculative_web_ui_.get(), |
| 1668 create_render_frame_flags, nullptr); | 1659 create_render_frame_flags, nullptr); |
| 1669 | 1660 |
| 1670 if (!speculative_render_frame_host_) { | 1661 if (!speculative_render_frame_host_) { |
| 1671 speculative_web_ui_.reset(); | 1662 speculative_web_ui_.reset(); |
| 1672 return false; | 1663 return false; |
| 1673 } | 1664 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1698 | 1689 |
| 1699 // We are creating a pending, speculative or swapped out RFH here. We should | 1690 // We are creating a pending, speculative or swapped out RFH here. We should |
| 1700 // never create it in the same SiteInstance as our current RFH. | 1691 // never create it in the same SiteInstance as our current RFH. |
| 1701 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 1692 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
| 1702 | 1693 |
| 1703 // Check if we've already created an RFH for this SiteInstance. If so, try | 1694 // Check if we've already created an RFH for this SiteInstance. If so, try |
| 1704 // to re-use the existing one, which has already been initialized. We'll | 1695 // to re-use the existing one, which has already been initialized. We'll |
| 1705 // remove it from the list of proxy hosts below if it will be active. | 1696 // remove it from the list of proxy hosts below if it will be active. |
| 1706 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1697 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 1707 if (proxy && proxy->render_frame_host()) { | 1698 if (proxy && proxy->render_frame_host()) { |
| 1699 RenderViewHost* render_view_host = proxy->GetRenderViewHost(); | |
| 1708 CHECK(!swapped_out_forbidden); | 1700 CHECK(!swapped_out_forbidden); |
| 1709 if (view_routing_id_ptr) | 1701 if (view_routing_id_ptr) |
| 1710 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); | 1702 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); |
| 1711 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 1703 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
| 1712 // Prevent the process from exiting while we're trying to use it. | 1704 // Prevent the process from exiting while we're trying to use it. |
| 1713 if (!swapped_out) { | 1705 if (!swapped_out) { |
| 1714 new_render_frame_host = proxy->PassFrameHostOwnership(); | 1706 new_render_frame_host = proxy->PassFrameHostOwnership(); |
| 1715 new_render_frame_host->GetProcess()->AddPendingView(); | 1707 new_render_frame_host->GetProcess()->AddPendingView(); |
| 1716 | 1708 |
| 1717 proxy_hosts_->Remove(instance->GetId()); | 1709 proxy_hosts_->Remove(instance->GetId()); |
| 1718 // NB |proxy| is deleted at this point. | 1710 // NB |proxy| is deleted at this point. |
| 1719 } | 1711 } |
| 1712 if (!render_view_host->GetView()) | |
|
Charlie Reis
2015/08/28 18:58:26
nit: This needs braces, since the body doesn't fit
lfg
2015/08/28 21:18:40
Done.
| |
| 1713 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host, | |
| 1714 MSG_ROUTING_NONE); | |
| 1720 } else { | 1715 } else { |
| 1721 // Create a new RenderFrameHost if we don't find an existing one. | 1716 // Create a new RenderFrameHost if we don't find an existing one. |
| 1722 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, | 1717 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, |
| 1723 MSG_ROUTING_NONE, flags); | 1718 MSG_ROUTING_NONE, flags); |
| 1724 RenderViewHostImpl* render_view_host = | 1719 RenderViewHostImpl* render_view_host = |
| 1725 new_render_frame_host->render_view_host(); | 1720 new_render_frame_host->render_view_host(); |
| 1726 int proxy_routing_id = MSG_ROUTING_NONE; | 1721 int proxy_routing_id = MSG_ROUTING_NONE; |
| 1727 | 1722 |
| 1728 // Prevent the process from exiting while we're trying to navigate in it. | 1723 // Prevent the process from exiting while we're trying to navigate in it. |
| 1729 // Otherwise, if the new RFH is swapped out already, store it. | 1724 // Otherwise, if the new RFH is swapped out already, store it. |
| 1730 if (!swapped_out) { | 1725 if (!swapped_out) { |
| 1731 new_render_frame_host->GetProcess()->AddPendingView(); | 1726 new_render_frame_host->GetProcess()->AddPendingView(); |
| 1732 } else { | 1727 } else { |
| 1733 proxy = new RenderFrameProxyHost( | 1728 proxy = new RenderFrameProxyHost( |
| 1734 new_render_frame_host->GetSiteInstance(), | 1729 new_render_frame_host->GetSiteInstance(), |
| 1735 new_render_frame_host->render_view_host(), frame_tree_node_); | 1730 new_render_frame_host->render_view_host(), frame_tree_node_); |
| 1736 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); | 1731 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); |
| 1737 proxy_routing_id = proxy->GetRoutingID(); | 1732 proxy_routing_id = proxy->GetRoutingID(); |
| 1738 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 1733 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
| 1739 } | 1734 } |
| 1740 | 1735 |
| 1741 success = InitRenderView(render_view_host, proxy_routing_id, | 1736 success = InitRenderView(render_view_host, proxy_routing_id); |
| 1742 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); | 1737 if (proxy_routing_id == MSG_ROUTING_NONE && !render_view_host->GetView()) |
| 1738 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host, | |
| 1739 proxy_routing_id); | |
|
Charlie Reis
2015/08/28 18:58:26
We're only calling this if proxy_routing_id is MSG
lfg
2015/08/28 21:18:40
No, I switched the interface to take a bool. What
| |
| 1740 | |
| 1743 if (success) { | 1741 if (success) { |
| 1744 // Remember that InitRenderView also created the RenderFrameProxy. | 1742 // Remember that InitRenderView also created the RenderFrameProxy. |
| 1745 if (swapped_out) | 1743 if (swapped_out) |
| 1746 proxy->set_render_frame_proxy_created(true); | 1744 proxy->set_render_frame_proxy_created(true); |
| 1747 if (frame_tree_node_->IsMainFrame()) { | 1745 if (frame_tree_node_->IsMainFrame()) { |
| 1748 // Don't show the main frame's view until we get a DidNavigate from it. | 1746 // Don't show the main frame's view until we get a DidNavigate from it. |
| 1749 // Only the RenderViewHost for the top-level RenderFrameHost has a | 1747 // Only the RenderViewHost for the top-level RenderFrameHost has a |
| 1750 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes | 1748 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes |
| 1751 // will be created later and hidden. | 1749 // will be created later and hidden. |
| 1752 if (render_view_host->GetView()) | 1750 if (render_view_host->GetView()) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1817 return proxy->GetRoutingID(); | 1815 return proxy->GetRoutingID(); |
| 1818 | 1816 |
| 1819 if (!proxy) { | 1817 if (!proxy) { |
| 1820 proxy = | 1818 proxy = |
| 1821 new RenderFrameProxyHost(instance, render_view_host, frame_tree_node_); | 1819 new RenderFrameProxyHost(instance, render_view_host, frame_tree_node_); |
| 1822 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); | 1820 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); |
| 1823 } | 1821 } |
| 1824 | 1822 |
| 1825 if (SiteIsolationPolicy::IsSwappedOutStateForbidden() && | 1823 if (SiteIsolationPolicy::IsSwappedOutStateForbidden() && |
| 1826 frame_tree_node_->IsMainFrame()) { | 1824 frame_tree_node_->IsMainFrame()) { |
| 1827 InitRenderView(render_view_host, proxy->GetRoutingID(), true); | 1825 InitRenderView(render_view_host, proxy->GetRoutingID()); |
| 1828 proxy->set_render_frame_proxy_created(true); | 1826 proxy->set_render_frame_proxy_created(true); |
| 1829 } else { | 1827 } else { |
| 1830 proxy->InitRenderFrameProxy(); | 1828 proxy->InitRenderFrameProxy(); |
| 1831 } | 1829 } |
| 1832 | 1830 |
| 1833 return proxy->GetRoutingID(); | 1831 return proxy->GetRoutingID(); |
| 1834 } | 1832 } |
| 1835 | 1833 |
| 1836 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { | 1834 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { |
| 1837 for (const auto& pair : *proxy_hosts_) { | 1835 for (const auto& pair : *proxy_hosts_) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1855 | 1853 |
| 1856 // Recreate the opener chain. | 1854 // Recreate the opener chain. |
| 1857 CreateOpenerProxiesIfNeeded(instance); | 1855 CreateOpenerProxiesIfNeeded(instance); |
| 1858 | 1856 |
| 1859 // If the proxy in |instance| doesn't exist, this RenderView is not swapped | 1857 // If the proxy in |instance| doesn't exist, this RenderView is not swapped |
| 1860 // out and shouldn't be reinitialized here. | 1858 // out and shouldn't be reinitialized here. |
| 1861 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1859 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 1862 if (!proxy) | 1860 if (!proxy) |
| 1863 return; | 1861 return; |
| 1864 | 1862 |
| 1865 InitRenderView(render_view_host, proxy->GetRoutingID(), false); | 1863 InitRenderView(render_view_host, proxy->GetRoutingID()); |
| 1866 proxy->set_render_frame_proxy_created(true); | 1864 proxy->set_render_frame_proxy_created(true); |
| 1867 } | 1865 } |
| 1868 | 1866 |
| 1869 void RenderFrameHostManager::CreateOuterDelegateProxy( | 1867 void RenderFrameHostManager::CreateOuterDelegateProxy( |
| 1870 SiteInstance* outer_contents_site_instance, | 1868 SiteInstance* outer_contents_site_instance, |
| 1871 RenderFrameHostImpl* render_frame_host) { | 1869 RenderFrameHostImpl* render_frame_host) { |
| 1872 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1870 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
| 1873 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 1871 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
| 1874 outer_contents_site_instance, nullptr, frame_tree_node_); | 1872 outer_contents_site_instance, nullptr, frame_tree_node_); |
| 1875 proxy_hosts_->Add(outer_contents_site_instance->GetId(), | 1873 proxy_hosts_->Add(outer_contents_site_instance->GetId(), |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1890 } | 1888 } |
| 1891 | 1889 |
| 1892 void RenderFrameHostManager::SetRWHViewForInnerContents( | 1890 void RenderFrameHostManager::SetRWHViewForInnerContents( |
| 1893 RenderWidgetHostView* child_rwhv) { | 1891 RenderWidgetHostView* child_rwhv) { |
| 1894 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame()); | 1892 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame()); |
| 1895 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv); | 1893 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv); |
| 1896 } | 1894 } |
| 1897 | 1895 |
| 1898 bool RenderFrameHostManager::InitRenderView( | 1896 bool RenderFrameHostManager::InitRenderView( |
| 1899 RenderViewHostImpl* render_view_host, | 1897 RenderViewHostImpl* render_view_host, |
| 1900 int proxy_routing_id, | 1898 int proxy_routing_id) { |
| 1901 bool for_main_frame_navigation) { | |
| 1902 // Ensure the renderer process is initialized before creating the | 1899 // Ensure the renderer process is initialized before creating the |
| 1903 // RenderView. | 1900 // RenderView. |
| 1904 if (!render_view_host->GetProcess()->Init()) | 1901 if (!render_view_host->GetProcess()->Init()) |
| 1905 return false; | 1902 return false; |
| 1906 | 1903 |
| 1907 // We may have initialized this RenderViewHost for another RenderFrameHost. | 1904 // We may have initialized this RenderViewHost for another RenderFrameHost. |
| 1908 if (render_view_host->IsRenderViewLive()) | 1905 if (render_view_host->IsRenderViewLive()) |
| 1909 return true; | 1906 return true; |
| 1910 | 1907 |
| 1911 // If the ongoing navigation is to a WebUI and the RenderView is not in a | 1908 // If the ongoing navigation is to a WebUI and the RenderView is not in a |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1928 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 1925 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 1929 render_view_host->GetProcess()->GetID())); | 1926 render_view_host->GetProcess()->GetID())); |
| 1930 } | 1927 } |
| 1931 } | 1928 } |
| 1932 | 1929 |
| 1933 int opener_frame_routing_id = | 1930 int opener_frame_routing_id = |
| 1934 GetOpenerRoutingID(render_view_host->GetSiteInstance()); | 1931 GetOpenerRoutingID(render_view_host->GetSiteInstance()); |
| 1935 | 1932 |
| 1936 return delegate_->CreateRenderViewForRenderManager( | 1933 return delegate_->CreateRenderViewForRenderManager( |
| 1937 render_view_host, opener_frame_routing_id, proxy_routing_id, | 1934 render_view_host, opener_frame_routing_id, proxy_routing_id, |
| 1938 frame_tree_node_->current_replication_state(), for_main_frame_navigation); | 1935 frame_tree_node_->current_replication_state()); |
| 1939 } | 1936 } |
| 1940 | 1937 |
| 1941 bool RenderFrameHostManager::InitRenderFrame( | 1938 bool RenderFrameHostManager::InitRenderFrame( |
| 1942 RenderFrameHostImpl* render_frame_host) { | 1939 RenderFrameHostImpl* render_frame_host) { |
| 1943 if (render_frame_host->IsRenderFrameLive()) | 1940 if (render_frame_host->IsRenderFrameLive()) |
| 1944 return true; | 1941 return true; |
| 1945 | 1942 |
| 1946 int parent_routing_id = MSG_ROUTING_NONE; | 1943 int parent_routing_id = MSG_ROUTING_NONE; |
| 1947 int previous_sibling_routing_id = MSG_ROUTING_NONE; | 1944 int previous_sibling_routing_id = MSG_ROUTING_NONE; |
| 1948 int proxy_routing_id = MSG_ROUTING_NONE; | 1945 int proxy_routing_id = MSG_ROUTING_NONE; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2238 | 2235 |
| 2239 // New SiteInstance: create a pending RFH to navigate. | 2236 // New SiteInstance: create a pending RFH to navigate. |
| 2240 | 2237 |
| 2241 // This will possibly create (set to nullptr) a Web UI object for the | 2238 // This will possibly create (set to nullptr) a Web UI object for the |
| 2242 // pending page. We'll use this later to give the page special access. This | 2239 // pending page. We'll use this later to give the page special access. This |
| 2243 // must happen before the new renderer is created below so it will get | 2240 // must happen before the new renderer is created below so it will get |
| 2244 // bindings. It must also happen after the above conditional call to | 2241 // bindings. It must also happen after the above conditional call to |
| 2245 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_ | 2242 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_ |
| 2246 // and the page will not have its bindings set appropriately. | 2243 // and the page will not have its bindings set appropriately. |
| 2247 SetPendingWebUI(dest_url, bindings); | 2244 SetPendingWebUI(dest_url, bindings); |
| 2248 CreatePendingRenderFrameHost(current_instance, new_instance.get(), | 2245 CreatePendingRenderFrameHost(current_instance, new_instance.get()); |
| 2249 frame_tree_node_->IsMainFrame()); | |
| 2250 if (!pending_render_frame_host_) | 2246 if (!pending_render_frame_host_) |
| 2251 return nullptr; | 2247 return nullptr; |
| 2252 | 2248 |
| 2253 // Check if our current RFH is live before we set up a transition. | 2249 // Check if our current RFH is live before we set up a transition. |
| 2254 if (!render_frame_host_->IsRenderFrameLive()) { | 2250 if (!render_frame_host_->IsRenderFrameLive()) { |
| 2255 // The current RFH is not live. There's no reason to sit around with a | 2251 // The current RFH is not live. There's no reason to sit around with a |
| 2256 // sad tab or a newly created RFH while we wait for the pending RFH to | 2252 // sad tab or a newly created RFH while we wait for the pending RFH to |
| 2257 // navigate. Just switch to the pending RFH now and go back to normal. | 2253 // navigate. Just switch to the pending RFH now and go back to normal. |
| 2258 // (Note that we don't care about on{before}unload handlers if the current | 2254 // (Note that we don't care about on{before}unload handlers if the current |
| 2259 // RFH isn't live.) | 2255 // RFH isn't live.) |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2505 // Ensure that all the nodes in the opener's frame tree have | 2501 // Ensure that all the nodes in the opener's frame tree have |
| 2506 // RenderFrameProxyHosts for the new SiteInstance. | 2502 // RenderFrameProxyHosts for the new SiteInstance. |
| 2507 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); | 2503 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); |
| 2508 } else if (rvh && !rvh->IsRenderViewLive()) { | 2504 } else if (rvh && !rvh->IsRenderViewLive()) { |
| 2509 EnsureRenderViewInitialized(rvh, instance); | 2505 EnsureRenderViewInitialized(rvh, instance); |
| 2510 } else { | 2506 } else { |
| 2511 // Create a swapped out RenderView in the given SiteInstance if none exists, | 2507 // Create a swapped out RenderView in the given SiteInstance if none exists, |
| 2512 // setting its opener to the given route_id. Since the opener can point to | 2508 // setting its opener to the given route_id. Since the opener can point to |
| 2513 // a subframe, do this on the root frame of the opener's frame tree. | 2509 // a subframe, do this on the root frame of the opener's frame tree. |
| 2514 // Return the new view's route_id. | 2510 // Return the new view's route_id. |
| 2515 frame_tree->root()->render_manager()-> | 2511 frame_tree->root()->render_manager()->CreateRenderFrame( |
| 2516 CreateRenderFrame(instance, nullptr, | 2512 instance, nullptr, CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr); |
| 2517 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | | |
| 2518 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, | |
| 2519 nullptr); | |
| 2520 } | 2513 } |
| 2521 } | 2514 } |
| 2522 | 2515 |
| 2523 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2516 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2524 if (!frame_tree_node_->opener()) | 2517 if (!frame_tree_node_->opener()) |
| 2525 return MSG_ROUTING_NONE; | 2518 return MSG_ROUTING_NONE; |
| 2526 | 2519 |
| 2527 return frame_tree_node_->opener() | 2520 return frame_tree_node_->opener() |
| 2528 ->render_manager() | 2521 ->render_manager() |
| 2529 ->GetRoutingIdForSiteInstance(instance); | 2522 ->GetRoutingIdForSiteInstance(instance); |
| 2530 } | 2523 } |
| 2531 | 2524 |
| 2532 } // namespace content | 2525 } // namespace content |
| OLD | NEW |