| 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 } | 124 } |
| 125 | 125 |
| 126 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { | 126 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { |
| 127 FrameTreeNode* node = nullptr; | 127 FrameTreeNode* node = nullptr; |
| 128 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); | 128 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); |
| 129 return node; | 129 return node; |
| 130 } | 130 } |
| 131 | 131 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 continue; | 176 continue; |
| 177 | 177 |
| 178 if (!on_node.Run(node)) | 178 if (!on_node.Run(node)) |
| 179 break; | 179 break; |
| 180 | 180 |
| 181 for (size_t i = 0; i < node->child_count(); ++i) | 181 for (size_t i = 0; i < node->child_count(); ++i) |
| 182 queue.push(node->child_at(i)); | 182 queue.push(node->child_at(i)); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent, | 186 RenderFrameHostImpl* FrameTree::AddFrame( |
| 187 int process_id, | 187 FrameTreeNode* parent, |
| 188 int new_routing_id, | 188 int process_id, |
| 189 blink::WebTreeScopeType scope, | 189 int new_routing_id, |
| 190 const std::string& frame_name, | 190 blink::WebTreeScopeType scope, |
| 191 blink::WebSandboxFlags sandbox_flags) { | 191 const std::string& frame_name, |
| 192 blink::WebSandboxFlags sandbox_flags, |
| 193 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
| 192 // A child frame always starts with an initial empty document, which means | 194 // A child frame always starts with an initial empty document, which means |
| 193 // it is in the same SiteInstance as the parent frame. Ensure that the process | 195 // it is in the same SiteInstance as the parent frame. Ensure that the process |
| 194 // which requested a child frame to be added is the same as the process of the | 196 // which requested a child frame to be added is the same as the process of the |
| 195 // parent node. | 197 // parent node. |
| 196 // We return nullptr if this is not the case, which can happen in a race if an | 198 // We return nullptr if this is not the case, which can happen in a race if an |
| 197 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. | 199 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. |
| 198 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 200 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
| 199 return nullptr; | 201 return nullptr; |
| 200 | 202 |
| 201 scoped_ptr<FrameTreeNode> node( | 203 scoped_ptr<FrameTreeNode> node(new FrameTreeNode( |
| 202 new FrameTreeNode(this, parent->navigator(), render_frame_delegate_, | 204 this, parent->navigator(), render_frame_delegate_, render_view_delegate_, |
| 203 render_view_delegate_, render_widget_delegate_, | 205 render_widget_delegate_, manager_delegate_, scope, frame_name, |
| 204 manager_delegate_, scope, frame_name, sandbox_flags)); | 206 sandbox_flags, frame_owner_properties)); |
| 205 FrameTreeNode* node_ptr = node.get(); | 207 FrameTreeNode* node_ptr = node.get(); |
| 206 // AddChild is what creates the RenderFrameHost. | 208 // AddChild is what creates the RenderFrameHost. |
| 207 parent->AddChild(node.Pass(), process_id, new_routing_id); | 209 parent->AddChild(node.Pass(), process_id, new_routing_id); |
| 208 return node_ptr->current_frame_host(); | 210 return node_ptr->current_frame_host(); |
| 209 } | 211 } |
| 210 | 212 |
| 211 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 213 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
| 212 FrameTreeNode* parent = child->parent(); | 214 FrameTreeNode* parent = child->parent(); |
| 213 if (!parent) { | 215 if (!parent) { |
| 214 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; | 216 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 load_progress_ = 0.0; | 395 load_progress_ = 0.0; |
| 394 } | 396 } |
| 395 | 397 |
| 396 bool FrameTree::IsLoading() { | 398 bool FrameTree::IsLoading() { |
| 397 bool is_loading = false; | 399 bool is_loading = false; |
| 398 ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 400 ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
| 399 return is_loading; | 401 return is_loading; |
| 400 } | 402 } |
| 401 | 403 |
| 402 } // namespace content | 404 } // namespace content |
| OLD | NEW |