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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 422 |
423 void FrameTree::ReplicatePageFocus(bool is_focused) { | 423 void FrameTree::ReplicatePageFocus(bool is_focused) { |
424 std::set<SiteInstance*> frame_tree_site_instances; | 424 std::set<SiteInstance*> frame_tree_site_instances; |
425 ForEach(base::Bind(&CollectSiteInstances, &frame_tree_site_instances)); | 425 ForEach(base::Bind(&CollectSiteInstances, &frame_tree_site_instances)); |
426 | 426 |
427 // Send the focus update to main frame's proxies in all SiteInstances of | 427 // Send the focus update to main frame's proxies in all SiteInstances of |
428 // other frames in this FrameTree. Note that the main frame might also know | 428 // other frames in this FrameTree. Note that the main frame might also know |
429 // about proxies in SiteInstances for frames in a different FrameTree (e.g., | 429 // about proxies in SiteInstances for frames in a different FrameTree (e.g., |
430 // for window.open), so we can't just iterate over its proxy_hosts_ in | 430 // for window.open), so we can't just iterate over its proxy_hosts_ in |
431 // RenderFrameHostManager. | 431 // RenderFrameHostManager. |
432 for (const auto& instance : frame_tree_site_instances) { | 432 for (const auto& instance : frame_tree_site_instances) |
433 if (instance == root_->current_frame_host()->GetSiteInstance()) | 433 SetPageFocus(instance, is_focused); |
434 continue; | 434 } |
435 | 435 |
| 436 void FrameTree::SetPageFocus(SiteInstance* instance, bool is_focused) { |
| 437 RenderFrameHostManager* root_manager = root_->render_manager(); |
| 438 |
| 439 // 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. |
| 441 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
436 RenderFrameProxyHost* proxy = | 442 RenderFrameProxyHost* proxy = |
437 root_->render_manager()->GetRenderFrameProxyHost(instance); | 443 root_manager->GetRenderFrameProxyHost(instance); |
438 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 444 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
439 } | 445 } |
440 } | 446 } |
441 | 447 |
442 } // namespace content | 448 } // namespace content |
OLD | NEW |