| 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/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
| 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 11 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
| 12 #include "content/browser/frame_host/frame_tree_node.h" | 12 #include "content/browser/frame_host/frame_tree_node.h" |
| 13 #include "content/browser/frame_host/navigation_controller_impl.h" | 13 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 14 #include "content/browser/frame_host/navigation_handle_impl.h" | 14 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 15 #include "content/browser/frame_host/navigation_request_info.h" | 15 #include "content/browser/frame_host/navigation_request_info.h" |
| 16 #include "content/browser/frame_host/navigator.h" | 16 #include "content/browser/frame_host/navigator.h" |
| 17 #include "content/browser/frame_host/navigator_impl.h" | 17 #include "content/browser/frame_host/navigator_impl.h" |
| 18 #include "content/browser/loader/navigation_url_loader.h" | 18 #include "content/browser/loader/navigation_url_loader.h" |
| 19 #include "content/browser/renderer_host/render_process_host_impl.h" | 19 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 20 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 20 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 21 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 21 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 22 #include "content/browser/site_instance_impl.h" | 22 #include "content/browser/site_instance_impl.h" |
| 23 #include "content/common/resource_request_body_impl.h" | 23 #include "content/common/resource_request_body_impl.h" |
| 24 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
| 26 #include "content/public/browser/global_request_id.h" |
| 26 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
| 27 #include "content/public/browser/navigation_data.h" | 28 #include "content/public/browser/navigation_data.h" |
| 28 #include "content/public/browser/navigation_ui_data.h" | 29 #include "content/public/browser/navigation_ui_data.h" |
| 29 #include "content/public/browser/storage_partition.h" | 30 #include "content/public/browser/storage_partition.h" |
| 30 #include "content/public/browser/stream_handle.h" | 31 #include "content/public/browser/stream_handle.h" |
| 31 #include "content/public/common/content_client.h" | 32 #include "content/public/common/content_client.h" |
| 32 #include "content/public/common/request_context_type.h" | 33 #include "content/public/common/request_context_type.h" |
| 33 #include "content/public/common/resource_response.h" | 34 #include "content/public/common/resource_response.h" |
| 34 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
| 35 #include "net/base/load_flags.h" | 36 #include "net/base/load_flags.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 common_params_.url, common_params_.method, common_params_.referrer.url, | 367 common_params_.url, common_params_.method, common_params_.referrer.url, |
| 367 false, response->head.headers, response->head.connection_info, | 368 false, response->head.headers, response->head.connection_info, |
| 368 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 369 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
| 369 base::Unretained(this))); | 370 base::Unretained(this))); |
| 370 } | 371 } |
| 371 | 372 |
| 372 void NavigationRequest::OnResponseStarted( | 373 void NavigationRequest::OnResponseStarted( |
| 373 const scoped_refptr<ResourceResponse>& response, | 374 const scoped_refptr<ResourceResponse>& response, |
| 374 std::unique_ptr<StreamHandle> body, | 375 std::unique_ptr<StreamHandle> body, |
| 375 const SSLStatus& ssl_status, | 376 const SSLStatus& ssl_status, |
| 376 std::unique_ptr<NavigationData> navigation_data) { | 377 std::unique_ptr<NavigationData> navigation_data, |
| 378 const GlobalRequestID& request_id, |
| 379 bool is_download, |
| 380 bool is_stream) { |
| 377 DCHECK(state_ == STARTED); | 381 DCHECK(state_ == STARTED); |
| 378 state_ = RESPONSE_STARTED; | 382 state_ = RESPONSE_STARTED; |
| 379 | 383 |
| 380 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 384 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
| 381 // commit; they leave the frame showing the previous page. | 385 // commit; they leave the frame showing the previous page. |
| 382 DCHECK(response); | 386 DCHECK(response); |
| 383 if (response->head.headers.get() && | 387 if (response->head.headers.get() && |
| 384 (response->head.headers->response_code() == 204 || | 388 (response->head.headers->response_code() == 204 || |
| 385 response->head.headers->response_code() == 205)) { | 389 response->head.headers->response_code() == 205)) { |
| 386 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( | 390 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 } | 428 } |
| 425 | 429 |
| 426 if (navigation_data) | 430 if (navigation_data) |
| 427 navigation_handle_->set_navigation_data(std::move(navigation_data)); | 431 navigation_handle_->set_navigation_data(std::move(navigation_data)); |
| 428 | 432 |
| 429 // Store the response and the StreamHandle until checks have been processed. | 433 // Store the response and the StreamHandle until checks have been processed. |
| 430 response_ = response; | 434 response_ = response; |
| 431 body_ = std::move(body); | 435 body_ = std::move(body); |
| 432 | 436 |
| 433 // Check if the navigation should be allowed to proceed. | 437 // Check if the navigation should be allowed to proceed. |
| 434 // TODO(clamy): pass the right values for request_id, is_download and | |
| 435 // is_stream. | |
| 436 navigation_handle_->WillProcessResponse( | 438 navigation_handle_->WillProcessResponse( |
| 437 render_frame_host, response->head.headers.get(), | 439 render_frame_host, response->head.headers.get(), |
| 438 response->head.connection_info, ssl_status, GlobalRequestID(), | 440 response->head.connection_info, ssl_status, request_id, |
| 439 common_params_.should_replace_current_entry, false, false, | 441 common_params_.should_replace_current_entry, is_download, is_stream, |
| 440 base::Closure(), | 442 base::Closure(), |
| 441 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, | 443 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, |
| 442 base::Unretained(this))); | 444 base::Unretained(this))); |
| 443 } | 445 } |
| 444 | 446 |
| 445 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, | 447 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, |
| 446 int net_error) { | 448 int net_error) { |
| 447 DCHECK(state_ == STARTED); | 449 DCHECK(state_ == STARTED); |
| 448 state_ = FAILED; | 450 state_ = FAILED; |
| 449 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); | 451 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 TransferNavigationHandleOwnership(render_frame_host); | 599 TransferNavigationHandleOwnership(render_frame_host); |
| 598 | 600 |
| 599 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 601 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 600 common_params_, request_params_, | 602 common_params_, request_params_, |
| 601 is_view_source_); | 603 is_view_source_); |
| 602 | 604 |
| 603 frame_tree_node_->ResetNavigationRequest(true); | 605 frame_tree_node_->ResetNavigationRequest(true); |
| 604 } | 606 } |
| 605 | 607 |
| 606 } // namespace content | 608 } // namespace content |
| OLD | NEW |