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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 202 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
203 this)); | 203 this)); |
204 | 204 |
205 if (is_swapped_out) { | 205 if (is_swapped_out) { |
206 rfh_state_ = STATE_SWAPPED_OUT; | 206 rfh_state_ = STATE_SWAPPED_OUT; |
207 } else { | 207 } else { |
208 rfh_state_ = STATE_DEFAULT; | 208 rfh_state_ = STATE_DEFAULT; |
209 GetSiteInstance()->increment_active_frame_count(); | 209 GetSiteInstance()->increment_active_frame_count(); |
210 } | 210 } |
211 | 211 |
212 if (GetProcess()->GetServiceRegistry()) { | 212 SetUpMojoIfNeeded(); |
213 RenderFrameSetupPtr setup; | |
214 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); | |
215 mojo::ServiceProviderPtr service_provider; | |
216 setup->GetServiceProviderForFrame(routing_id_, | |
217 mojo::GetProxy(&service_provider)); | |
218 service_registry_.BindRemoteServiceProvider( | |
219 service_provider.PassMessagePipe()); | |
220 | |
221 #if defined(OS_ANDROID) | |
222 service_registry_android_.reset( | |
223 new ServiceRegistryAndroid(&service_registry_)); | |
224 #endif | |
225 } | |
226 | 213 |
227 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( | 214 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( |
228 &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr()))); | 215 &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr()))); |
229 } | 216 } |
230 | 217 |
231 RenderFrameHostImpl::~RenderFrameHostImpl() { | 218 RenderFrameHostImpl::~RenderFrameHostImpl() { |
232 GetProcess()->RemoveRoute(routing_id_); | 219 GetProcess()->RemoveRoute(routing_id_); |
233 g_routing_id_frame_map.Get().erase( | 220 g_routing_id_frame_map.Get().erase( |
234 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 221 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
235 | 222 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 Send(new FrameMsg_JavaScriptExecuteRequestForTests(routing_id_, | 302 Send(new FrameMsg_JavaScriptExecuteRequestForTests(routing_id_, |
316 javascript, | 303 javascript, |
317 0, false)); | 304 0, false)); |
318 } | 305 } |
319 | 306 |
320 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 307 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
321 return render_view_host_; | 308 return render_view_host_; |
322 } | 309 } |
323 | 310 |
324 ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() { | 311 ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() { |
325 return &service_registry_; | 312 return service_registry_.get(); |
326 } | 313 } |
327 | 314 |
328 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 315 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
329 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { | 316 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { |
330 return render_view_host_->input_router()->SendInput( | 317 return render_view_host_->input_router()->SendInput( |
331 make_scoped_ptr(message)); | 318 make_scoped_ptr(message)); |
332 } | 319 } |
333 | 320 |
334 // Route IPCs through the RenderFrameProxyHost when in swapped out state. | 321 // Route IPCs through the RenderFrameProxyHost when in swapped out state. |
335 // Note: For subframes in --site-per-process mode, we don't use swapped out | 322 // Note: For subframes in --site-per-process mode, we don't use swapped out |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1435 routing_id_, response->head, body->GetURL(), | 1422 routing_id_, response->head, body->GetURL(), |
1436 common_params, commit_params)); | 1423 common_params, commit_params)); |
1437 // TODO(clamy): Check if we should start the throbber for non javascript urls | 1424 // TODO(clamy): Check if we should start the throbber for non javascript urls |
1438 // here. | 1425 // here. |
1439 | 1426 |
1440 // TODO(clamy): Release the stream handle once the renderer has finished | 1427 // TODO(clamy): Release the stream handle once the renderer has finished |
1441 // reading it. | 1428 // reading it. |
1442 stream_handle_ = body.Pass(); | 1429 stream_handle_ = body.Pass(); |
1443 } | 1430 } |
1444 | 1431 |
1432 void RenderFrameHostImpl::SetUpMojoIfNeeded() { | |
1433 if (service_registry_.get()) | |
1434 return; | |
1435 | |
1436 service_registry_.reset(new ServiceRegistryImpl()); | |
1437 if (!GetProcess()->GetServiceRegistry()) | |
1438 return; | |
1439 | |
1440 RenderFrameSetupPtr setup; | |
1441 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); | |
1442 mojo::ServiceProviderPtr service_provider; | |
1443 setup->GetServiceProviderForFrame(routing_id_, | |
1444 mojo::GetProxy(&service_provider)); | |
1445 service_registry_->BindRemoteServiceProvider( | |
1446 service_provider.PassMessagePipe()); | |
1447 | |
1448 #if defined(OS_ANDROID) | |
1449 service_registry_android_.reset( | |
1450 new ServiceRegistryAndroid(service_registry_.get())); | |
1451 #endif | |
1452 } | |
1453 | |
1454 void RenderFrameHostImpl::InvalidateMojoConnection() { | |
1455 service_registry_.reset(); | |
1456 #if defined(OS_ANDROID) | |
1457 service_registry_android_.reset(); | |
qsr
2014/10/27 11:45:41
This is not that big a deal, but this should be re
| |
1458 #endif | |
1459 } | |
1460 | |
1445 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( | 1461 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( |
1446 int request_id, blink::WebNotificationPermission permission) { | 1462 int request_id, blink::WebNotificationPermission permission) { |
1447 Send(new PlatformNotificationMsg_PermissionRequestComplete( | 1463 Send(new PlatformNotificationMsg_PermissionRequestComplete( |
1448 routing_id_, request_id, permission)); | 1464 routing_id_, request_id, permission)); |
1449 } | 1465 } |
1450 | 1466 |
1451 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( | 1467 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( |
1452 const std::map<int32, int> node_to_frame_routing_id_map) { | 1468 const std::map<int32, int> node_to_frame_routing_id_map) { |
1453 std::map<int32, int>::const_iterator iter; | 1469 std::map<int32, int>::const_iterator iter; |
1454 for (iter = node_to_frame_routing_id_map.begin(); | 1470 for (iter = node_to_frame_routing_id_map.begin(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1597 // Clear any state if a pending navigation is canceled or preempted. | 1613 // Clear any state if a pending navigation is canceled or preempted. |
1598 if (suspended_nav_params_) | 1614 if (suspended_nav_params_) |
1599 suspended_nav_params_.reset(); | 1615 suspended_nav_params_.reset(); |
1600 | 1616 |
1601 TRACE_EVENT_ASYNC_END0("navigation", | 1617 TRACE_EVENT_ASYNC_END0("navigation", |
1602 "RenderFrameHostImpl navigation suspended", this); | 1618 "RenderFrameHostImpl navigation suspended", this); |
1603 navigations_suspended_ = false; | 1619 navigations_suspended_ = false; |
1604 } | 1620 } |
1605 | 1621 |
1606 } // namespace content | 1622 } // namespace content |
OLD | NEW |