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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 RenderFrameHostImpl* FrameTree::GetMainFrame() const { | 251 RenderFrameHostImpl* FrameTree::GetMainFrame() const { |
252 return root_->current_frame_host(); | 252 return root_->current_frame_host(); |
253 } | 253 } |
254 | 254 |
255 FrameTreeNode* FrameTree::GetFocusedFrame() { | 255 FrameTreeNode* FrameTree::GetFocusedFrame() { |
256 return FindByID(focused_frame_tree_node_id_); | 256 return FindByID(focused_frame_tree_node_id_); |
257 } | 257 } |
258 | 258 |
259 void FrameTree::SetFocusedFrame(FrameTreeNode* node) { | 259 void FrameTree::SetFocusedFrame(FrameTreeNode* node) { |
| 260 // If the focused frame changed across processes, send a message to the old |
| 261 // focused frame's renderer process to clear focus from that frame and fire |
| 262 // blur events. |
| 263 FrameTreeNode* oldFocusedFrame = GetFocusedFrame(); |
| 264 if (oldFocusedFrame && |
| 265 oldFocusedFrame->current_frame_host()->GetSiteInstance() != |
| 266 node->current_frame_host()->GetSiteInstance()) { |
| 267 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 268 oldFocusedFrame->current_frame_host()->ClearFocus(); |
| 269 } |
| 270 |
260 node->set_last_focus_time(base::TimeTicks::Now()); | 271 node->set_last_focus_time(base::TimeTicks::Now()); |
261 focused_frame_tree_node_id_ = node->frame_tree_node_id(); | 272 focused_frame_tree_node_id_ = node->frame_tree_node_id(); |
262 } | 273 } |
263 | 274 |
264 void FrameTree::SetFrameRemoveListener( | 275 void FrameTree::SetFrameRemoveListener( |
265 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { | 276 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { |
266 on_frame_removed_ = on_frame_removed; | 277 on_frame_removed_ = on_frame_removed; |
267 } | 278 } |
268 | 279 |
269 RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance, | 280 RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 load_progress_ = 0.0; | 403 load_progress_ = 0.0; |
393 } | 404 } |
394 | 405 |
395 bool FrameTree::IsLoading() { | 406 bool FrameTree::IsLoading() { |
396 bool is_loading = false; | 407 bool is_loading = false; |
397 ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 408 ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
398 return is_loading; | 409 return is_loading; |
399 } | 410 } |
400 | 411 |
401 } // namespace content | 412 } // namespace content |
OLD | NEW |