| 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/cross_site_request_manager.h" | |
| 19 #include "content/browser/frame_host/cross_process_frame_connector.h" | 18 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 20 #include "content/browser/frame_host/cross_site_transferring_request.h" | 19 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 21 #include "content/browser/frame_host/frame_tree.h" | 20 #include "content/browser/frame_host/frame_tree.h" |
| 22 #include "content/browser/frame_host/frame_tree_node.h" | 21 #include "content/browser/frame_host/frame_tree_node.h" |
| 23 #include "content/browser/frame_host/navigator.h" | 22 #include "content/browser/frame_host/navigator.h" |
| 24 #include "content/browser/frame_host/render_frame_host_delegate.h" | 23 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 25 #include "content/browser/frame_host/render_frame_proxy_host.h" | 24 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 26 #include "content/browser/renderer_host/input/input_router.h" | 25 #include "content/browser/renderer_host/input/input_router.h" |
| 27 #include "content/browser/renderer_host/input/timeout_monitor.h" | 26 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 28 #include "content/browser/renderer_host/render_process_host_impl.h" | 27 #include "content/browser/renderer_host/render_process_host_impl.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 mojo::Get(&service_provider)); | 185 mojo::Get(&service_provider)); |
| 187 service_registry_.BindRemoteServiceProvider( | 186 service_registry_.BindRemoteServiceProvider( |
| 188 service_provider.PassMessagePipe()); | 187 service_provider.PassMessagePipe()); |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 | 190 |
| 192 RenderFrameHostImpl::~RenderFrameHostImpl() { | 191 RenderFrameHostImpl::~RenderFrameHostImpl() { |
| 193 GetProcess()->RemoveRoute(routing_id_); | 192 GetProcess()->RemoveRoute(routing_id_); |
| 194 g_routing_id_frame_map.Get().erase( | 193 g_routing_id_frame_map.Get().erase( |
| 195 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 194 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
| 196 // Clean up any leftover state from cross-site requests. | |
| 197 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | |
| 198 GetProcess()->GetID(), routing_id_, false); | |
| 199 | 195 |
| 200 if (delegate_) | 196 if (delegate_) |
| 201 delegate_->RenderFrameDeleted(this); | 197 delegate_->RenderFrameDeleted(this); |
| 202 | 198 |
| 203 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 199 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| 204 // the corresponding RenderViewHost if it is no longer needed. | 200 // the corresponding RenderViewHost if it is no longer needed. |
| 205 frame_tree_->UnregisterRenderFrameHost(this); | 201 frame_tree_->UnregisterRenderFrameHost(this); |
| 206 } | 202 } |
| 207 | 203 |
| 208 int RenderFrameHostImpl::GetRoutingID() { | 204 int RenderFrameHostImpl::GetRoutingID() { |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { | 675 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { |
| 680 // TODO(creis): Move swapped out state to RFH. Until then, only update it | 676 // TODO(creis): Move swapped out state to RFH. Until then, only update it |
| 681 // when swapping out the main frame. | 677 // when swapping out the main frame. |
| 682 if (!GetParent()) { | 678 if (!GetParent()) { |
| 683 // If this RenderViewHost is not in the default state, it must have already | 679 // If this RenderViewHost is not in the default state, it must have already |
| 684 // gone through this, therefore just return. | 680 // gone through this, therefore just return. |
| 685 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) | 681 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) |
| 686 return; | 682 return; |
| 687 | 683 |
| 688 render_view_host_->SetState( | 684 render_view_host_->SetState( |
| 689 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); | 685 RenderViewHostImpl::STATE_PENDING_SWAP_OUT); |
| 690 render_view_host_->unload_event_monitor_timeout_->Start( | 686 render_view_host_->unload_event_monitor_timeout_->Start( |
| 691 base::TimeDelta::FromMilliseconds( | 687 base::TimeDelta::FromMilliseconds( |
| 692 RenderViewHostImpl::kUnloadTimeoutMS)); | 688 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 693 } | 689 } |
| 694 | 690 |
| 695 set_render_frame_proxy_host(proxy); | 691 set_render_frame_proxy_host(proxy); |
| 696 | 692 |
| 697 if (render_view_host_->IsRenderViewLive()) | 693 if (render_view_host_->IsRenderViewLive()) |
| 698 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); | 694 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); |
| 699 | 695 |
| 700 if (!GetParent()) | 696 if (!GetParent()) |
| 701 delegate_->SwappedOut(this); | 697 delegate_->SwappedOut(this); |
| 702 | 698 else |
| 703 // Allow the navigation to proceed. | 699 set_swapped_out(true); |
| 704 frame_tree_node_->render_manager()->SwappedOut(this); | |
| 705 } | 700 } |
| 706 | 701 |
| 707 void RenderFrameHostImpl::OnBeforeUnloadACK( | 702 void RenderFrameHostImpl::OnBeforeUnloadACK( |
| 708 bool proceed, | 703 bool proceed, |
| 709 const base::TimeTicks& renderer_before_unload_start_time, | 704 const base::TimeTicks& renderer_before_unload_start_time, |
| 710 const base::TimeTicks& renderer_before_unload_end_time) { | 705 const base::TimeTicks& renderer_before_unload_end_time) { |
| 711 // TODO(creis): Support properly beforeunload on subframes. For now just | 706 // TODO(creis): Support properly beforeunload on subframes. For now just |
| 712 // pretend that the handler ran and allowed the navigation to proceed. | 707 // pretend that the handler ran and allowed the navigation to proceed. |
| 713 if (GetParent()) { | 708 if (GetParent()) { |
| 714 render_view_host_->is_waiting_for_beforeunload_ack_ = false; | 709 render_view_host_->is_waiting_for_beforeunload_ack_ = false; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 if (!proceed) | 772 if (!proceed) |
| 778 render_view_host_->GetDelegate()->DidCancelLoading(); | 773 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 779 } | 774 } |
| 780 | 775 |
| 781 void RenderFrameHostImpl::OnSwapOutACK() { | 776 void RenderFrameHostImpl::OnSwapOutACK() { |
| 782 OnSwappedOut(false); | 777 OnSwappedOut(false); |
| 783 } | 778 } |
| 784 | 779 |
| 785 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { | 780 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { |
| 786 // For now, we only need to update the RVH state machine for top-level swaps. | 781 // For now, we only need to update the RVH state machine for top-level swaps. |
| 787 // Subframe swaps (in --site-per-process) can just continue via RFHM. | |
| 788 if (!GetParent()) | 782 if (!GetParent()) |
| 789 render_view_host_->OnSwappedOut(timed_out); | 783 render_view_host_->OnSwappedOut(timed_out); |
| 790 else | |
| 791 frame_tree_node_->render_manager()->SwappedOut(this); | |
| 792 } | 784 } |
| 793 | 785 |
| 794 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { | 786 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { |
| 795 // Validate the URLs in |params|. If the renderer can't request the URLs | 787 // Validate the URLs in |params|. If the renderer can't request the URLs |
| 796 // directly, don't show them in the context menu. | 788 // directly, don't show them in the context menu. |
| 797 ContextMenuParams validated_params(params); | 789 ContextMenuParams validated_params(params); |
| 798 RenderProcessHost* process = GetProcess(); | 790 RenderProcessHost* process = GetProcess(); |
| 799 | 791 |
| 800 // We don't validate |unfiltered_link_url| so that this field can be used | 792 // We don't validate |unfiltered_link_url| so that this field can be used |
| 801 // when users want to copy the original link URL. | 793 // when users want to copy the original link URL. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 render_view_host_->delegate_->RendererUnresponsive( | 1151 render_view_host_->delegate_->RendererUnresponsive( |
| 1160 render_view_host_, | 1152 render_view_host_, |
| 1161 render_view_host_->is_waiting_for_beforeunload_ack(), | 1153 render_view_host_->is_waiting_for_beforeunload_ack(), |
| 1162 render_view_host_->IsWaitingForUnloadACK()); | 1154 render_view_host_->IsWaitingForUnloadACK()); |
| 1163 } | 1155 } |
| 1164 | 1156 |
| 1165 void RenderFrameHostImpl::NotificationClosed(int notification_id) { | 1157 void RenderFrameHostImpl::NotificationClosed(int notification_id) { |
| 1166 cancel_notification_callbacks_.erase(notification_id); | 1158 cancel_notification_callbacks_.erase(notification_id); |
| 1167 } | 1159 } |
| 1168 | 1160 |
| 1169 bool RenderFrameHostImpl::HasPendingCrossSiteRequest() { | |
| 1170 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( | |
| 1171 GetProcess()->GetID(), routing_id_); | |
| 1172 } | |
| 1173 | |
| 1174 void RenderFrameHostImpl::SetHasPendingCrossSiteRequest( | |
| 1175 bool has_pending_request) { | |
| 1176 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | |
| 1177 GetProcess()->GetID(), routing_id_, has_pending_request); | |
| 1178 } | |
| 1179 | |
| 1180 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( | 1161 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( |
| 1181 int request_id, blink::WebNotificationPermission permission) { | 1162 int request_id, blink::WebNotificationPermission permission) { |
| 1182 Send(new PlatformNotificationMsg_PermissionRequestComplete( | 1163 Send(new PlatformNotificationMsg_PermissionRequestComplete( |
| 1183 routing_id_, request_id, permission)); | 1164 routing_id_, request_id, permission)); |
| 1184 } | 1165 } |
| 1185 | 1166 |
| 1186 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1167 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 1187 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1168 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
| 1188 } | 1169 } |
| 1189 | 1170 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 } | 1236 } |
| 1256 | 1237 |
| 1257 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1238 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
| 1258 // Clear any state if a pending navigation is canceled or preempted. | 1239 // Clear any state if a pending navigation is canceled or preempted. |
| 1259 if (suspended_nav_params_) | 1240 if (suspended_nav_params_) |
| 1260 suspended_nav_params_.reset(); | 1241 suspended_nav_params_.reset(); |
| 1261 navigations_suspended_ = false; | 1242 navigations_suspended_ = false; |
| 1262 } | 1243 } |
| 1263 | 1244 |
| 1264 } // namespace content | 1245 } // namespace content |
| OLD | NEW |