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" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "content/browser/accessibility/accessibility_mode_helper.h" | 14 #include "content/browser/accessibility/accessibility_mode_helper.h" |
15 #include "content/browser/accessibility/browser_accessibility_manager.h" | 15 #include "content/browser/accessibility/browser_accessibility_manager.h" |
16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
17 #include "content/browser/child_process_security_policy_impl.h" | 17 #include "content/browser/child_process_security_policy_impl.h" |
18 #include "content/browser/frame_host/cross_process_frame_connector.h" | 18 #include "content/browser/frame_host/cross_process_frame_connector.h" |
19 #include "content/browser/frame_host/cross_site_transferring_request.h" | 19 #include "content/browser/frame_host/cross_site_transferring_request.h" |
20 #include "content/browser/frame_host/frame_accessibility.h" | 20 #include "content/browser/frame_host/frame_accessibility.h" |
21 #include "content/browser/frame_host/frame_tree.h" | 21 #include "content/browser/frame_host/frame_tree.h" |
22 #include "content/browser/frame_host/frame_tree_node.h" | 22 #include "content/browser/frame_host/frame_tree_node.h" |
23 #include "content/browser/frame_host/navigator.h" | 23 #include "content/browser/frame_host/navigator.h" |
24 #include "content/browser/frame_host/render_frame_host_delegate.h" | 24 #include "content/browser/frame_host/render_frame_host_delegate.h" |
25 #include "content/browser/frame_host/render_frame_proxy_host.h" | 25 #include "content/browser/frame_host/render_frame_proxy_host.h" |
26 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 26 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
27 #include "content/browser/geolocation/geolocation_service_context.h" | |
27 #include "content/browser/renderer_host/input/input_router.h" | 28 #include "content/browser/renderer_host/input/input_router.h" |
28 #include "content/browser/renderer_host/input/timeout_monitor.h" | 29 #include "content/browser/renderer_host/input/timeout_monitor.h" |
29 #include "content/browser/renderer_host/render_process_host_impl.h" | 30 #include "content/browser/renderer_host/render_process_host_impl.h" |
30 #include "content/browser/renderer_host/render_view_host_delegate.h" | 31 #include "content/browser/renderer_host/render_view_host_delegate.h" |
31 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 32 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
32 #include "content/browser/renderer_host/render_view_host_impl.h" | 33 #include "content/browser/renderer_host/render_view_host_impl.h" |
33 #include "content/browser/renderer_host/render_widget_host_impl.h" | 34 #include "content/browser/renderer_host/render_widget_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 35 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
35 #include "content/browser/transition_request_manager.h" | 36 #include "content/browser/transition_request_manager.h" |
36 #include "content/common/accessibility_messages.h" | 37 #include "content/common/accessibility_messages.h" |
37 #include "content/common/desktop_notification_messages.h" | 38 #include "content/common/desktop_notification_messages.h" |
38 #include "content/common/frame_messages.h" | 39 #include "content/common/frame_messages.h" |
39 #include "content/common/input_messages.h" | 40 #include "content/common/input_messages.h" |
40 #include "content/common/inter_process_time_ticks_converter.h" | 41 #include "content/common/inter_process_time_ticks_converter.h" |
41 #include "content/common/navigation_params.h" | 42 #include "content/common/navigation_params.h" |
42 #include "content/common/platform_notification_messages.h" | 43 #include "content/common/platform_notification_messages.h" |
43 #include "content/common/render_frame_setup.mojom.h" | |
44 #include "content/common/swapped_out_messages.h" | 44 #include "content/common/swapped_out_messages.h" |
45 #include "content/public/browser/ax_event_notification_details.h" | 45 #include "content/public/browser/ax_event_notification_details.h" |
46 #include "content/public/browser/browser_accessibility_state.h" | 46 #include "content/public/browser/browser_accessibility_state.h" |
47 #include "content/public/browser/browser_context.h" | 47 #include "content/public/browser/browser_context.h" |
48 #include "content/public/browser/browser_plugin_guest_manager.h" | 48 #include "content/public/browser/browser_plugin_guest_manager.h" |
49 #include "content/public/browser/browser_thread.h" | 49 #include "content/public/browser/browser_thread.h" |
50 #include "content/public/browser/content_browser_client.h" | 50 #include "content/public/browser/content_browser_client.h" |
51 #include "content/public/browser/desktop_notification_delegate.h" | 51 #include "content/public/browser/desktop_notification_delegate.h" |
52 #include "content/public/browser/render_process_host.h" | 52 #include "content/public/browser/render_process_host.h" |
53 #include "content/public/browser/render_widget_host_view.h" | 53 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 this)); | 197 this)); |
198 | 198 |
199 if (is_swapped_out) { | 199 if (is_swapped_out) { |
200 rfh_state_ = STATE_SWAPPED_OUT; | 200 rfh_state_ = STATE_SWAPPED_OUT; |
201 } else { | 201 } else { |
202 rfh_state_ = STATE_DEFAULT; | 202 rfh_state_ = STATE_DEFAULT; |
203 GetSiteInstance()->increment_active_frame_count(); | 203 GetSiteInstance()->increment_active_frame_count(); |
204 } | 204 } |
205 | 205 |
206 if (GetProcess()->GetServiceRegistry()) { | 206 if (GetProcess()->GetServiceRegistry()) { |
207 RenderFrameSetupPtr setup; | 207 RegisterMojoServices(); |
208 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); | 208 GetProcess()->GetServiceRegistry()->ConnectToRemoteService( |
209 &render_frame_setup_); | |
209 mojo::ServiceProviderPtr service_provider; | 210 mojo::ServiceProviderPtr service_provider; |
210 setup->GetServiceProviderForFrame(routing_id_, | 211 render_frame_setup_->GetServiceProviderForFrame( |
211 mojo::GetProxy(&service_provider)); | 212 routing_id_, mojo::GetProxy(&service_provider)); |
212 service_registry_.BindRemoteServiceProvider( | 213 service_registry_.BindRemoteServiceProvider( |
213 service_provider.PassMessagePipe()); | 214 service_provider.PassMessagePipe()); |
214 | 215 |
215 #if defined(OS_ANDROID) | 216 #if defined(OS_ANDROID) |
216 service_registry_android_.reset( | 217 service_registry_android_.reset( |
217 new ServiceRegistryAndroid(&service_registry_)); | 218 new ServiceRegistryAndroid(&service_registry_)); |
218 #endif | 219 #endif |
219 } | 220 } |
220 | 221 |
221 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( | 222 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 } | 1191 } |
1191 | 1192 |
1192 void RenderFrameHostImpl::OnHidePopup() { | 1193 void RenderFrameHostImpl::OnHidePopup() { |
1193 RenderViewHostDelegateView* view = | 1194 RenderViewHostDelegateView* view = |
1194 render_view_host_->delegate_->GetDelegateView(); | 1195 render_view_host_->delegate_->GetDelegateView(); |
1195 if (view) | 1196 if (view) |
1196 view->HidePopupMenu(); | 1197 view->HidePopupMenu(); |
1197 } | 1198 } |
1198 #endif | 1199 #endif |
1199 | 1200 |
1201 void RenderFrameHostImpl::RegisterMojoServices() { | |
1202 GeolocationServiceContext* geolocation_service_context = | |
1203 delegate_ ? delegate_->GetGeolocationServiceContext() : NULL; | |
1204 if (geolocation_service_context) { | |
1205 GetServiceRegistry()->AddService<GeolocationService>( | |
1206 base::Bind(&GeolocationServiceContext::CreateService, | |
1207 base::Unretained(geolocation_service_context), | |
1208 base::Bind(&RenderFrameHostImpl::DidUseGeolocationPermission, | |
1209 base::Unretained(this)))); | |
1210 } | |
1211 } | |
1212 | |
1200 void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) { | 1213 void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) { |
1201 // Only main frames should be swapped out and retained inside a proxy host. | 1214 // Only main frames should be swapped out and retained inside a proxy host. |
1202 if (rfh_state == STATE_SWAPPED_OUT) | 1215 if (rfh_state == STATE_SWAPPED_OUT) |
1203 CHECK(!GetParent()); | 1216 CHECK(!GetParent()); |
1204 | 1217 |
1205 // We update the number of RenderFrameHosts in a SiteInstance when the swapped | 1218 // We update the number of RenderFrameHosts in a SiteInstance when the swapped |
1206 // out status of a RenderFrameHost gets flipped to/from active. | 1219 // out status of a RenderFrameHost gets flipped to/from active. |
1207 if (!IsRFHStateActive(rfh_state_) && IsRFHStateActive(rfh_state)) | 1220 if (!IsRFHStateActive(rfh_state_) && IsRFHStateActive(rfh_state)) |
1208 GetSiteInstance()->increment_active_frame_count(); | 1221 GetSiteInstance()->increment_active_frame_count(); |
1209 else if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state)) | 1222 else if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state)) |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1563 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1576 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1564 // Clear any state if a pending navigation is canceled or preempted. | 1577 // Clear any state if a pending navigation is canceled or preempted. |
1565 if (suspended_nav_params_) | 1578 if (suspended_nav_params_) |
1566 suspended_nav_params_.reset(); | 1579 suspended_nav_params_.reset(); |
1567 | 1580 |
1568 TRACE_EVENT_ASYNC_END0("navigation", | 1581 TRACE_EVENT_ASYNC_END0("navigation", |
1569 "RenderFrameHostImpl navigation suspended", this); | 1582 "RenderFrameHostImpl navigation suspended", this); |
1570 navigations_suspended_ = false; | 1583 navigations_suspended_ = false; |
1571 } | 1584 } |
1572 | 1585 |
1586 void RenderFrameHostImpl::DidUseGeolocationPermission() { | |
1587 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | |
blundell
2014/10/23 13:19:59
Charlie, could you just confirm that this is corre
Charlie Reis
2014/10/23 17:27:17
Yep, that works.
| |
1588 GetContentClient()->browser()->DidUseGeolocationPermission( | |
1589 delegate_->GetAsWebContents(), | |
1590 GetLastCommittedURL().GetOrigin(), | |
1591 top_frame->GetLastCommittedURL().GetOrigin()); | |
1592 } | |
1593 | |
1573 } // namespace content | 1594 } // namespace content |
OLD | NEW |