| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 : render_frame_delegate_(render_frame_delegate), | 101 : render_frame_delegate_(render_frame_delegate), |
| 102 render_view_delegate_(render_view_delegate), | 102 render_view_delegate_(render_view_delegate), |
| 103 render_widget_delegate_(render_widget_delegate), | 103 render_widget_delegate_(render_widget_delegate), |
| 104 manager_delegate_(manager_delegate), | 104 manager_delegate_(manager_delegate), |
| 105 root_(new FrameTreeNode(this, | 105 root_(new FrameTreeNode(this, |
| 106 navigator, | 106 navigator, |
| 107 render_frame_delegate, | 107 render_frame_delegate, |
| 108 render_view_delegate, | 108 render_view_delegate, |
| 109 render_widget_delegate, | 109 render_widget_delegate, |
| 110 manager_delegate, | 110 manager_delegate, |
| 111 // The top-level frame must always be in a |
| 112 // document scope. |
| 113 blink::WebTreeScopeType::Document, |
| 111 std::string(), | 114 std::string(), |
| 112 SandboxFlags::NONE)), | 115 SandboxFlags::NONE)), |
| 113 focused_frame_tree_node_id_(-1), | 116 focused_frame_tree_node_id_(-1), |
| 114 load_progress_(0.0) { | 117 load_progress_(0.0) { |
| 115 } | 118 } |
| 116 | 119 |
| 117 FrameTree::~FrameTree() { | 120 FrameTree::~FrameTree() { |
| 118 } | 121 } |
| 119 | 122 |
| 120 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { | 123 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 break; | 176 break; |
| 174 | 177 |
| 175 for (size_t i = 0; i < node->child_count(); ++i) | 178 for (size_t i = 0; i < node->child_count(); ++i) |
| 176 queue.push(node->child_at(i)); | 179 queue.push(node->child_at(i)); |
| 177 } | 180 } |
| 178 } | 181 } |
| 179 | 182 |
| 180 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent, | 183 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent, |
| 181 int process_id, | 184 int process_id, |
| 182 int new_routing_id, | 185 int new_routing_id, |
| 186 blink::WebTreeScopeType scope, |
| 183 const std::string& frame_name, | 187 const std::string& frame_name, |
| 184 SandboxFlags sandbox_flags) { | 188 SandboxFlags sandbox_flags) { |
| 185 // A child frame always starts with an initial empty document, which means | 189 // A child frame always starts with an initial empty document, which means |
| 186 // it is in the same SiteInstance as the parent frame. Ensure that the process | 190 // it is in the same SiteInstance as the parent frame. Ensure that the process |
| 187 // which requested a child frame to be added is the same as the process of the | 191 // which requested a child frame to be added is the same as the process of the |
| 188 // parent node. | 192 // parent node. |
| 189 // We return nullptr if this is not the case, which can happen in a race if an | 193 // We return nullptr if this is not the case, which can happen in a race if an |
| 190 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. | 194 // old RFH sends a CreateChildFrame message as we're swapping to a new RFH. |
| 191 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 195 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
| 192 return nullptr; | 196 return nullptr; |
| 193 | 197 |
| 194 scoped_ptr<FrameTreeNode> node(new FrameTreeNode( | 198 scoped_ptr<FrameTreeNode> node( |
| 195 this, parent->navigator(), render_frame_delegate_, render_view_delegate_, | 199 new FrameTreeNode(this, parent->navigator(), render_frame_delegate_, |
| 196 render_widget_delegate_, manager_delegate_, frame_name, sandbox_flags)); | 200 render_view_delegate_, render_widget_delegate_, |
| 201 manager_delegate_, scope, frame_name, sandbox_flags)); |
| 197 FrameTreeNode* node_ptr = node.get(); | 202 FrameTreeNode* node_ptr = node.get(); |
| 198 // AddChild is what creates the RenderFrameHost. | 203 // AddChild is what creates the RenderFrameHost. |
| 199 parent->AddChild(node.Pass(), process_id, new_routing_id); | 204 parent->AddChild(node.Pass(), process_id, new_routing_id); |
| 200 return node_ptr->current_frame_host(); | 205 return node_ptr->current_frame_host(); |
| 201 } | 206 } |
| 202 | 207 |
| 203 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 208 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
| 204 FrameTreeNode* parent = child->parent(); | 209 FrameTreeNode* parent = child->parent(); |
| 205 if (!parent) { | 210 if (!parent) { |
| 206 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; | 211 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 load_progress_ = 0.0; | 394 load_progress_ = 0.0; |
| 390 } | 395 } |
| 391 | 396 |
| 392 bool FrameTree::IsLoading() { | 397 bool FrameTree::IsLoading() { |
| 393 bool is_loading = false; | 398 bool is_loading = false; |
| 394 ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 399 ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
| 395 return is_loading; | 400 return is_loading; |
| 396 } | 401 } |
| 397 | 402 |
| 398 } // namespace content | 403 } // namespace content |
| OLD | NEW |