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

Unified Diff: content/browser/frame_host/frame_tree.cc

Issue 1394383002: OOPIF: Send page-level focus messages to all processes rendering a page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move ReplicatePageFocus to FrameTree 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 742b84782e2c6d9aa162283123632f97480b0815..ac61afa5240b7d354ad2e4f6b558483f6fb19930 100644
--- a/content/browser/frame_host/frame_tree.cc
+++ b/content/browser/frame_host/frame_tree.cc
@@ -18,6 +18,7 @@
#include "content/browser/frame_host/render_frame_proxy_host.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/common/input_messages.h"
#include "content/common/site_isolation_policy.h"
#include "third_party/WebKit/public/web/WebSandboxFlags.h"
@@ -94,6 +95,14 @@ bool IsNodeLoading(bool* is_loading, FrameTreeNode* node) {
return true;
}
+// Helper function used with FrameTree::ForEach to collect SiteInstances
+// involved in rendering a single FrameTree (which is a subset of SiteInstances
+// in main frame's proxy_hosts_ because of openers).
+bool CollectSiteInstances(std::set<SiteInstance*>* set, FrameTreeNode* node) {
+ set->insert(node->current_frame_host()->GetSiteInstance());
+ return true;
+}
+
} // namespace
FrameTree::FrameTree(Navigator* navigator,
@@ -411,4 +420,23 @@ bool FrameTree::IsLoading() {
return is_loading;
}
+void FrameTree::ReplicatePageFocus(bool is_focused) {
+ std::set<SiteInstance*> frame_tree_site_instances;
+ ForEach(base::Bind(&CollectSiteInstances, &frame_tree_site_instances));
+
+ // Send the focus update to main frame's proxies in all SiteInstances of
+ // other frames in this FrameTree. Note that the main frame might also know
+ // 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;
+
+ RenderFrameProxyHost* proxy =
+ root_->render_manager()->GetRenderFrameProxyHost(instance);
+ proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698