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 "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/common/resource_request_body_impl.h" | 29 #include "content/common/resource_request_body_impl.h" |
30 #include "content/public/browser/browser_context.h" | 30 #include "content/public/browser/browser_context.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
33 #include "content/public/browser/global_request_id.h" | 33 #include "content/public/browser/global_request_id.h" |
34 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
35 #include "content/public/browser/navigation_data.h" | 35 #include "content/public/browser/navigation_data.h" |
36 #include "content/public/browser/navigation_ui_data.h" | 36 #include "content/public/browser/navigation_ui_data.h" |
37 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
38 #include "content/public/browser/storage_partition.h" | 38 #include "content/public/browser/storage_partition.h" |
39 #include "content/public/browser/stream_handle.h" | |
40 #include "content/public/common/appcache_info.h" | 39 #include "content/public/common/appcache_info.h" |
41 #include "content/public/common/content_client.h" | 40 #include "content/public/common/content_client.h" |
42 #include "content/public/common/origin_util.h" | 41 #include "content/public/common/origin_util.h" |
43 #include "content/public/common/request_context_type.h" | 42 #include "content/public/common/request_context_type.h" |
44 #include "content/public/common/resource_response.h" | 43 #include "content/public/common/resource_response.h" |
45 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
46 #include "content/public/common/web_preferences.h" | 45 #include "content/public/common/web_preferences.h" |
47 #include "net/base/load_flags.h" | 46 #include "net/base/load_flags.h" |
48 #include "net/base/net_errors.h" | 47 #include "net/base/net_errors.h" |
49 #include "net/base/url_util.h" | 48 #include "net/base/url_util.h" |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 navigation_handle_->WillRedirectRequest( | 500 navigation_handle_->WillRedirectRequest( |
502 common_params_.url, common_params_.method, common_params_.referrer.url, | 501 common_params_.url, common_params_.method, common_params_.referrer.url, |
503 is_external_protocol, response->head.headers, | 502 is_external_protocol, response->head.headers, |
504 response->head.connection_info, | 503 response->head.connection_info, |
505 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 504 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
506 base::Unretained(this))); | 505 base::Unretained(this))); |
507 } | 506 } |
508 | 507 |
509 void NavigationRequest::OnResponseStarted( | 508 void NavigationRequest::OnResponseStarted( |
510 const scoped_refptr<ResourceResponse>& response, | 509 const scoped_refptr<ResourceResponse>& response, |
511 std::unique_ptr<StreamHandle> body, | 510 mojo::ScopedDataPipeConsumerHandle handle, |
512 const SSLStatus& ssl_status, | 511 const SSLStatus& ssl_status, |
513 std::unique_ptr<NavigationData> navigation_data, | 512 std::unique_ptr<NavigationData> navigation_data, |
514 const GlobalRequestID& request_id, | 513 const GlobalRequestID& request_id, |
515 bool is_download, | 514 bool is_download, |
516 bool is_stream) { | 515 bool is_stream) { |
| 516 DCHECK(handle.is_valid()); |
517 DCHECK(state_ == STARTED); | 517 DCHECK(state_ == STARTED); |
518 DCHECK(response); | 518 DCHECK(response); |
519 state_ = RESPONSE_STARTED; | 519 state_ = RESPONSE_STARTED; |
520 | 520 |
521 // Check if the response should be sent to a renderer. | 521 // Check if the response should be sent to a renderer. |
522 response_should_be_rendered_ = | 522 response_should_be_rendered_ = |
523 !is_download && (!response->head.headers.get() || | 523 !is_download && (!response->head.headers.get() || |
524 (response->head.headers->response_code() != 204 && | 524 (response->head.headers->response_code() != 204 && |
525 response->head.headers->response_code() != 205)); | 525 response->head.headers->response_code() != 205)); |
526 | 526 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation( | 571 if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation( |
572 frame_tree_node_->IsMainFrame())) { | 572 frame_tree_node_->IsMainFrame())) { |
573 frame_tree_node_->ResetNavigationRequest(false, true); | 573 frame_tree_node_->ResetNavigationRequest(false, true); |
574 return; | 574 return; |
575 } | 575 } |
576 } | 576 } |
577 | 577 |
578 if (navigation_data) | 578 if (navigation_data) |
579 navigation_handle_->set_navigation_data(std::move(navigation_data)); | 579 navigation_handle_->set_navigation_data(std::move(navigation_data)); |
580 | 580 |
581 // Store the response and the StreamHandle until checks have been processed. | 581 // Store the response and the data pipe until checks have been processed. |
582 response_ = response; | 582 response_ = response; |
583 body_ = std::move(body); | 583 handle_ = std::move(handle); |
584 | 584 |
585 // Check if the navigation should be allowed to proceed. | 585 // Check if the navigation should be allowed to proceed. |
586 navigation_handle_->WillProcessResponse( | 586 navigation_handle_->WillProcessResponse( |
587 render_frame_host, response->head.headers.get(), | 587 render_frame_host, response->head.headers.get(), |
588 response->head.connection_info, ssl_status, request_id, | 588 response->head.connection_info, ssl_status, request_id, |
589 common_params_.should_replace_current_entry, is_download, is_stream, | 589 common_params_.should_replace_current_entry, is_download, is_stream, |
590 base::Closure(), | 590 base::Closure(), |
591 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, | 591 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, |
592 base::Unretained(this))); | 592 base::Unretained(this))); |
593 } | 593 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 navigation_handle_->GetRenderFrameHost(); | 835 navigation_handle_->GetRenderFrameHost(); |
836 DCHECK(render_frame_host == | 836 DCHECK(render_frame_host == |
837 frame_tree_node_->render_manager()->current_frame_host() || | 837 frame_tree_node_->render_manager()->current_frame_host() || |
838 render_frame_host == | 838 render_frame_host == |
839 frame_tree_node_->render_manager()->speculative_frame_host()); | 839 frame_tree_node_->render_manager()->speculative_frame_host()); |
840 | 840 |
841 TransferNavigationHandleOwnership(render_frame_host); | 841 TransferNavigationHandleOwnership(render_frame_host); |
842 | 842 |
843 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 843 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
844 | 844 |
845 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 845 render_frame_host->CommitNavigation(response_.get(), std::move(handle_), |
846 common_params_, request_params_, | 846 common_params_, request_params_, |
847 is_view_source_); | 847 is_view_source_); |
848 | 848 |
849 frame_tree_node_->ResetNavigationRequest(true, true); | 849 frame_tree_node_->ResetNavigationRequest(true, true); |
850 } | 850 } |
851 | 851 |
852 } // namespace content | 852 } // namespace content |
OLD | NEW |