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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 return NodeRange(root_, node_to_skip); | 169 return NodeRange(root_, node_to_skip); |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool FrameTree::AddFrame(FrameTreeNode* parent, | 172 bool FrameTree::AddFrame(FrameTreeNode* parent, |
| 173 int process_id, | 173 int process_id, |
| 174 int new_routing_id, | 174 int new_routing_id, |
| 175 blink::WebTreeScopeType scope, | 175 blink::WebTreeScopeType scope, |
| 176 const std::string& frame_name, | 176 const std::string& frame_name, |
| 177 const std::string& frame_unique_name, | 177 const std::string& frame_unique_name, |
| 178 blink::WebSandboxFlags sandbox_flags, | 178 blink::WebSandboxFlags sandbox_flags, |
| 179 const ParsedFeaturePolicyHeader& container_policy, | |
| 179 const FrameOwnerProperties& frame_owner_properties) { | 180 const FrameOwnerProperties& frame_owner_properties) { |
| 180 CHECK_NE(new_routing_id, MSG_ROUTING_NONE); | 181 CHECK_NE(new_routing_id, MSG_ROUTING_NONE); |
| 181 | 182 |
| 182 // 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 |
| 183 // 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 |
| 184 // 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 |
| 185 // parent node. | 186 // parent node. |
| 186 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 187 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
| 187 return false; | 188 return false; |
| 188 | 189 |
| 189 // AddChild is what creates the RenderFrameHost. | 190 // AddChild is what creates the RenderFrameHost. |
| 190 FrameTreeNode* added_node = parent->AddChild( | 191 FrameTreeNode* added_node = parent->AddChild( |
| 191 base::WrapUnique(new FrameTreeNode( | 192 base::WrapUnique(new FrameTreeNode( |
| 192 this, parent->navigator(), render_frame_delegate_, | 193 this, parent->navigator(), render_frame_delegate_, |
| 193 render_widget_delegate_, manager_delegate_, parent, scope, frame_name, | 194 render_widget_delegate_, manager_delegate_, parent, scope, frame_name, |
| 194 frame_unique_name, frame_owner_properties)), | 195 frame_unique_name, frame_owner_properties)), |
| 195 process_id, new_routing_id); | 196 process_id, new_routing_id); |
| 196 | 197 |
| 197 // The last committed NavigationEntry may have a FrameNavigationEntry with the | 198 // The last committed NavigationEntry may have a FrameNavigationEntry with the |
| 198 // same |frame_unique_name|, since we don't remove FrameNavigationEntries if | 199 // same |frame_unique_name|, since we don't remove FrameNavigationEntries if |
| 199 // their frames are deleted. If there is a stale one, remove it to avoid | 200 // their frames are deleted. If there is a stale one, remove it to avoid |
| 200 // conflicts on future updates. | 201 // conflicts on future updates. |
| 201 NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>( | 202 NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>( |
| 202 parent->navigator()->GetController()->GetLastCommittedEntry()); | 203 parent->navigator()->GetController()->GetLastCommittedEntry()); |
| 203 if (last_committed_entry) | 204 if (last_committed_entry) |
| 204 last_committed_entry->ClearStaleFrameEntriesForNewFrame(added_node); | 205 last_committed_entry->ClearStaleFrameEntriesForNewFrame(added_node); |
| 205 | 206 |
| 206 // Set sandbox flags and make them effective immediately, since initial | 207 // Set sandbox flags and make them effective immediately, since initial |
|
lunalu1
2017/04/05 22:30:03
nit: update the comment so that it reflects on bot
iclelland
2017/04/09 03:25:54
Done.
| |
| 207 // sandbox flags should apply to the initial empty document in the frame. | 208 // sandbox flags should apply to the initial empty document in the frame. |
| 208 added_node->SetPendingSandboxFlags(sandbox_flags); | 209 added_node->SetPendingSandboxFlags(sandbox_flags); |
| 209 added_node->CommitPendingSandboxFlags(); | 210 added_node->SetPendingContainerPolicy(container_policy); |
|
alexmos
2017/04/06 00:44:22
If we're combining the commit step, perhaps it als
iclelland
2017/04/09 03:25:54
I hadn't done this; SetPendingSandboxFlags is also
alexmos
2017/04/11 01:17:49
Ack. I was thinking you could pass in an empty po
| |
| 211 added_node->CommitPendingFramePolicy(); | |
| 210 | 212 |
| 211 // Now that the new node is part of the FrameTree and has a RenderFrameHost, | 213 // Now that the new node is part of the FrameTree and has a RenderFrameHost, |
| 212 // we can announce the creation of the initial RenderFrame which already | 214 // we can announce the creation of the initial RenderFrame which already |
| 213 // exists in the renderer process. | 215 // exists in the renderer process. |
| 214 added_node->current_frame_host()->SetRenderFrameCreated(true); | 216 added_node->current_frame_host()->SetRenderFrameCreated(true); |
| 215 return true; | 217 return true; |
| 216 } | 218 } |
| 217 | 219 |
| 218 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 220 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
| 219 FrameTreeNode* parent = child->parent(); | 221 FrameTreeNode* parent = child->parent(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 // This is only used to set page-level focus in cross-process subframes, and | 462 // This is only used to set page-level focus in cross-process subframes, and |
| 461 // requests to set focus in main frame's SiteInstance are ignored. | 463 // requests to set focus in main frame's SiteInstance are ignored. |
| 462 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 464 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 463 RenderFrameProxyHost* proxy = | 465 RenderFrameProxyHost* proxy = |
| 464 root_manager->GetRenderFrameProxyHost(instance); | 466 root_manager->GetRenderFrameProxyHost(instance); |
| 465 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 467 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 466 } | 468 } |
| 467 } | 469 } |
| 468 | 470 |
| 469 } // namespace content | 471 } // namespace content |
| OLD | NEW |