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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/frame_tree.cc
diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc
index ac61afa5240b7d354ad2e4f6b558483f6fb19930..91a5c18d86a15a6bc0db3d2425fad6c6ea216275 100644
--- a/content/browser/frame_host/frame_tree.cc
+++ b/content/browser/frame_host/frame_tree.cc
@@ -429,12 +429,19 @@ void FrameTree::ReplicatePageFocus(bool is_focused) {
// about proxies in SiteInstances for frames in a different FrameTree (e.g.,
// for window.open), so we can't just iterate over its proxy_hosts_ in
// RenderFrameHostManager.
- for (const auto& instance : frame_tree_site_instances) {
- if (instance == root_->current_frame_host()->GetSiteInstance())
- continue;
+ for (const auto& instance : frame_tree_site_instances)
+ SetPageFocus(instance, is_focused);
+}
+
+void FrameTree::SetPageFocus(SiteInstance* instance, bool is_focused) {
+ RenderFrameHostManager* root_manager = root_->render_manager();
+ // 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.
+ // subframes, and requests to set focus in main frame's SiteInstance are
+ // ignored.
+ if (instance != root_manager->current_frame_host()->GetSiteInstance()) {
RenderFrameProxyHost* proxy =
- root_->render_manager()->GetRenderFrameProxyHost(instance);
+ root_manager->GetRenderFrameProxyHost(instance);
proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
}
}

Powered by Google App Engine
This is Rietveld 408576698