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...) 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 container policy and make them effective immediately, |
207 // sandbox flags should apply to the initial empty document in the frame. | 208 // since initial sandbox flags and feature policy should apply to the initial |
| 209 // empty document in the frame. |
208 added_node->SetPendingSandboxFlags(sandbox_flags); | 210 added_node->SetPendingSandboxFlags(sandbox_flags); |
209 added_node->CommitPendingSandboxFlags(); | 211 added_node->SetPendingContainerPolicy(container_policy); |
| 212 added_node->CommitPendingFramePolicy(); |
210 | 213 |
211 // Now that the new node is part of the FrameTree and has a RenderFrameHost, | 214 // 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 | 215 // we can announce the creation of the initial RenderFrame which already |
213 // exists in the renderer process. | 216 // exists in the renderer process. |
214 added_node->current_frame_host()->SetRenderFrameCreated(true); | 217 added_node->current_frame_host()->SetRenderFrameCreated(true); |
215 return true; | 218 return true; |
216 } | 219 } |
217 | 220 |
218 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 221 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
219 FrameTreeNode* parent = child->parent(); | 222 FrameTreeNode* parent = child->parent(); |
(...skipping 240 matching lines...) Loading... |
460 // This is only used to set page-level focus in cross-process subframes, and | 463 // 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. | 464 // requests to set focus in main frame's SiteInstance are ignored. |
462 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 465 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
463 RenderFrameProxyHost* proxy = | 466 RenderFrameProxyHost* proxy = |
464 root_manager->GetRenderFrameProxyHost(instance); | 467 root_manager->GetRenderFrameProxyHost(instance); |
465 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 468 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
466 } | 469 } |
467 } | 470 } |
468 | 471 |
469 } // namespace content | 472 } // namespace content |
OLD | NEW |