OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
9 #include "content/browser/frame_host/navigation_controller_impl.h" | 11 #include "content/browser/frame_host/navigation_controller_impl.h" |
10 #include "content/browser/frame_host/navigation_handle_impl.h" | 12 #include "content/browser/frame_host/navigation_handle_impl.h" |
11 #include "content/browser/frame_host/navigation_request_info.h" | 13 #include "content/browser/frame_host/navigation_request_info.h" |
12 #include "content/browser/frame_host/navigator.h" | 14 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/loader/navigation_url_loader.h" | 15 #include "content/browser/loader/navigation_url_loader.h" |
14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 16 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
15 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 17 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
16 #include "content/browser/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 false, // skip_service_worker | 102 false, // skip_service_worker |
101 REQUEST_CONTEXT_TYPE_LOCATION), | 103 REQUEST_CONTEXT_TYPE_LOCATION), |
102 entry.ConstructRequestNavigationParams( | 104 entry.ConstructRequestNavigationParams( |
103 frame_entry, is_same_document_history_load, | 105 frame_entry, is_same_document_history_load, |
104 frame_tree_node->has_committed_real_load(), | 106 frame_tree_node->has_committed_real_load(), |
105 controller->GetPendingEntryIndex() == -1, | 107 controller->GetPendingEntryIndex() == -1, |
106 controller->GetIndexOfEntry(&entry), | 108 controller->GetIndexOfEntry(&entry), |
107 controller->GetLastCommittedEntryIndex(), | 109 controller->GetLastCommittedEntryIndex(), |
108 controller->GetEntryCount()), | 110 controller->GetEntryCount()), |
109 request_body, true, &frame_entry, &entry)); | 111 request_body, true, &frame_entry, &entry)); |
110 return navigation_request.Pass(); | 112 return navigation_request; |
111 } | 113 } |
112 | 114 |
113 // static | 115 // static |
114 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( | 116 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
115 FrameTreeNode* frame_tree_node, | 117 FrameTreeNode* frame_tree_node, |
116 const CommonNavigationParams& common_params, | 118 const CommonNavigationParams& common_params, |
117 const BeginNavigationParams& begin_params, | 119 const BeginNavigationParams& begin_params, |
118 scoped_refptr<ResourceRequestBody> body, | 120 scoped_refptr<ResourceRequestBody> body, |
119 int current_history_list_offset, | 121 int current_history_list_offset, |
120 int current_history_list_length) { | 122 int current_history_list_length) { |
(...skipping 15 matching lines...) Expand all Loading... |
136 false, // is_same_document_history_load | 138 false, // is_same_document_history_load |
137 false, // has_committed_real_load | 139 false, // has_committed_real_load |
138 false, // intended_as_new_entry | 140 false, // intended_as_new_entry |
139 -1, // pending_history_list_offset | 141 -1, // pending_history_list_offset |
140 current_history_list_offset, current_history_list_length, | 142 current_history_list_offset, current_history_list_length, |
141 false, // is_view_source | 143 false, // is_view_source |
142 false); // should_clear_history_list | 144 false); // should_clear_history_list |
143 scoped_ptr<NavigationRequest> navigation_request( | 145 scoped_ptr<NavigationRequest> navigation_request( |
144 new NavigationRequest(frame_tree_node, common_params, begin_params, | 146 new NavigationRequest(frame_tree_node, common_params, begin_params, |
145 request_params, body, false, nullptr, nullptr)); | 147 request_params, body, false, nullptr, nullptr)); |
146 return navigation_request.Pass(); | 148 return navigation_request; |
147 } | 149 } |
148 | 150 |
149 NavigationRequest::NavigationRequest( | 151 NavigationRequest::NavigationRequest( |
150 FrameTreeNode* frame_tree_node, | 152 FrameTreeNode* frame_tree_node, |
151 const CommonNavigationParams& common_params, | 153 const CommonNavigationParams& common_params, |
152 const BeginNavigationParams& begin_params, | 154 const BeginNavigationParams& begin_params, |
153 const RequestNavigationParams& request_params, | 155 const RequestNavigationParams& request_params, |
154 scoped_refptr<ResourceRequestBody> body, | 156 scoped_refptr<ResourceRequestBody> body, |
155 bool browser_initiated, | 157 bool browser_initiated, |
156 const FrameNavigationEntry* frame_entry, | 158 const FrameNavigationEntry* frame_entry, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); | 223 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); |
222 } | 224 } |
223 | 225 |
224 void NavigationRequest::CreateNavigationHandle() { | 226 void NavigationRequest::CreateNavigationHandle() { |
225 navigation_handle_ = NavigationHandleImpl::Create( | 227 navigation_handle_ = NavigationHandleImpl::Create( |
226 common_params_.url, frame_tree_node_, common_params_.navigation_start); | 228 common_params_.url, frame_tree_node_, common_params_.navigation_start); |
227 } | 229 } |
228 | 230 |
229 void NavigationRequest::TransferNavigationHandleOwnership( | 231 void NavigationRequest::TransferNavigationHandleOwnership( |
230 RenderFrameHostImpl* render_frame_host) { | 232 RenderFrameHostImpl* render_frame_host) { |
231 render_frame_host->SetNavigationHandle(navigation_handle_.Pass()); | 233 render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); |
232 } | 234 } |
233 | 235 |
234 void NavigationRequest::OnRequestRedirected( | 236 void NavigationRequest::OnRequestRedirected( |
235 const net::RedirectInfo& redirect_info, | 237 const net::RedirectInfo& redirect_info, |
236 const scoped_refptr<ResourceResponse>& response) { | 238 const scoped_refptr<ResourceResponse>& response) { |
237 common_params_.url = redirect_info.new_url; | 239 common_params_.url = redirect_info.new_url; |
238 begin_params_.method = redirect_info.new_method; | 240 begin_params_.method = redirect_info.new_method; |
239 common_params_.referrer.url = GURL(redirect_info.new_referrer); | 241 common_params_.referrer.url = GURL(redirect_info.new_referrer); |
240 | 242 |
241 // TODO(clamy): Have CSP + security upgrade checks here. | 243 // TODO(clamy): Have CSP + security upgrade checks here. |
(...skipping 18 matching lines...) Expand all Loading... |
260 // Update the service worker params of the request params. | 262 // Update the service worker params of the request params. |
261 request_params_.should_create_service_worker = | 263 request_params_.should_create_service_worker = |
262 (frame_tree_node_->current_replication_state().sandbox_flags & | 264 (frame_tree_node_->current_replication_state().sandbox_flags & |
263 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; | 265 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; |
264 if (navigation_handle_->service_worker_handle()) { | 266 if (navigation_handle_->service_worker_handle()) { |
265 request_params_.service_worker_provider_id = | 267 request_params_.service_worker_provider_id = |
266 navigation_handle_->service_worker_handle() | 268 navigation_handle_->service_worker_handle() |
267 ->service_worker_provider_host_id(); | 269 ->service_worker_provider_host_id(); |
268 } | 270 } |
269 | 271 |
270 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, | 272 frame_tree_node_->navigator()->CommitNavigation( |
271 response.get(), body.Pass()); | 273 frame_tree_node_, response.get(), std::move(body)); |
272 } | 274 } |
273 | 275 |
274 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, | 276 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, |
275 int net_error) { | 277 int net_error) { |
276 DCHECK(state_ == STARTED); | 278 DCHECK(state_ == STARTED); |
277 state_ = FAILED; | 279 state_ = FAILED; |
278 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); | 280 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); |
279 frame_tree_node_->navigator()->FailedNavigation( | 281 frame_tree_node_->navigator()->FailedNavigation( |
280 frame_tree_node_, has_stale_copy_in_cache, net_error); | 282 frame_tree_node_, has_stale_copy_in_cache, net_error); |
281 } | 283 } |
(...skipping 11 matching lines...) Expand all Loading... |
293 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 295 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
294 result == NavigationThrottle::CANCEL) { | 296 result == NavigationThrottle::CANCEL) { |
295 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 297 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
296 frame_tree_node_->ResetNavigationRequest(false); | 298 frame_tree_node_->ResetNavigationRequest(false); |
297 return; | 299 return; |
298 } | 300 } |
299 | 301 |
300 InitializeServiceWorkerHandleIfNeeded(); | 302 InitializeServiceWorkerHandleIfNeeded(); |
301 loader_ = NavigationURLLoader::Create( | 303 loader_ = NavigationURLLoader::Create( |
302 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 304 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
303 info_.Pass(), navigation_handle_->service_worker_handle(), this); | 305 std::move(info_), navigation_handle_->service_worker_handle(), this); |
304 } | 306 } |
305 | 307 |
306 void NavigationRequest::OnRedirectChecksComplete( | 308 void NavigationRequest::OnRedirectChecksComplete( |
307 NavigationThrottle::ThrottleCheckResult result) { | 309 NavigationThrottle::ThrottleCheckResult result) { |
308 CHECK(result != NavigationThrottle::DEFER); | 310 CHECK(result != NavigationThrottle::DEFER); |
309 | 311 |
310 // Abort the request if needed. This will destroy the NavigationRequest. | 312 // Abort the request if needed. This will destroy the NavigationRequest. |
311 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 313 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
312 result == NavigationThrottle::CANCEL) { | 314 result == NavigationThrottle::CANCEL) { |
313 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 315 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
(...skipping 29 matching lines...) Expand all Loading... |
343 browser_context, navigating_frame_host->GetSiteInstance()); | 345 browser_context, navigating_frame_host->GetSiteInstance()); |
344 DCHECK(partition); | 346 DCHECK(partition); |
345 | 347 |
346 ServiceWorkerContextWrapper* service_worker_context = | 348 ServiceWorkerContextWrapper* service_worker_context = |
347 static_cast<ServiceWorkerContextWrapper*>( | 349 static_cast<ServiceWorkerContextWrapper*>( |
348 partition->GetServiceWorkerContext()); | 350 partition->GetServiceWorkerContext()); |
349 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 351 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
350 } | 352 } |
351 | 353 |
352 } // namespace content | 354 } // namespace content |
OLD | NEW |