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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.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: Fix Charlie's nits 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/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/browser/frame_host/render_frame_host_factory.h" 25 #include "content/browser/frame_host/render_frame_host_factory.h"
26 #include "content/browser/frame_host/render_frame_host_impl.h" 26 #include "content/browser/frame_host/render_frame_host_impl.h"
27 #include "content/browser/frame_host/render_frame_proxy_host.h" 27 #include "content/browser/frame_host/render_frame_proxy_host.h"
28 #include "content/browser/renderer_host/render_process_host_impl.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
29 #include "content/browser/renderer_host/render_view_host_factory.h" 29 #include "content/browser/renderer_host/render_view_host_factory.h"
30 #include "content/browser/renderer_host/render_view_host_impl.h" 30 #include "content/browser/renderer_host/render_view_host_impl.h"
31 #include "content/browser/site_instance_impl.h" 31 #include "content/browser/site_instance_impl.h"
32 #include "content/browser/webui/web_ui_controller_factory_registry.h" 32 #include "content/browser/webui/web_ui_controller_factory_registry.h"
33 #include "content/browser/webui/web_ui_impl.h" 33 #include "content/browser/webui/web_ui_impl.h"
34 #include "content/common/frame_messages.h" 34 #include "content/common/frame_messages.h"
35 #include "content/common/input_messages.h"
35 #include "content/common/site_isolation_policy.h" 36 #include "content/common/site_isolation_policy.h"
36 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
37 #include "content/public/browser/content_browser_client.h" 38 #include "content/public/browser/content_browser_client.h"
38 #include "content/public/browser/render_process_host_observer.h" 39 #include "content/public/browser/render_process_host_observer.h"
39 #include "content/public/browser/render_widget_host_iterator.h" 40 #include "content/public/browser/render_widget_host_iterator.h"
40 #include "content/public/browser/render_widget_host_view.h" 41 #include "content/public/browser/render_widget_host_view.h"
41 #include "content/public/browser/user_metrics.h" 42 #include "content/public/browser/user_metrics.h"
42 #include "content/public/browser/web_ui_controller.h" 43 #include "content/public/browser/web_ui_controller.h"
43 #include "content/public/common/browser_plugin_guest_mode.h" 44 #include "content/public/common/browser_plugin_guest_mode.h"
44 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // If this tree is already on our processing list *and* we have visited it, 77 // If this tree is already on our processing list *and* we have visited it,
77 // then this node's opener is a back link. This means the node will need 78 // then this node's opener is a back link. This means the node will need
78 // special treatment to process its opener. 79 // special treatment to process its opener.
79 size_t position = std::distance(opener_trees->begin(), existing_tree_it); 80 size_t position = std::distance(opener_trees->begin(), existing_tree_it);
80 if (position < visited_index) 81 if (position < visited_index)
81 nodes_with_back_links->insert(node); 82 nodes_with_back_links->insert(node);
82 } 83 }
83 return true; 84 return true;
84 } 85 }
85 86
87 // Helper function that can be used with FrameTree::ForEach to collect
88 // SiteInstances involved in rendering a page, which is a subset of those in
89 // proxy_hosts_ because of openers.
90 bool CollectSiteInstances(std::set<SiteInstance*>* set,
91 FrameTreeNode* node) {
92 set->insert(node->current_frame_host()->GetSiteInstance());
93 return true;
94 }
95
86 } // namespace 96 } // namespace
87 97
88 // A helper class to hold all frame proxies and register as a 98 // A helper class to hold all frame proxies and register as a
89 // RenderProcessHostObserver for them. 99 // RenderProcessHostObserver for them.
90 class RenderFrameHostManager::RenderFrameProxyHostMap 100 class RenderFrameHostManager::RenderFrameProxyHostMap
91 : public RenderProcessHostObserver { 101 : public RenderProcessHostObserver {
92 public: 102 public:
93 using MapType = base::hash_map<int32, RenderFrameProxyHost*>; 103 using MapType = base::hash_map<int32, RenderFrameProxyHost*>;
94 104
95 RenderFrameProxyHostMap(RenderFrameHostManager* manager); 105 RenderFrameProxyHostMap(RenderFrameHostManager* manager);
(...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 false /* is_loading */, FrameReplicationState())); 1995 false /* is_loading */, FrameReplicationState()));
1986 proxy->set_render_frame_proxy_created(true); 1996 proxy->set_render_frame_proxy_created(true);
1987 } 1997 }
1988 1998
1989 void RenderFrameHostManager::SetRWHViewForInnerContents( 1999 void RenderFrameHostManager::SetRWHViewForInnerContents(
1990 RenderWidgetHostView* child_rwhv) { 2000 RenderWidgetHostView* child_rwhv) {
1991 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame()); 2001 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame());
1992 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv); 2002 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv);
1993 } 2003 }
1994 2004
2005 void RenderFrameHostManager::ReplicatePageFocus(bool is_focused) {
nasko 2015/10/16 21:43:44 This doesn't seem to logically belong in this clas
Charlie Reis 2015/10/16 22:03:26 I could see this going either way. It's broadcast
alexmos 2015/10/16 22:56:06 Good suggestion -- moved to FrameTree.
2006 CHECK(frame_tree_node_->IsMainFrame());
2007
2008 std::set<SiteInstance*> frame_tree_site_instances;
2009 frame_tree_node_->frame_tree()->ForEach(
2010 base::Bind(&CollectSiteInstances, &frame_tree_site_instances));
2011
2012 // Notify the proxies for all SiteInstances of other frames in this
2013 // FrameTree. Note that the main frame might also know about proxies in
2014 // SiteInstances for a frame in a different FrameTree (e.g., for
2015 // window.open), so we can't just iterate over proxy_hosts_.
2016 for (const auto& instance : frame_tree_site_instances) {
2017 if (instance == render_frame_host_->GetSiteInstance())
2018 continue;
2019
2020 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
2021 CHECK(proxy);
nasko 2015/10/16 21:44:21 No need to CHECK here, as it will crash on the nex
alexmos 2015/10/16 22:56:06 Done.
2022
2023 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
2024 }
2025 }
2026
1995 bool RenderFrameHostManager::InitRenderView( 2027 bool RenderFrameHostManager::InitRenderView(
1996 RenderViewHostImpl* render_view_host, 2028 RenderViewHostImpl* render_view_host,
1997 int proxy_routing_id) { 2029 int proxy_routing_id) {
1998 // Ensure the renderer process is initialized before creating the 2030 // Ensure the renderer process is initialized before creating the
1999 // RenderView. 2031 // RenderView.
2000 if (!render_view_host->GetProcess()->Init()) 2032 if (!render_view_host->GetProcess()->Init())
2001 return false; 2033 return false;
2002 2034
2003 // We may have initialized this RenderViewHost for another RenderFrameHost. 2035 // We may have initialized this RenderViewHost for another RenderFrameHost.
2004 if (render_view_host->IsRenderViewLive()) 2036 if (render_view_host->IsRenderViewLive())
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2673 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2642 if (!frame_tree_node_->opener()) 2674 if (!frame_tree_node_->opener())
2643 return MSG_ROUTING_NONE; 2675 return MSG_ROUTING_NONE;
2644 2676
2645 return frame_tree_node_->opener() 2677 return frame_tree_node_->opener()
2646 ->render_manager() 2678 ->render_manager()
2647 ->GetRoutingIdForSiteInstance(instance); 2679 ->GetRoutingIdForSiteInstance(instance);
2648 } 2680 }
2649 2681
2650 } // namespace content 2682 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698