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

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

Issue 268543008: Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_proxy_host.h" 5 #include "content/browser/frame_host/render_frame_proxy_host.h"
6 6
7 #include "base/lazy_instance.h"
7 #include "content/browser/frame_host/cross_process_frame_connector.h" 8 #include "content/browser/frame_host/cross_process_frame_connector.h"
8 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
10 #include "content/browser/frame_host/render_frame_host_impl.h" 11 #include "content/browser/frame_host/render_frame_host_impl.h"
11 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 12 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_view_base.h" 14 #include "content/browser/renderer_host/render_widget_host_view_base.h"
14 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
15 #include "content/common/frame_messages.h" 16 #include "content/common/frame_messages.h"
17 #include "content/public/browser/browser_thread.h"
16 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
17 19
18 namespace content { 20 namespace content {
19 21
22 namespace {
23
24 // The (process id, routing id) pair that identifies one RenderFrame.
25 typedef std::pair<int32, int32> RenderFrameProxyHostID;
26 typedef base::hash_map<RenderFrameProxyHostID, RenderFrameProxyHost*>
27 RoutingIDFrameProxyMap;
28 base::LazyInstance<RoutingIDFrameProxyMap> g_routing_id_frame_proxy_map =
29 LAZY_INSTANCE_INITIALIZER;
30
31 }
32
20 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, 33 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance,
21 FrameTreeNode* frame_tree_node) 34 FrameTreeNode* frame_tree_node)
22 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), 35 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()),
23 site_instance_(site_instance), 36 site_instance_(site_instance),
24 frame_tree_node_(frame_tree_node) { 37 frame_tree_node_(frame_tree_node) {
25 GetProcess()->AddRoute(routing_id_, this); 38 GetProcess()->AddRoute(routing_id_, this);
39 g_routing_id_frame_proxy_map.Get().insert(std::make_pair(
nasko 2014/08/25 21:23:29 nit: I like checking the return value of insert, j
dmazzoni 2014/08/26 23:31:03 Is this what you had in mind? DCHECK(g_routing_
Charlie Reis 2014/08/27 17:28:34 You'll need to store the return value and DCHECK(r
40 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), this));
26 41
27 if (!frame_tree_node_->IsMainFrame() && 42 if (!frame_tree_node_->IsMainFrame() &&
28 frame_tree_node_->parent() 43 frame_tree_node_->parent()
29 ->render_manager() 44 ->render_manager()
30 ->current_frame_host() 45 ->current_frame_host()
31 ->GetSiteInstance() == site_instance) { 46 ->GetSiteInstance() == site_instance) {
32 // The RenderFrameHost navigating cross-process is destroyed and a proxy for 47 // The RenderFrameHost navigating cross-process is destroyed and a proxy for
33 // it is created in the parent's process. CrossProcessFrameConnector 48 // it is created in the parent's process. CrossProcessFrameConnector
34 // initialization only needs to happen on an initial cross-process 49 // initialization only needs to happen on an initial cross-process
35 // navigation, when the RenderFrameHost leaves the same process as its 50 // navigation, when the RenderFrameHost leaves the same process as its
36 // parent. The same CrossProcessFrameConnector is used for subsequent cross- 51 // parent. The same CrossProcessFrameConnector is used for subsequent cross-
37 // process navigations, but it will be destroyed if the frame is 52 // process navigations, but it will be destroyed if the frame is
38 // navigated back to the same SiteInstance as its parent. 53 // navigated back to the same SiteInstance as its parent.
39 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); 54 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this));
40 } 55 }
41 } 56 }
42 57
43 RenderFrameProxyHost::~RenderFrameProxyHost() { 58 RenderFrameProxyHost::~RenderFrameProxyHost() {
44 if (GetProcess()->HasConnection()) 59 if (GetProcess()->HasConnection())
45 Send(new FrameMsg_DeleteProxy(routing_id_)); 60 Send(new FrameMsg_DeleteProxy(routing_id_));
46 61
47 GetProcess()->RemoveRoute(routing_id_); 62 GetProcess()->RemoveRoute(routing_id_);
63 g_routing_id_frame_proxy_map.Get().erase(
64 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_));
48 } 65 }
49 66
50 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { 67 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) {
51 cross_process_frame_connector_->set_view( 68 cross_process_frame_connector_->set_view(
52 static_cast<RenderWidgetHostViewChildFrame*>(view)); 69 static_cast<RenderWidgetHostViewChildFrame*>(view));
53 } 70 }
54 71
55 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() { 72 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() {
56 if (render_frame_host_.get()) 73 if (render_frame_host_.get())
57 return render_frame_host_->render_view_host(); 74 return render_frame_host_->render_view_host();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 120
104 Send(new FrameMsg_NewFrameProxy( 121 Send(new FrameMsg_NewFrameProxy(
105 routing_id_, 122 routing_id_,
106 parent_routing_id, 123 parent_routing_id,
107 frame_tree_node_->frame_tree()->GetRenderViewHost( 124 frame_tree_node_->frame_tree()->GetRenderViewHost(
108 site_instance_)->GetRoutingID())); 125 site_instance_)->GetRoutingID()));
109 126
110 return true; 127 return true;
111 } 128 }
112 129
130 // static
131 RenderFrameProxyHost* RenderFrameProxyHost::FromID(int process_id,
nasko 2014/08/25 21:23:29 nit: static methods should be at the top of the fi
dmazzoni 2014/08/26 23:31:03 Done.
132 int routing_id) {
133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
134 RoutingIDFrameProxyMap* frames = g_routing_id_frame_proxy_map.Pointer();
135 RoutingIDFrameProxyMap::iterator it = frames->find(
136 RenderFrameProxyHostID(process_id, routing_id));
137 return it == frames->end() ? NULL : it->second;
138 }
139
113 } // namespace content 140 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698