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 <queue> | 7 #include <queue> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 root_(new FrameTreeNode(this, | 117 root_(new FrameTreeNode(this, |
118 navigator, | 118 navigator, |
119 render_frame_delegate, | 119 render_frame_delegate, |
120 render_view_delegate, | 120 render_view_delegate, |
121 render_widget_delegate, | 121 render_widget_delegate, |
122 manager_delegate, | 122 manager_delegate, |
123 // The top-level frame must always be in a | 123 // The top-level frame must always be in a |
124 // document scope. | 124 // document scope. |
125 blink::WebTreeScopeType::Document, | 125 blink::WebTreeScopeType::Document, |
126 std::string(), | 126 std::string(), |
127 blink::WebSandboxFlags::None)), | 127 blink::WebSandboxFlags::None, |
| 128 blink::WebFrameOwnerProperties())), |
128 focused_frame_tree_node_id_(-1), | 129 focused_frame_tree_node_id_(-1), |
129 load_progress_(0.0) { | 130 load_progress_(0.0) {} |
130 } | |
131 | 131 |
132 FrameTree::~FrameTree() { | 132 FrameTree::~FrameTree() { |
133 delete root_; | 133 delete root_; |
134 root_ = nullptr; | 134 root_ = nullptr; |
135 } | 135 } |
136 | 136 |
137 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { | 137 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { |
138 FrameTreeNode* node = nullptr; | 138 FrameTreeNode* node = nullptr; |
139 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); | 139 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); |
140 return node; | 140 return node; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 continue; | 187 continue; |
188 | 188 |
189 if (!on_node.Run(node)) | 189 if (!on_node.Run(node)) |
190 break; | 190 break; |
191 | 191 |
192 for (size_t i = 0; i < node->child_count(); ++i) | 192 for (size_t i = 0; i < node->child_count(); ++i) |
193 queue.push(node->child_at(i)); | 193 queue.push(node->child_at(i)); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent, | 197 RenderFrameHostImpl* FrameTree::AddFrame( |
198 int process_id, | 198 FrameTreeNode* parent, |
199 int new_routing_id, | 199 int process_id, |
200 blink::WebTreeScopeType scope, | 200 int new_routing_id, |
201 const std::string& frame_name, | 201 blink::WebTreeScopeType scope, |
202 blink::WebSandboxFlags sandbox_flags) { | 202 const std::string& frame_name, |
| 203 blink::WebSandboxFlags sandbox_flags, |
| 204 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
203 // A child frame always starts with an initial empty document, which means | 205 // A child frame always starts with an initial empty document, which means |
204 // it is in the same SiteInstance as the parent frame. Ensure that the process | 206 // it is in the same SiteInstance as the parent frame. Ensure that the process |
205 // which requested a child frame to be added is the same as the process of the | 207 // which requested a child frame to be added is the same as the process of the |
206 // parent node. | 208 // parent node. |
207 // We return nullptr if this is not the case, which can happen in a race if an | 209 // We return nullptr if this is not the case, which can happen in a race if an |
208 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. | 210 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. |
209 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 211 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
210 return nullptr; | 212 return nullptr; |
211 | 213 |
212 scoped_ptr<FrameTreeNode> node( | 214 scoped_ptr<FrameTreeNode> node(new FrameTreeNode( |
213 new FrameTreeNode(this, parent->navigator(), render_frame_delegate_, | 215 this, parent->navigator(), render_frame_delegate_, render_view_delegate_, |
214 render_view_delegate_, render_widget_delegate_, | 216 render_widget_delegate_, manager_delegate_, scope, frame_name, |
215 manager_delegate_, scope, frame_name, sandbox_flags)); | 217 sandbox_flags, frame_owner_properties)); |
216 FrameTreeNode* node_ptr = node.get(); | 218 FrameTreeNode* node_ptr = node.get(); |
217 // AddChild is what creates the RenderFrameHost. | 219 // AddChild is what creates the RenderFrameHost. |
218 parent->AddChild(node.Pass(), process_id, new_routing_id); | 220 parent->AddChild(node.Pass(), process_id, new_routing_id); |
219 return node_ptr->current_frame_host(); | 221 return node_ptr->current_frame_host(); |
220 } | 222 } |
221 | 223 |
222 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 224 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
223 FrameTreeNode* parent = child->parent(); | 225 FrameTreeNode* parent = child->parent(); |
224 if (!parent) { | 226 if (!parent) { |
225 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; | 227 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 // This is only used to set page-level focus in cross-process subframes, and | 441 // This is only used to set page-level focus in cross-process subframes, and |
440 // requests to set focus in main frame's SiteInstance are ignored. | 442 // requests to set focus in main frame's SiteInstance are ignored. |
441 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 443 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
442 RenderFrameProxyHost* proxy = | 444 RenderFrameProxyHost* proxy = |
443 root_manager->GetRenderFrameProxyHost(instance); | 445 root_manager->GetRenderFrameProxyHost(instance); |
444 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 446 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
445 } | 447 } |
446 } | 448 } |
447 | 449 |
448 } // namespace content | 450 } // namespace content |
OLD | NEW |