Chromium Code Reviews| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| 11 #include "content/browser/frame_host/frame_tree_node.h" | 11 #include "content/browser/frame_host/frame_tree_node.h" |
| 12 #include "content/browser/frame_host/navigation_controller_impl.h" | 12 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 13 #include "content/browser/frame_host/navigation_handle_impl.h" | 13 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 14 #include "content/browser/frame_host/navigation_request_info.h" | 14 #include "content/browser/frame_host/navigation_request_info.h" |
| 15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
| 16 #include "content/browser/frame_host/navigator_impl.h" | 16 #include "content/browser/frame_host/navigator_impl.h" |
| 17 #include "content/browser/loader/navigation_url_loader.h" | 17 #include "content/browser/loader/navigation_url_loader.h" |
| 18 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 18 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 19 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 19 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 20 #include "content/browser/site_instance_impl.h" | 20 #include "content/browser/site_instance_impl.h" |
| 21 #include "content/common/resource_request_body.h" | 21 #include "content/common/resource_request_body.h" |
| 22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
| 23 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
| 24 #include "content/public/browser/navigation_data.h" | |
| 24 #include "content/public/browser/storage_partition.h" | 25 #include "content/public/browser/storage_partition.h" |
| 25 #include "content/public/browser/stream_handle.h" | 26 #include "content/public/browser/stream_handle.h" |
| 26 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/resource_response.h" | 28 #include "content/public/common/resource_response.h" |
| 28 #include "net/base/load_flags.h" | 29 #include "net/base/load_flags.h" |
| 29 #include "net/http/http_request_headers.h" | 30 #include "net/http/http_request_headers.h" |
| 30 #include "net/url_request/redirect_info.h" | 31 #include "net/url_request/redirect_info.h" |
| 31 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 32 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 267 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
| 267 navigation_handle_->WillRedirectRequest( | 268 navigation_handle_->WillRedirectRequest( |
| 268 common_params_.url, common_params_.method, common_params_.referrer.url, | 269 common_params_.url, common_params_.method, common_params_.referrer.url, |
| 269 false, response->head.headers, | 270 false, response->head.headers, |
| 270 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 271 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
| 271 base::Unretained(this))); | 272 base::Unretained(this))); |
| 272 } | 273 } |
| 273 | 274 |
| 274 void NavigationRequest::OnResponseStarted( | 275 void NavigationRequest::OnResponseStarted( |
| 275 const scoped_refptr<ResourceResponse>& response, | 276 const scoped_refptr<ResourceResponse>& response, |
| 276 std::unique_ptr<StreamHandle> body) { | 277 std::unique_ptr<StreamHandle> body, |
| 278 std::unique_ptr<NavigationData> navigation_data) { | |
| 277 DCHECK(state_ == STARTED); | 279 DCHECK(state_ == STARTED); |
| 278 state_ = RESPONSE_STARTED; | 280 state_ = RESPONSE_STARTED; |
| 279 | 281 |
| 280 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 282 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
| 281 // commit; they leave the frame showing the previous page. | 283 // commit; they leave the frame showing the previous page. |
| 282 DCHECK(response); | 284 DCHECK(response); |
| 283 if (response->head.headers.get() && | 285 if (response->head.headers.get() && |
| 284 (response->head.headers->response_code() == 204 || | 286 (response->head.headers->response_code() == 204 || |
| 285 response->head.headers->response_code() == 205)) { | 287 response->head.headers->response_code() == 205)) { |
| 286 frame_tree_node_->ResetNavigationRequest(false); | 288 frame_tree_node_->ResetNavigationRequest(false); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 313 // renderer, allow the embedder to cancel the transfer. | 315 // renderer, allow the embedder to cancel the transfer. |
| 314 if (!browser_initiated_ && | 316 if (!browser_initiated_ && |
| 315 render_frame_host != frame_tree_node_->current_frame_host() && | 317 render_frame_host != frame_tree_node_->current_frame_host() && |
| 316 !frame_tree_node_->navigator() | 318 !frame_tree_node_->navigator() |
| 317 ->GetDelegate() | 319 ->GetDelegate() |
| 318 ->ShouldTransferNavigation()) { | 320 ->ShouldTransferNavigation()) { |
| 319 frame_tree_node_->ResetNavigationRequest(false); | 321 frame_tree_node_->ResetNavigationRequest(false); |
| 320 return; | 322 return; |
| 321 } | 323 } |
| 322 | 324 |
| 325 if (navigation_data.get()) | |
|
bengr
2016/04/29 21:14:22
No need for .get()
RyanSturm
2016/05/02 19:52:21
Done.
| |
| 326 navigation_handle_->SetNavigationData(std::move(navigation_data)); | |
| 327 | |
| 323 // Store the response and the StreamHandle until checks have been processed. | 328 // Store the response and the StreamHandle until checks have been processed. |
| 324 response_ = response; | 329 response_ = response; |
| 325 body_ = std::move(body); | 330 body_ = std::move(body); |
| 326 | 331 |
| 327 // Check if the navigation should be allowed to proceed. | 332 // Check if the navigation should be allowed to proceed. |
| 328 navigation_handle_->WillProcessResponse( | 333 navigation_handle_->WillProcessResponse( |
| 329 render_frame_host, response->head.headers.get(), | 334 render_frame_host, response->head.headers.get(), |
| 330 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, | 335 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, |
| 331 base::Unretained(this))); | 336 base::Unretained(this))); |
| 332 } | 337 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 browser_context, navigating_frame_host->GetSiteInstance()); | 457 browser_context, navigating_frame_host->GetSiteInstance()); |
| 453 DCHECK(partition); | 458 DCHECK(partition); |
| 454 | 459 |
| 455 ServiceWorkerContextWrapper* service_worker_context = | 460 ServiceWorkerContextWrapper* service_worker_context = |
| 456 static_cast<ServiceWorkerContextWrapper*>( | 461 static_cast<ServiceWorkerContextWrapper*>( |
| 457 partition->GetServiceWorkerContext()); | 462 partition->GetServiceWorkerContext()); |
| 458 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 463 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
| 459 } | 464 } |
| 460 | 465 |
| 461 } // namespace content | 466 } // namespace content |
| OLD | NEW |