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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 root_(new FrameTreeNode(this, | 108 root_(new FrameTreeNode(this, |
109 navigator, | 109 navigator, |
110 render_frame_delegate, | 110 render_frame_delegate, |
111 render_view_delegate, | 111 render_view_delegate, |
112 render_widget_delegate, | 112 render_widget_delegate, |
113 manager_delegate, | 113 manager_delegate, |
114 // The top-level frame must always be in a | 114 // The top-level frame must always be in a |
115 // document scope. | 115 // document scope. |
116 blink::WebTreeScopeType::Document, | 116 blink::WebTreeScopeType::Document, |
117 std::string(), | 117 std::string(), |
118 blink::WebSandboxFlags::None)), | 118 blink::WebSandboxFlags::None, |
| 119 blink::WebFrameOwnerProperties())), |
119 focused_frame_tree_node_id_(-1), | 120 focused_frame_tree_node_id_(-1), |
120 load_progress_(0.0) { | 121 load_progress_(0.0) {} |
121 } | |
122 | 122 |
123 FrameTree::~FrameTree() { | 123 FrameTree::~FrameTree() { |
124 delete root_; | 124 delete root_; |
125 root_ = nullptr; | 125 root_ = nullptr; |
126 } | 126 } |
127 | 127 |
128 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { | 128 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { |
129 FrameTreeNode* node = nullptr; | 129 FrameTreeNode* node = nullptr; |
130 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); | 130 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); |
131 return node; | 131 return node; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 continue; | 178 continue; |
179 | 179 |
180 if (!on_node.Run(node)) | 180 if (!on_node.Run(node)) |
181 break; | 181 break; |
182 | 182 |
183 for (size_t i = 0; i < node->child_count(); ++i) | 183 for (size_t i = 0; i < node->child_count(); ++i) |
184 queue.push(node->child_at(i)); | 184 queue.push(node->child_at(i)); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent, | 188 RenderFrameHostImpl* FrameTree::AddFrame( |
189 int process_id, | 189 FrameTreeNode* parent, |
190 int new_routing_id, | 190 int process_id, |
191 blink::WebTreeScopeType scope, | 191 int new_routing_id, |
192 const std::string& frame_name, | 192 blink::WebTreeScopeType scope, |
193 blink::WebSandboxFlags sandbox_flags) { | 193 const std::string& frame_name, |
| 194 blink::WebSandboxFlags sandbox_flags, |
| 195 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
194 // A child frame always starts with an initial empty document, which means | 196 // A child frame always starts with an initial empty document, which means |
195 // it is in the same SiteInstance as the parent frame. Ensure that the process | 197 // it is in the same SiteInstance as the parent frame. Ensure that the process |
196 // which requested a child frame to be added is the same as the process of the | 198 // which requested a child frame to be added is the same as the process of the |
197 // parent node. | 199 // parent node. |
198 // We return nullptr if this is not the case, which can happen in a race if an | 200 // We return nullptr if this is not the case, which can happen in a race if an |
199 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. | 201 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. |
200 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 202 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
201 return nullptr; | 203 return nullptr; |
202 | 204 |
203 scoped_ptr<FrameTreeNode> node( | 205 scoped_ptr<FrameTreeNode> node(new FrameTreeNode( |
204 new FrameTreeNode(this, parent->navigator(), render_frame_delegate_, | 206 this, parent->navigator(), render_frame_delegate_, render_view_delegate_, |
205 render_view_delegate_, render_widget_delegate_, | 207 render_widget_delegate_, manager_delegate_, scope, frame_name, |
206 manager_delegate_, scope, frame_name, sandbox_flags)); | 208 sandbox_flags, frame_owner_properties)); |
207 FrameTreeNode* node_ptr = node.get(); | 209 FrameTreeNode* node_ptr = node.get(); |
208 // AddChild is what creates the RenderFrameHost. | 210 // AddChild is what creates the RenderFrameHost. |
209 parent->AddChild(node.Pass(), process_id, new_routing_id); | 211 parent->AddChild(node.Pass(), process_id, new_routing_id); |
210 return node_ptr->current_frame_host(); | 212 return node_ptr->current_frame_host(); |
211 } | 213 } |
212 | 214 |
213 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 215 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
214 FrameTreeNode* parent = child->parent(); | 216 FrameTreeNode* parent = child->parent(); |
215 if (!parent) { | 217 if (!parent) { |
216 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; | 218 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 load_progress_ = 0.0; | 407 load_progress_ = 0.0; |
406 } | 408 } |
407 | 409 |
408 bool FrameTree::IsLoading() { | 410 bool FrameTree::IsLoading() { |
409 bool is_loading = false; | 411 bool is_loading = false; |
410 ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 412 ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
411 return is_loading; | 413 return is_loading; |
412 } | 414 } |
413 | 415 |
414 } // namespace content | 416 } // namespace content |
OLD | NEW |