Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: content/browser/frame_host/frame_tree.cc

Issue 1406103005: Preserve page-level focus for subframe cross-process navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus-page
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Currently, this is only used to set page-level focus in cross-process
Charlie Reis 2015/10/23 21:41:52 nit: Drop "Currently"
alexmos 2015/10/24 00:41:43 Done.
440 // subframes, and requests to set focus in main frame's SiteInstance are
441 // ignored.
442 if (instance != root_manager->current_frame_host()->GetSiteInstance()) {
436 RenderFrameProxyHost* proxy = 443 RenderFrameProxyHost* proxy =
437 root_->render_manager()->GetRenderFrameProxyHost(instance); 444 root_manager->GetRenderFrameProxyHost(instance);
438 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); 445 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
439 } 446 }
440 } 447 }
441 448
442 } // namespace content 449 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698