| 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, | 194 |
| 195 frame_unique_name, frame_owner_properties)), | 195 // Set sandbox flags and container policy and make them effective immediately, |
| 196 process_id, new_routing_id); | 196 // since initial sandbox flags and feature policy should apply to the initial |
| 197 // empty document in the frame. This needs to happen before the call to |
| 198 // AddChild so that the effective policy is sent to any newly-created |
| 199 // RenderFrameProxy objects when the RenderFrameHost is created. |
| 200 new_node->SetPendingSandboxFlags(sandbox_flags); |
| 201 new_node->SetPendingContainerPolicy(container_policy); |
| 202 new_node->CommitPendingFramePolicy(); |
| 203 |
| 204 // Add the new node to the FrameTree, creating the RenderFrameHost. |
| 205 FrameTreeNode* added_node = |
| 206 parent->AddChild(std::move(new_node), process_id, new_routing_id); |
| 197 | 207 |
| 198 // The last committed NavigationEntry may have a FrameNavigationEntry with the | 208 // The last committed NavigationEntry may have a FrameNavigationEntry with the |
| 199 // same |frame_unique_name|, since we don't remove FrameNavigationEntries if | 209 // 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 | 210 // their frames are deleted. If there is a stale one, remove it to avoid |
| 201 // conflicts on future updates. | 211 // conflicts on future updates. |
| 202 NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>( | 212 NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>( |
| 203 parent->navigator()->GetController()->GetLastCommittedEntry()); | 213 parent->navigator()->GetController()->GetLastCommittedEntry()); |
| 204 if (last_committed_entry) | 214 if (last_committed_entry) |
| 205 last_committed_entry->ClearStaleFrameEntriesForNewFrame(added_node); | 215 last_committed_entry->ClearStaleFrameEntriesForNewFrame(added_node); |
| 206 | 216 |
| 207 // Set sandbox flags and container policy and make them effective immediately, | |
| 208 // since initial sandbox flags and feature policy should apply to the initial | |
| 209 // empty document in the frame. | |
| 210 added_node->SetPendingSandboxFlags(sandbox_flags); | |
| 211 added_node->SetPendingContainerPolicy(container_policy); | |
| 212 added_node->CommitPendingFramePolicy(); | |
| 213 | |
| 214 // Now that the new node is part of the FrameTree and has a RenderFrameHost, | 217 // 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 | 218 // we can announce the creation of the initial RenderFrame which already |
| 216 // exists in the renderer process. | 219 // exists in the renderer process. |
| 217 added_node->current_frame_host()->SetRenderFrameCreated(true); | 220 added_node->current_frame_host()->SetRenderFrameCreated(true); |
| 218 return true; | 221 return true; |
| 219 } | 222 } |
| 220 | 223 |
| 221 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 224 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
| 222 FrameTreeNode* parent = child->parent(); | 225 FrameTreeNode* parent = child->parent(); |
| 223 if (!parent) { | 226 if (!parent) { |
| (...skipping 239 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 | 466 // 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. | 467 // requests to set focus in main frame's SiteInstance are ignored. |
| 465 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 468 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 466 RenderFrameProxyHost* proxy = | 469 RenderFrameProxyHost* proxy = |
| 467 root_manager->GetRenderFrameProxyHost(instance); | 470 root_manager->GetRenderFrameProxyHost(instance); |
| 468 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 471 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 469 } | 472 } |
| 470 } | 473 } |
| 471 | 474 |
| 472 } // namespace content | 475 } // namespace content |
| OLD | NEW |