| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 268 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
| 268 navigation_handle_->WillRedirectRequest( | 269 navigation_handle_->WillRedirectRequest( |
| 269 common_params_.url, common_params_.method, common_params_.referrer.url, | 270 common_params_.url, common_params_.method, common_params_.referrer.url, |
| 270 false, response->head.headers, | 271 false, response->head.headers, |
| 271 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 272 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
| 272 base::Unretained(this))); | 273 base::Unretained(this))); |
| 273 } | 274 } |
| 274 | 275 |
| 275 void NavigationRequest::OnResponseStarted( | 276 void NavigationRequest::OnResponseStarted( |
| 276 const scoped_refptr<ResourceResponse>& response, | 277 const scoped_refptr<ResourceResponse>& response, |
| 277 std::unique_ptr<StreamHandle> body) { | 278 std::unique_ptr<StreamHandle> body, |
| 279 std::unique_ptr<NavigationData> navigation_data) { |
| 278 DCHECK(state_ == STARTED); | 280 DCHECK(state_ == STARTED); |
| 279 state_ = RESPONSE_STARTED; | 281 state_ = RESPONSE_STARTED; |
| 280 | 282 |
| 281 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 283 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
| 282 // commit; they leave the frame showing the previous page. | 284 // commit; they leave the frame showing the previous page. |
| 283 DCHECK(response); | 285 DCHECK(response); |
| 284 if (response->head.headers.get() && | 286 if (response->head.headers.get() && |
| 285 (response->head.headers->response_code() == 204 || | 287 (response->head.headers->response_code() == 204 || |
| 286 response->head.headers->response_code() == 205)) { | 288 response->head.headers->response_code() == 205)) { |
| 287 frame_tree_node_->ResetNavigationRequest(false); | 289 frame_tree_node_->ResetNavigationRequest(false); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 314 // renderer, allow the embedder to cancel the transfer. | 316 // renderer, allow the embedder to cancel the transfer. |
| 315 if (!browser_initiated_ && | 317 if (!browser_initiated_ && |
| 316 render_frame_host != frame_tree_node_->current_frame_host() && | 318 render_frame_host != frame_tree_node_->current_frame_host() && |
| 317 !frame_tree_node_->navigator() | 319 !frame_tree_node_->navigator() |
| 318 ->GetDelegate() | 320 ->GetDelegate() |
| 319 ->ShouldTransferNavigation()) { | 321 ->ShouldTransferNavigation()) { |
| 320 frame_tree_node_->ResetNavigationRequest(false); | 322 frame_tree_node_->ResetNavigationRequest(false); |
| 321 return; | 323 return; |
| 322 } | 324 } |
| 323 | 325 |
| 326 if (navigation_data) |
| 327 navigation_handle_->set_navigation_data(std::move(navigation_data)); |
| 328 |
| 324 // Store the response and the StreamHandle until checks have been processed. | 329 // Store the response and the StreamHandle until checks have been processed. |
| 325 response_ = response; | 330 response_ = response; |
| 326 body_ = std::move(body); | 331 body_ = std::move(body); |
| 327 | 332 |
| 328 // Check if the navigation should be allowed to proceed. | 333 // Check if the navigation should be allowed to proceed. |
| 329 navigation_handle_->WillProcessResponse( | 334 navigation_handle_->WillProcessResponse( |
| 330 render_frame_host, response->head.headers.get(), | 335 render_frame_host, response->head.headers.get(), |
| 331 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, | 336 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, |
| 332 base::Unretained(this))); | 337 base::Unretained(this))); |
| 333 } | 338 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 browser_context, navigating_frame_host->GetSiteInstance()); | 458 browser_context, navigating_frame_host->GetSiteInstance()); |
| 454 DCHECK(partition); | 459 DCHECK(partition); |
| 455 | 460 |
| 456 ServiceWorkerContextWrapper* service_worker_context = | 461 ServiceWorkerContextWrapper* service_worker_context = |
| 457 static_cast<ServiceWorkerContextWrapper*>( | 462 static_cast<ServiceWorkerContextWrapper*>( |
| 458 partition->GetServiceWorkerContext()); | 463 partition->GetServiceWorkerContext()); |
| 459 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 464 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
| 460 } | 465 } |
| 461 | 466 |
| 462 } // namespace content | 467 } // namespace content |
| OLD | NEW |