| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 void NavigationRequest::BeginNavigation() { | 353 void NavigationRequest::BeginNavigation() { |
| 354 DCHECK(!loader_); | 354 DCHECK(!loader_); |
| 355 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); | 355 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); |
| 356 state_ = STARTED; | 356 state_ = STARTED; |
| 357 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); | 357 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); |
| 358 | 358 |
| 359 if (ShouldMakeNetworkRequestForURL(common_params_.url) && | 359 if (ShouldMakeNetworkRequestForURL(common_params_.url) && |
| 360 !navigation_handle_->IsSameDocument()) { | 360 !navigation_handle_->IsSameDocument()) { |
| 361 // It's safe to use base::Unretained because this NavigationRequest owns | 361 // It's safe to use base::Unretained because this NavigationRequest owns |
| 362 // the NavigationHandle where the callback will be stored. | 362 // the NavigationHandle where the callback will be stored. |
| 363 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | |
| 364 // TODO(clamy): pass the method to the NavigationHandle instead of a | 363 // TODO(clamy): pass the method to the NavigationHandle instead of a |
| 365 // boolean. | 364 // boolean. |
| 365 bool is_external_protocol = |
| 366 !GetContentClient()->browser()->IsHandledURL(common_params_.url); |
| 366 navigation_handle_->WillStartRequest( | 367 navigation_handle_->WillStartRequest( |
| 367 common_params_.method, common_params_.post_data, | 368 common_params_.method, common_params_.post_data, |
| 368 Referrer::SanitizeForRequest(common_params_.url, | 369 Referrer::SanitizeForRequest(common_params_.url, |
| 369 common_params_.referrer), | 370 common_params_.referrer), |
| 370 begin_params_.has_user_gesture, common_params_.transition, false, | 371 begin_params_.has_user_gesture, common_params_.transition, |
| 371 begin_params_.request_context_type, | 372 is_external_protocol, begin_params_.request_context_type, |
| 372 begin_params_.mixed_content_context_type, | 373 begin_params_.mixed_content_context_type, |
| 373 base::Bind(&NavigationRequest::OnStartChecksComplete, | 374 base::Bind(&NavigationRequest::OnStartChecksComplete, |
| 374 base::Unretained(this))); | 375 base::Unretained(this))); |
| 375 return; | 376 return; |
| 376 } | 377 } |
| 377 | 378 |
| 378 // There is no need to make a network request for this navigation, so commit | 379 // There is no need to make a network request for this navigation, so commit |
| 379 // it immediately. | 380 // it immediately. |
| 380 state_ = RESPONSE_STARTED; | 381 state_ = RESPONSE_STARTED; |
| 381 | 382 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // FilterURL sets the URL to about:blank if the CSP checks prevent the | 474 // FilterURL sets the URL to about:blank if the CSP checks prevent the |
| 474 // renderer from accessing it. | 475 // renderer from accessing it. |
| 475 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { | 476 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { |
| 476 frame_tree_node_->ResetNavigationRequest(false); | 477 frame_tree_node_->ResetNavigationRequest(false); |
| 477 return; | 478 return; |
| 478 } | 479 } |
| 479 } | 480 } |
| 480 | 481 |
| 481 // It's safe to use base::Unretained because this NavigationRequest owns the | 482 // It's safe to use base::Unretained because this NavigationRequest owns the |
| 482 // NavigationHandle where the callback will be stored. | 483 // NavigationHandle where the callback will be stored. |
| 483 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 484 bool is_external_protocol = |
| 485 !GetContentClient()->browser()->IsHandledURL(common_params_.url); |
| 484 navigation_handle_->WillRedirectRequest( | 486 navigation_handle_->WillRedirectRequest( |
| 485 common_params_.url, common_params_.method, common_params_.referrer.url, | 487 common_params_.url, common_params_.method, common_params_.referrer.url, |
| 486 false, response->head.headers, response->head.connection_info, | 488 is_external_protocol, response->head.headers, |
| 489 response->head.connection_info, |
| 487 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 490 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
| 488 base::Unretained(this))); | 491 base::Unretained(this))); |
| 489 } | 492 } |
| 490 | 493 |
| 491 void NavigationRequest::OnResponseStarted( | 494 void NavigationRequest::OnResponseStarted( |
| 492 const scoped_refptr<ResourceResponse>& response, | 495 const scoped_refptr<ResourceResponse>& response, |
| 493 std::unique_ptr<StreamHandle> body, | 496 std::unique_ptr<StreamHandle> body, |
| 494 const SSLStatus& ssl_status, | 497 const SSLStatus& ssl_status, |
| 495 std::unique_ptr<NavigationData> navigation_data, | 498 std::unique_ptr<NavigationData> navigation_data, |
| 496 const GlobalRequestID& request_id, | 499 const GlobalRequestID& request_id, |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 826 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 824 | 827 |
| 825 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 828 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 826 common_params_, request_params_, | 829 common_params_, request_params_, |
| 827 is_view_source_); | 830 is_view_source_); |
| 828 | 831 |
| 829 frame_tree_node_->ResetNavigationRequest(true); | 832 frame_tree_node_->ResetNavigationRequest(true); |
| 830 } | 833 } |
| 831 | 834 |
| 832 } // namespace content | 835 } // namespace content |
| OLD | NEW |