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/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "content/browser/accessibility/accessibility_mode_helper.h" | 12 #include "content/browser/accessibility/accessibility_mode_helper.h" |
13 #include "content/browser/accessibility/browser_accessibility_manager.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager.h" |
14 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 14 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
15 #include "content/browser/child_process_security_policy_impl.h" | 15 #include "content/browser/child_process_security_policy_impl.h" |
| 16 #include "content/browser/cross_site_request_manager.h" |
16 #include "content/browser/frame_host/cross_process_frame_connector.h" | 17 #include "content/browser/frame_host/cross_process_frame_connector.h" |
17 #include "content/browser/frame_host/cross_site_transferring_request.h" | 18 #include "content/browser/frame_host/cross_site_transferring_request.h" |
18 #include "content/browser/frame_host/frame_tree.h" | 19 #include "content/browser/frame_host/frame_tree.h" |
19 #include "content/browser/frame_host/frame_tree_node.h" | 20 #include "content/browser/frame_host/frame_tree_node.h" |
20 #include "content/browser/frame_host/navigator.h" | 21 #include "content/browser/frame_host/navigator.h" |
21 #include "content/browser/frame_host/render_frame_host_delegate.h" | 22 #include "content/browser/frame_host/render_frame_host_delegate.h" |
22 #include "content/browser/frame_host/render_frame_proxy_host.h" | 23 #include "content/browser/frame_host/render_frame_proxy_host.h" |
23 #include "content/browser/renderer_host/input/input_router.h" | 24 #include "content/browser/renderer_host/input/input_router.h" |
24 #include "content/browser/renderer_host/input/timeout_monitor.h" | 25 #include "content/browser/renderer_host/input/timeout_monitor.h" |
25 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 bool is_swapped_out) | 160 bool is_swapped_out) |
160 : render_view_host_(render_view_host), | 161 : render_view_host_(render_view_host), |
161 delegate_(delegate), | 162 delegate_(delegate), |
162 cross_process_frame_connector_(NULL), | 163 cross_process_frame_connector_(NULL), |
163 render_frame_proxy_host_(NULL), | 164 render_frame_proxy_host_(NULL), |
164 frame_tree_(frame_tree), | 165 frame_tree_(frame_tree), |
165 frame_tree_node_(frame_tree_node), | 166 frame_tree_node_(frame_tree_node), |
166 routing_id_(routing_id), | 167 routing_id_(routing_id), |
167 is_swapped_out_(is_swapped_out), | 168 is_swapped_out_(is_swapped_out), |
168 renderer_initialized_(false), | 169 renderer_initialized_(false), |
| 170 navigations_suspended_(false), |
169 weak_ptr_factory_(this) { | 171 weak_ptr_factory_(this) { |
170 frame_tree_->RegisterRenderFrameHost(this); | 172 frame_tree_->RegisterRenderFrameHost(this); |
171 GetProcess()->AddRoute(routing_id_, this); | 173 GetProcess()->AddRoute(routing_id_, this); |
172 g_routing_id_frame_map.Get().insert(std::make_pair( | 174 g_routing_id_frame_map.Get().insert(std::make_pair( |
173 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 175 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
174 this)); | 176 this)); |
175 | 177 |
176 if (GetProcess()->GetServiceRegistry()) { | 178 if (GetProcess()->GetServiceRegistry()) { |
177 RenderFrameSetupPtr setup; | 179 RenderFrameSetupPtr setup; |
178 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); | 180 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); |
179 mojo::ServiceProviderPtr service_provider; | 181 mojo::ServiceProviderPtr service_provider; |
180 setup->GetServiceProviderForFrame(routing_id_, | 182 setup->GetServiceProviderForFrame(routing_id_, |
181 mojo::Get(&service_provider)); | 183 mojo::Get(&service_provider)); |
182 service_registry_.BindRemoteServiceProvider( | 184 service_registry_.BindRemoteServiceProvider( |
183 service_provider.PassMessagePipe()); | 185 service_provider.PassMessagePipe()); |
184 } | 186 } |
185 } | 187 } |
186 | 188 |
187 RenderFrameHostImpl::~RenderFrameHostImpl() { | 189 RenderFrameHostImpl::~RenderFrameHostImpl() { |
188 GetProcess()->RemoveRoute(routing_id_); | 190 GetProcess()->RemoveRoute(routing_id_); |
189 g_routing_id_frame_map.Get().erase( | 191 g_routing_id_frame_map.Get().erase( |
190 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 192 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
| 193 // Clean up any leftover state from cross-site requests. |
| 194 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
| 195 GetProcess()->GetID(), routing_id_, false); |
| 196 |
191 if (delegate_) | 197 if (delegate_) |
192 delegate_->RenderFrameDeleted(this); | 198 delegate_->RenderFrameDeleted(this); |
193 | 199 |
194 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 200 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
195 // the corresponding RenderViewHost if it is no longer needed. | 201 // the corresponding RenderViewHost if it is no longer needed. |
196 frame_tree_->UnregisterRenderFrameHost(this); | 202 frame_tree_->UnregisterRenderFrameHost(this); |
197 } | 203 } |
198 | 204 |
199 int RenderFrameHostImpl::GetRoutingID() { | 205 int RenderFrameHostImpl::GetRoutingID() { |
200 return routing_id_; | 206 return routing_id_; |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { | 1010 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { |
1005 // If 'data:' is used, and we have a 'file:' base url, grant access to | 1011 // If 'data:' is used, and we have a 'file:' base url, grant access to |
1006 // local files. | 1012 // local files. |
1007 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1013 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
1008 GetProcess()->GetID(), params.base_url_for_data_url); | 1014 GetProcess()->GetID(), params.base_url_for_data_url); |
1009 } | 1015 } |
1010 } | 1016 } |
1011 | 1017 |
1012 // Only send the message if we aren't suspended at the start of a cross-site | 1018 // Only send the message if we aren't suspended at the start of a cross-site |
1013 // request. | 1019 // request. |
1014 if (render_view_host_->navigations_suspended_) { | 1020 if (navigations_suspended_) { |
1015 // Shouldn't be possible to have a second navigation while suspended, since | 1021 // Shouldn't be possible to have a second navigation while suspended, since |
1016 // navigations will only be suspended during a cross-site request. If a | 1022 // navigations will only be suspended during a cross-site request. If a |
1017 // second navigation occurs, RenderFrameHostManager will cancel this pending | 1023 // second navigation occurs, RenderFrameHostManager will cancel this pending |
1018 // RFH and create a new pending RFH. | 1024 // RFH and create a new pending RFH. |
1019 DCHECK(!render_view_host_->suspended_nav_params_.get()); | 1025 DCHECK(!suspended_nav_params_.get()); |
1020 render_view_host_->suspended_nav_params_.reset( | 1026 suspended_nav_params_.reset(new FrameMsg_Navigate_Params(params)); |
1021 new FrameMsg_Navigate_Params(params)); | |
1022 } else { | 1027 } else { |
1023 // Get back to a clean state, in case we start a new navigation without | 1028 // Get back to a clean state, in case we start a new navigation without |
1024 // completing a RVH swap or unload handler. | 1029 // completing a RVH swap or unload handler. |
1025 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); | 1030 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); |
1026 | 1031 |
1027 Send(new FrameMsg_Navigate(routing_id_, params)); | 1032 Send(new FrameMsg_Navigate(routing_id_, params)); |
1028 } | 1033 } |
1029 | 1034 |
1030 // Force the throbber to start. We do this because Blink's "started | 1035 // Force the throbber to start. We do this because Blink's "started |
1031 // loading" message will be received asynchronously from the UI of the | 1036 // loading" message will be received asynchronously from the UI of the |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 render_view_host_->delegate_->RendererUnresponsive( | 1139 render_view_host_->delegate_->RendererUnresponsive( |
1135 render_view_host_, | 1140 render_view_host_, |
1136 render_view_host_->is_waiting_for_beforeunload_ack(), | 1141 render_view_host_->is_waiting_for_beforeunload_ack(), |
1137 render_view_host_->IsWaitingForUnloadACK()); | 1142 render_view_host_->IsWaitingForUnloadACK()); |
1138 } | 1143 } |
1139 | 1144 |
1140 void RenderFrameHostImpl::NotificationClosed(int notification_id) { | 1145 void RenderFrameHostImpl::NotificationClosed(int notification_id) { |
1141 cancel_notification_callbacks_.erase(notification_id); | 1146 cancel_notification_callbacks_.erase(notification_id); |
1142 } | 1147 } |
1143 | 1148 |
| 1149 bool RenderFrameHostImpl::HasPendingCrossSiteRequest() { |
| 1150 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( |
| 1151 GetProcess()->GetID(), routing_id_); |
| 1152 } |
| 1153 |
| 1154 void RenderFrameHostImpl::SetHasPendingCrossSiteRequest( |
| 1155 bool has_pending_request) { |
| 1156 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
| 1157 GetProcess()->GetID(), routing_id_, has_pending_request); |
| 1158 } |
| 1159 |
1144 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( | 1160 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( |
1145 int request_id, blink::WebNotificationPermission permission) { | 1161 int request_id, blink::WebNotificationPermission permission) { |
1146 Send(new PlatformNotificationMsg_PermissionRequestComplete( | 1162 Send(new PlatformNotificationMsg_PermissionRequestComplete( |
1147 routing_id_, request_id, permission)); | 1163 routing_id_, request_id, permission)); |
1148 } | 1164 } |
1149 | 1165 |
1150 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1166 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
1151 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1167 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
1152 } | 1168 } |
1153 | 1169 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 BrowserThread::PostTask( | 1207 BrowserThread::PostTask( |
1192 BrowserThread::IO, | 1208 BrowserThread::IO, |
1193 FROM_HERE, | 1209 FROM_HERE, |
1194 base::Bind( | 1210 base::Bind( |
1195 &TransitionRequestManager::ClearPendingTransitionRequestData, | 1211 &TransitionRequestManager::ClearPendingTransitionRequestData, |
1196 base::Unretained(TransitionRequestManager::GetInstance()), | 1212 base::Unretained(TransitionRequestManager::GetInstance()), |
1197 GetProcess()->GetID(), | 1213 GetProcess()->GetID(), |
1198 routing_id_)); | 1214 routing_id_)); |
1199 } | 1215 } |
1200 | 1216 |
| 1217 void RenderFrameHostImpl::SetNavigationsSuspended( |
| 1218 bool suspend, |
| 1219 const base::TimeTicks& proceed_time) { |
| 1220 // This should only be called to toggle the state. |
| 1221 DCHECK(navigations_suspended_ != suspend); |
| 1222 |
| 1223 navigations_suspended_ = suspend; |
| 1224 if (!suspend && suspended_nav_params_) { |
| 1225 // There's navigation message params waiting to be sent. Now that we're not |
| 1226 // suspended anymore, resume navigation by sending them. If we were swapped |
| 1227 // out, we should also stop filtering out the IPC messages now. |
| 1228 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); |
| 1229 |
| 1230 DCHECK(!proceed_time.is_null()); |
| 1231 suspended_nav_params_->browser_navigation_start = proceed_time; |
| 1232 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); |
| 1233 suspended_nav_params_.reset(); |
| 1234 } |
| 1235 } |
| 1236 |
| 1237 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
| 1238 // Clear any state if a pending navigation is canceled or preempted. |
| 1239 if (suspended_nav_params_) |
| 1240 suspended_nav_params_.reset(); |
| 1241 navigations_suspended_ = false; |
| 1242 } |
| 1243 |
1201 } // namespace content | 1244 } // namespace content |
OLD | NEW |