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

Side by Side 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 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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "content/browser/frame_host/frame_tree_node.h" 14 #include "content/browser/frame_host/frame_tree_node.h"
15 #include "content/browser/frame_host/navigator.h" 15 #include "content/browser/frame_host/navigator.h"
16 #include "content/browser/frame_host/render_frame_host_factory.h" 16 #include "content/browser/frame_host/render_frame_host_factory.h"
17 #include "content/browser/frame_host/render_frame_host_impl.h" 17 #include "content/browser/frame_host/render_frame_host_impl.h"
18 #include "content/browser/frame_host/render_frame_proxy_host.h" 18 #include "content/browser/frame_host/render_frame_proxy_host.h"
19 #include "content/browser/renderer_host/render_view_host_factory.h" 19 #include "content/browser/renderer_host/render_view_host_factory.h"
20 #include "content/browser/renderer_host/render_view_host_impl.h" 20 #include "content/browser/renderer_host/render_view_host_impl.h"
21 #include "content/common/input_messages.h"
21 #include "content/common/site_isolation_policy.h" 22 #include "content/common/site_isolation_policy.h"
22 #include "third_party/WebKit/public/web/WebSandboxFlags.h" 23 #include "third_party/WebKit/public/web/WebSandboxFlags.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace { 27 namespace {
27 28
28 // Used with FrameTree::ForEach() to search for the FrameTreeNode 29 // Used with FrameTree::ForEach() to search for the FrameTreeNode
29 // corresponding to |frame_tree_node_id| within a specific FrameTree. 30 // corresponding to |frame_tree_node_id| within a specific FrameTree.
30 bool FrameTreeNodeForId(int frame_tree_node_id, 31 bool FrameTreeNodeForId(int frame_tree_node_id,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // the nodes is loading. 88 // the nodes is loading.
88 bool IsNodeLoading(bool* is_loading, FrameTreeNode* node) { 89 bool IsNodeLoading(bool* is_loading, FrameTreeNode* node) {
89 if (node->IsLoading()) { 90 if (node->IsLoading()) {
90 // There is at least one node loading, so abort traversal. 91 // There is at least one node loading, so abort traversal.
91 *is_loading = true; 92 *is_loading = true;
92 return false; 93 return false;
93 } 94 }
94 return true; 95 return true;
95 } 96 }
96 97
98 // Helper function used with FrameTree::ForEach to collect SiteInstances
99 // involved in rendering a single FrameTree (which is a subset of SiteInstances
100 // in main frame's proxy_hosts_ because of openers).
101 bool CollectSiteInstances(std::set<SiteInstance*>* set, FrameTreeNode* node) {
102 set->insert(node->current_frame_host()->GetSiteInstance());
103 return true;
104 }
105
97 } // namespace 106 } // namespace
98 107
99 FrameTree::FrameTree(Navigator* navigator, 108 FrameTree::FrameTree(Navigator* navigator,
100 RenderFrameHostDelegate* render_frame_delegate, 109 RenderFrameHostDelegate* render_frame_delegate,
101 RenderViewHostDelegate* render_view_delegate, 110 RenderViewHostDelegate* render_view_delegate,
102 RenderWidgetHostDelegate* render_widget_delegate, 111 RenderWidgetHostDelegate* render_widget_delegate,
103 RenderFrameHostManager::Delegate* manager_delegate) 112 RenderFrameHostManager::Delegate* manager_delegate)
104 : render_frame_delegate_(render_frame_delegate), 113 : render_frame_delegate_(render_frame_delegate),
105 render_view_delegate_(render_view_delegate), 114 render_view_delegate_(render_view_delegate),
106 render_widget_delegate_(render_widget_delegate), 115 render_widget_delegate_(render_widget_delegate),
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 ForEach(base::Bind(&ResetNodeLoadProgress)); 413 ForEach(base::Bind(&ResetNodeLoadProgress));
405 load_progress_ = 0.0; 414 load_progress_ = 0.0;
406 } 415 }
407 416
408 bool FrameTree::IsLoading() { 417 bool FrameTree::IsLoading() {
409 bool is_loading = false; 418 bool is_loading = false;
410 ForEach(base::Bind(&IsNodeLoading, &is_loading)); 419 ForEach(base::Bind(&IsNodeLoading, &is_loading));
411 return is_loading; 420 return is_loading;
412 } 421 }
413 422
423 void FrameTree::ReplicatePageFocus(bool is_focused) {
424 std::set<SiteInstance*> frame_tree_site_instances;
425 ForEach(base::Bind(&CollectSiteInstances, &frame_tree_site_instances));
426
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
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
431 // RenderFrameHostManager.
432 for (const auto& instance : frame_tree_site_instances) {
433 if (instance == root_->current_frame_host()->GetSiteInstance())
434 continue;
435
436 RenderFrameProxyHost* proxy =
437 root_->render_manager()->GetRenderFrameProxyHost(instance);
438 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
439 }
440 }
441
414 } // namespace content 442 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698