OLD | NEW |
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_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
11 #include "content/browser/child_process_security_policy_impl.h" | 11 #include "content/browser/child_process_security_policy_impl.h" |
12 #include "content/browser/frame_host/cross_process_frame_connector.h" | 12 #include "content/browser/frame_host/cross_process_frame_connector.h" |
13 #include "content/browser/frame_host/cross_site_transferring_request.h" | 13 #include "content/browser/frame_host/cross_site_transferring_request.h" |
14 #include "content/browser/frame_host/frame_tree.h" | 14 #include "content/browser/frame_host/frame_tree.h" |
15 #include "content/browser/frame_host/frame_tree_node.h" | 15 #include "content/browser/frame_host/frame_tree_node.h" |
16 #include "content/browser/frame_host/navigator.h" | 16 #include "content/browser/frame_host/navigator.h" |
17 #include "content/browser/frame_host/render_frame_host_delegate.h" | 17 #include "content/browser/frame_host/render_frame_host_delegate.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/input/input_router.h" | 19 #include "content/browser/renderer_host/input/input_router.h" |
20 #include "content/browser/renderer_host/input/timeout_monitor.h" | 20 #include "content/browser/renderer_host/input/timeout_monitor.h" |
21 #include "content/browser/renderer_host/render_view_host_impl.h" | 21 #include "content/browser/renderer_host/render_view_host_impl.h" |
22 #include "content/browser/renderer_host/render_widget_host_impl.h" | 22 #include "content/browser/renderer_host/render_widget_host_impl.h" |
23 #include "content/common/desktop_notification_messages.h" | 23 #include "content/common/desktop_notification_messages.h" |
24 #include "content/common/frame_messages.h" | 24 #include "content/common/frame_messages.h" |
25 #include "content/common/input_messages.h" | 25 #include "content/common/input_messages.h" |
26 #include "content/common/inter_process_time_ticks_converter.h" | 26 #include "content/common/inter_process_time_ticks_converter.h" |
| 27 #include "content/common/render_frame_setup.mojom.h" |
27 #include "content/common/swapped_out_messages.h" | 28 #include "content/common/swapped_out_messages.h" |
28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
30 #include "content/public/browser/desktop_notification_delegate.h" | 31 #include "content/public/browser/desktop_notification_delegate.h" |
31 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/render_widget_host_view.h" | 33 #include "content/public/browser/render_widget_host_view.h" |
33 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
34 #include "content/public/common/content_constants.h" | 35 #include "content/public/common/content_constants.h" |
35 #include "content/public/common/url_constants.h" | 36 #include "content/public/common/url_constants.h" |
36 #include "content/public/common/url_utils.h" | 37 #include "content/public/common/url_utils.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 case blink::WebTextDirectionLeftToRight: | 117 case blink::WebTextDirectionLeftToRight: |
117 return base::i18n::LEFT_TO_RIGHT; | 118 return base::i18n::LEFT_TO_RIGHT; |
118 case blink::WebTextDirectionRightToLeft: | 119 case blink::WebTextDirectionRightToLeft: |
119 return base::i18n::RIGHT_TO_LEFT; | 120 return base::i18n::RIGHT_TO_LEFT; |
120 default: | 121 default: |
121 NOTREACHED(); | 122 NOTREACHED(); |
122 return base::i18n::UNKNOWN_DIRECTION; | 123 return base::i18n::UNKNOWN_DIRECTION; |
123 } | 124 } |
124 } | 125 } |
125 | 126 |
| 127 class RenderFrameSetupImpl : public mojo::InterfaceImpl<RenderFrameSetup> { |
| 128 public: |
| 129 explicit RenderFrameSetupImpl(int process_id) : process_id_(process_id) {} |
| 130 |
| 131 virtual void ConnectToInterfaceProvider( |
| 132 int32_t view_routing_id, |
| 133 mojo::InterfaceRequest<mojo::IInterfaceProvider> |
| 134 interface_provider_request) OVERRIDE { |
| 135 RenderFrameHostImpl* frame_host = static_cast<RenderFrameHostImpl*>( |
| 136 RenderFrameHost::FromID(process_id_, view_routing_id)); |
| 137 if (!frame_host) |
| 138 return; |
| 139 |
| 140 frame_host->BindServiceRegistry( |
| 141 interface_provider_request.PassMessagePipe()); |
| 142 } |
| 143 |
| 144 virtual void OnConnectionError() OVERRIDE { delete this; } |
| 145 |
| 146 private: |
| 147 const int process_id_; |
| 148 }; |
| 149 |
| 150 void CreateRenderFrameHostSetup(int process_id, |
| 151 mojo::ScopedMessagePipeHandle handle) { |
| 152 mojo::BindToPipe(new RenderFrameSetupImpl(process_id), handle.Pass()); |
| 153 } |
| 154 |
126 } // namespace | 155 } // namespace |
127 | 156 |
128 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, | 157 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, |
129 int render_frame_id) { | 158 int render_frame_id) { |
130 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | 159 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
131 } | 160 } |
132 | 161 |
133 // static | 162 // static |
134 RenderFrameHostImpl* RenderFrameHostImpl::FromID( | 163 RenderFrameHostImpl* RenderFrameHostImpl::FromID( |
135 int process_id, int routing_id) { | 164 int process_id, int routing_id) { |
(...skipping 18 matching lines...) Expand all Loading... |
154 frame_tree_(frame_tree), | 183 frame_tree_(frame_tree), |
155 frame_tree_node_(frame_tree_node), | 184 frame_tree_node_(frame_tree_node), |
156 routing_id_(routing_id), | 185 routing_id_(routing_id), |
157 is_swapped_out_(is_swapped_out), | 186 is_swapped_out_(is_swapped_out), |
158 weak_ptr_factory_(this) { | 187 weak_ptr_factory_(this) { |
159 frame_tree_->RegisterRenderFrameHost(this); | 188 frame_tree_->RegisterRenderFrameHost(this); |
160 GetProcess()->AddRoute(routing_id_, this); | 189 GetProcess()->AddRoute(routing_id_, this); |
161 g_routing_id_frame_map.Get().insert(std::make_pair( | 190 g_routing_id_frame_map.Get().insert(std::make_pair( |
162 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 191 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
163 this)); | 192 this)); |
| 193 |
| 194 if (GetProcess()->GetServiceRegistry()) { |
| 195 GetProcess()->GetServiceRegistry()->AddService<RenderFrameSetup>( |
| 196 base::Bind(CreateRenderFrameHostSetup, GetProcess()->GetID())); |
| 197 } |
164 } | 198 } |
165 | 199 |
166 RenderFrameHostImpl::~RenderFrameHostImpl() { | 200 RenderFrameHostImpl::~RenderFrameHostImpl() { |
167 GetProcess()->RemoveRoute(routing_id_); | 201 GetProcess()->RemoveRoute(routing_id_); |
168 g_routing_id_frame_map.Get().erase( | 202 g_routing_id_frame_map.Get().erase( |
169 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 203 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
170 if (delegate_) | 204 if (delegate_) |
171 delegate_->RenderFrameDeleted(this); | 205 delegate_->RenderFrameDeleted(this); |
172 | 206 |
173 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 207 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 Send(new FrameMsg_JavaScriptExecuteRequest(routing_id_, | 268 Send(new FrameMsg_JavaScriptExecuteRequest(routing_id_, |
235 javascript, | 269 javascript, |
236 key, true)); | 270 key, true)); |
237 javascript_callbacks_.insert(std::make_pair(key, callback)); | 271 javascript_callbacks_.insert(std::make_pair(key, callback)); |
238 } | 272 } |
239 | 273 |
240 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 274 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
241 return render_view_host_; | 275 return render_view_host_; |
242 } | 276 } |
243 | 277 |
| 278 ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() { |
| 279 return &service_registry_; |
| 280 } |
| 281 |
244 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 282 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
245 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { | 283 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { |
246 return render_view_host_->input_router()->SendInput( | 284 return render_view_host_->input_router()->SendInput( |
247 make_scoped_ptr(message)); | 285 make_scoped_ptr(message)); |
248 } | 286 } |
249 | 287 |
250 if (render_view_host_->IsSwappedOut()) { | 288 if (render_view_host_->IsSwappedOut()) { |
251 DCHECK(render_frame_proxy_host_); | 289 DCHECK(render_frame_proxy_host_); |
252 return render_frame_proxy_host_->Send(message); | 290 return render_frame_proxy_host_->Send(message); |
253 } | 291 } |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 void RenderFrameHostImpl::NotificationClosed(int notification_id) { | 927 void RenderFrameHostImpl::NotificationClosed(int notification_id) { |
890 cancel_notification_callbacks_.erase(notification_id); | 928 cancel_notification_callbacks_.erase(notification_id); |
891 } | 929 } |
892 | 930 |
893 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( | 931 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( |
894 int callback_context) { | 932 int callback_context) { |
895 Send(new DesktopNotificationMsg_PermissionRequestDone( | 933 Send(new DesktopNotificationMsg_PermissionRequestDone( |
896 routing_id_, callback_context)); | 934 routing_id_, callback_context)); |
897 } | 935 } |
898 | 936 |
| 937 void RenderFrameHostImpl::BindServiceRegistry( |
| 938 mojo::ScopedMessagePipeHandle shell_handle) { |
| 939 service_registry_.Bind(shell_handle.Pass()); |
| 940 } |
| 941 |
899 } // namespace content | 942 } // namespace content |
OLD | NEW |