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