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/frame_tree.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 const FrameOwnerProperties& frame_owner_properties) { | 180 const FrameOwnerProperties& frame_owner_properties) { |
| 181 CHECK_NE(new_routing_id, MSG_ROUTING_NONE); | 181 CHECK_NE(new_routing_id, MSG_ROUTING_NONE); |
| 182 | 182 |
| 183 // A child frame always starts with an initial empty document, which means | 183 // A child frame always starts with an initial empty document, which means |
| 184 // it is in the same SiteInstance as the parent frame. Ensure that the process | 184 // it is in the same SiteInstance as the parent frame. Ensure that the process |
| 185 // which requested a child frame to be added is the same as the process of the | 185 // which requested a child frame to be added is the same as the process of the |
| 186 // parent node. | 186 // parent node. |
| 187 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 187 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
| 188 return false; | 188 return false; |
| 189 | 189 |
| 190 // AddChild is what creates the RenderFrameHost. | 190 std::unique_ptr<FrameTreeNode> new_node = base::WrapUnique(new FrameTreeNode( |
| 191 FrameTreeNode* added_node = parent->AddChild( | 191 this, parent->navigator(), render_frame_delegate_, |
| 192 base::WrapUnique(new FrameTreeNode( | 192 render_widget_delegate_, manager_delegate_, parent, scope, frame_name, |
| 193 this, parent->navigator(), render_frame_delegate_, | 193 frame_unique_name, frame_owner_properties)); |
| 194 render_widget_delegate_, manager_delegate_, parent, scope, frame_name, | |
| 195 frame_unique_name, frame_owner_properties)), | |
| 196 process_id, new_routing_id); | |
| 197 | 194 |
| 198 // The last committed NavigationEntry may have a FrameNavigationEntry with the | 195 // The last committed NavigationEntry may have a FrameNavigationEntry with the |
| 199 // same |frame_unique_name|, since we don't remove FrameNavigationEntries if | 196 // same |frame_unique_name|, since we don't remove FrameNavigationEntries if |
| 200 // their frames are deleted. If there is a stale one, remove it to avoid | 197 // their frames are deleted. If there is a stale one, remove it to avoid |
| 201 // conflicts on future updates. | 198 // conflicts on future updates. |
| 202 NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>( | 199 NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>( |
| 203 parent->navigator()->GetController()->GetLastCommittedEntry()); | 200 parent->navigator()->GetController()->GetLastCommittedEntry()); |
| 204 if (last_committed_entry) | 201 if (last_committed_entry) |
| 205 last_committed_entry->ClearStaleFrameEntriesForNewFrame(added_node); | 202 last_committed_entry->ClearStaleFrameEntriesForNewFrame(new_node.get()); |
|
alexmos
2017/06/23 18:23:55
Hmm, ClearStaleFrameEntriesForNewFrame calls InSam
iclelland
2017/06/24 03:57:44
Done.
| |
| 206 | 203 |
| 207 // Set sandbox flags and container policy and make them effective immediately, | 204 // Set sandbox flags and container policy and make them effective immediately, |
| 208 // since initial sandbox flags and feature policy should apply to the initial | 205 // since initial sandbox flags and feature policy should apply to the initial |
| 209 // empty document in the frame. | 206 // empty document in the frame. |
|
alexmos
2017/06/23 18:23:55
Can we update this comment to explain why those ne
iclelland
2017/06/24 03:57:44
Done.
| |
| 210 added_node->SetPendingSandboxFlags(sandbox_flags); | 207 new_node->SetPendingSandboxFlags(sandbox_flags); |
| 211 added_node->SetPendingContainerPolicy(container_policy); | 208 new_node->SetPendingContainerPolicy(container_policy); |
| 212 added_node->CommitPendingFramePolicy(); | 209 new_node->CommitPendingFramePolicy(); |
| 210 | |
| 211 // Add the new node to the FrameTree, creating the RenderFrameHost. | |
| 212 FrameTreeNode* added_node = | |
| 213 parent->AddChild(std::move(new_node), process_id, new_routing_id); | |
| 213 | 214 |
| 214 // Now that the new node is part of the FrameTree and has a RenderFrameHost, | 215 // Now that the new node is part of the FrameTree and has a RenderFrameHost, |
| 215 // we can announce the creation of the initial RenderFrame which already | 216 // we can announce the creation of the initial RenderFrame which already |
| 216 // exists in the renderer process. | 217 // exists in the renderer process. |
| 217 added_node->current_frame_host()->SetRenderFrameCreated(true); | 218 added_node->current_frame_host()->SetRenderFrameCreated(true); |
| 218 return true; | 219 return true; |
| 219 } | 220 } |
| 220 | 221 |
| 221 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 222 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
| 222 FrameTreeNode* parent = child->parent(); | 223 FrameTreeNode* parent = child->parent(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 // This is only used to set page-level focus in cross-process subframes, and | 464 // This is only used to set page-level focus in cross-process subframes, and |
| 464 // requests to set focus in main frame's SiteInstance are ignored. | 465 // requests to set focus in main frame's SiteInstance are ignored. |
| 465 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 466 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 466 RenderFrameProxyHost* proxy = | 467 RenderFrameProxyHost* proxy = |
| 467 root_manager->GetRenderFrameProxyHost(instance); | 468 root_manager->GetRenderFrameProxyHost(instance); |
| 468 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 469 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 469 } | 470 } |
| 470 } | 471 } |
| 471 | 472 |
| 472 } // namespace content | 473 } // namespace content |
| OLD | NEW |