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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 proxy_routing_id, | 1644 proxy_routing_id, |
1645 for_main_frame_navigation); | 1645 for_main_frame_navigation); |
1646 } | 1646 } |
1647 | 1647 |
1648 bool RenderFrameHostManager::InitRenderFrame( | 1648 bool RenderFrameHostManager::InitRenderFrame( |
1649 RenderFrameHostImpl* render_frame_host) { | 1649 RenderFrameHostImpl* render_frame_host) { |
1650 if (render_frame_host->IsRenderFrameLive()) | 1650 if (render_frame_host->IsRenderFrameLive()) |
1651 return true; | 1651 return true; |
1652 | 1652 |
1653 int parent_routing_id = MSG_ROUTING_NONE; | 1653 int parent_routing_id = MSG_ROUTING_NONE; |
1654 int previous_sibling_routing_id = MSG_ROUTING_NONE; | |
1655 int proxy_routing_id = MSG_ROUTING_NONE; | 1654 int proxy_routing_id = MSG_ROUTING_NONE; |
1656 | |
1657 if (frame_tree_node_->parent()) { | 1655 if (frame_tree_node_->parent()) { |
1658 parent_routing_id = frame_tree_node_->parent()->render_manager()-> | 1656 parent_routing_id = frame_tree_node_->parent()->render_manager()-> |
1659 GetRoutingIdForSiteInstance(render_frame_host->GetSiteInstance()); | 1657 GetRoutingIdForSiteInstance(render_frame_host->GetSiteInstance()); |
1660 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); | 1658 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); |
1661 } | 1659 } |
1662 | |
1663 // At this point, all RenderFrameProxies for sibling frames have already been | |
1664 // created, including any proxies that come after this frame. To preserve | |
1665 // correct order for indexed window access (e.g., window.frames[1]), pass the | |
1666 // previous sibling frame so that this frame is correctly inserted into the | |
1667 // frame tree on the renderer side. | |
1668 FrameTreeNode* previous_sibling = frame_tree_node_->PreviousSibling(); | |
1669 if (previous_sibling) { | |
1670 previous_sibling_routing_id = | |
1671 previous_sibling->render_manager()->GetRoutingIdForSiteInstance( | |
1672 render_frame_host->GetSiteInstance()); | |
1673 CHECK_NE(previous_sibling_routing_id, MSG_ROUTING_NONE); | |
1674 } | |
1675 | |
1676 // Check whether there is an existing proxy for this frame in this | 1660 // Check whether there is an existing proxy for this frame in this |
1677 // SiteInstance. If there is, the new RenderFrame needs to be able to find | 1661 // SiteInstance. If there is, the new RenderFrame needs to be able to find |
1678 // the proxy it is replacing, so that it can fully initialize itself. | 1662 // the proxy it is replacing, so that it can fully initialize itself. |
1679 // NOTE: This is the only time that a RenderFrameProxyHost can be in the same | 1663 // NOTE: This is the only time that a RenderFrameProxyHost can be in the same |
1680 // SiteInstance as its RenderFrameHost. This is only the case until the | 1664 // SiteInstance as its RenderFrameHost. This is only the case until the |
1681 // RenderFrameHost commits, at which point it will replace and delete the | 1665 // RenderFrameHost commits, at which point it will replace and delete the |
1682 // RenderFrameProxyHost. | 1666 // RenderFrameProxyHost. |
1683 RenderFrameProxyHost* existing_proxy = | 1667 RenderFrameProxyHost* existing_proxy = |
1684 GetRenderFrameProxyHost(render_frame_host->GetSiteInstance()); | 1668 GetRenderFrameProxyHost(render_frame_host->GetSiteInstance()); |
1685 if (existing_proxy) { | 1669 if (existing_proxy) { |
1686 proxy_routing_id = existing_proxy->GetRoutingID(); | 1670 proxy_routing_id = existing_proxy->GetRoutingID(); |
1687 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); | 1671 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); |
1688 if (!existing_proxy->is_render_frame_proxy_live()) | 1672 if (!existing_proxy->is_render_frame_proxy_live()) |
1689 existing_proxy->InitRenderFrameProxy(); | 1673 existing_proxy->InitRenderFrameProxy(); |
1690 } | 1674 } |
1691 return delegate_->CreateRenderFrameForRenderManager( | 1675 return delegate_->CreateRenderFrameForRenderManager(render_frame_host, |
1692 render_frame_host, parent_routing_id, previous_sibling_routing_id, | 1676 parent_routing_id, |
1693 proxy_routing_id); | 1677 proxy_routing_id); |
1694 } | 1678 } |
1695 | 1679 |
1696 int RenderFrameHostManager::GetRoutingIdForSiteInstance( | 1680 int RenderFrameHostManager::GetRoutingIdForSiteInstance( |
1697 SiteInstance* site_instance) { | 1681 SiteInstance* site_instance) { |
1698 if (render_frame_host_->GetSiteInstance() == site_instance) | 1682 if (render_frame_host_->GetSiteInstance() == site_instance) |
1699 return render_frame_host_->GetRoutingID(); | 1683 return render_frame_host_->GetRoutingID(); |
1700 | 1684 |
1701 RenderFrameProxyHostMap::iterator iter = | 1685 RenderFrameProxyHostMap::iterator iter = |
1702 proxy_hosts_.find(site_instance->GetId()); | 1686 proxy_hosts_.find(site_instance->GetId()); |
1703 if (iter != proxy_hosts_.end()) | 1687 if (iter != proxy_hosts_.end()) |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2102 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
2119 SiteInstance* instance) { | 2103 SiteInstance* instance) { |
2120 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2104 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
2121 if (iter != proxy_hosts_.end()) { | 2105 if (iter != proxy_hosts_.end()) { |
2122 delete iter->second; | 2106 delete iter->second; |
2123 proxy_hosts_.erase(iter); | 2107 proxy_hosts_.erase(iter); |
2124 } | 2108 } |
2125 } | 2109 } |
2126 | 2110 |
2127 } // namespace content | 2111 } // namespace content |
OLD | NEW |