Chromium Code Reviews| 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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1188 } | 1189 } |
| 1189 | 1190 |
| 1190 void RenderFrameHostImpl::OnHidePopup() { | 1191 void RenderFrameHostImpl::OnHidePopup() { |
| 1191 RenderViewHostDelegateView* view = | 1192 RenderViewHostDelegateView* view = |
| 1192 render_view_host_->delegate_->GetDelegateView(); | 1193 render_view_host_->delegate_->GetDelegateView(); |
| 1193 if (view) | 1194 if (view) |
| 1194 view->HidePopupMenu(); | 1195 view->HidePopupMenu(); |
| 1195 } | 1196 } |
| 1196 #endif | 1197 #endif |
| 1197 | 1198 |
| 1199 void RenderFrameHostImpl::RegisterMojoServices() { | |
| 1200 GeolocationServiceContext* geolocation_service_context = | |
| 1201 delegate_ ? delegate_->GetGeolocationServiceContext() : NULL; | |
| 1202 if (geolocation_service_context) { | |
| 1203 GetServiceRegistry()->AddService<GeolocationService>( | |
| 1204 base::Bind(&GeolocationServiceContext::CreateService, | |
| 1205 base::Unretained(geolocation_service_context), | |
| 1206 base::Bind(&RenderFrameHostImpl::DidUseGeolocationPermission, | |
| 1207 base::Unretained(this)))); | |
| 1208 } | |
| 1209 } | |
| 1210 | |
| 1198 void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) { | 1211 void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) { |
| 1199 // Only main frames should be swapped out and retained inside a proxy host. | 1212 // Only main frames should be swapped out and retained inside a proxy host. |
| 1200 if (rfh_state == STATE_SWAPPED_OUT) | 1213 if (rfh_state == STATE_SWAPPED_OUT) |
| 1201 CHECK(!GetParent()); | 1214 CHECK(!GetParent()); |
| 1202 | 1215 |
| 1203 // We update the number of RenderFrameHosts in a SiteInstance when the swapped | 1216 // We update the number of RenderFrameHosts in a SiteInstance when the swapped |
| 1204 // out status of a RenderFrameHost gets flipped to/from active. | 1217 // out status of a RenderFrameHost gets flipped to/from active. |
| 1205 if (!IsRFHStateActive(rfh_state_) && IsRFHStateActive(rfh_state)) | 1218 if (!IsRFHStateActive(rfh_state_) && IsRFHStateActive(rfh_state)) |
| 1206 GetSiteInstance()->increment_active_frame_count(); | 1219 GetSiteInstance()->increment_active_frame_count(); |
| 1207 else if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state)) | 1220 else if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state)) |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1561 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1574 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
| 1562 // Clear any state if a pending navigation is canceled or preempted. | 1575 // Clear any state if a pending navigation is canceled or preempted. |
| 1563 if (suspended_nav_params_) | 1576 if (suspended_nav_params_) |
| 1564 suspended_nav_params_.reset(); | 1577 suspended_nav_params_.reset(); |
| 1565 | 1578 |
| 1566 TRACE_EVENT_ASYNC_END0("navigation", | 1579 TRACE_EVENT_ASYNC_END0("navigation", |
| 1567 "RenderFrameHostImpl navigation suspended", this); | 1580 "RenderFrameHostImpl navigation suspended", this); |
| 1568 navigations_suspended_ = false; | 1581 navigations_suspended_ = false; |
| 1569 } | 1582 } |
| 1570 | 1583 |
| 1584 void RenderFrameHostImpl::DidUseGeolocationPermission() { | |
| 1585 RenderFrameHost* top_frame = this; | |
|
Charlie Reis
2014/10/21 22:28:32
We can use frame_tree_node()->frame_tree()->root()
blundell
2014/10/23 12:27:01
Done.
| |
| 1586 while (top_frame->GetParent()) { | |
| 1587 top_frame = top_frame->GetParent(); | |
| 1588 } | |
| 1589 GetContentClient()->browser()->DidUseGeolocationPermission( | |
| 1590 delegate_->GetAsWebContents(), | |
| 1591 GetLastCommittedURL().GetOrigin(), | |
| 1592 top_frame->GetLastCommittedURL().GetOrigin()); | |
| 1593 } | |
| 1594 | |
| 1571 } // namespace content | 1595 } // namespace content |
| OLD | NEW |