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