| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 NavigationRequest::~NavigationRequest() { | 338 NavigationRequest::~NavigationRequest() { |
| 339 } | 339 } |
| 340 | 340 |
| 341 void NavigationRequest::BeginNavigation() { | 341 void NavigationRequest::BeginNavigation() { |
| 342 DCHECK(!loader_); | 342 DCHECK(!loader_); |
| 343 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); | 343 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); |
| 344 state_ = STARTED; | 344 state_ = STARTED; |
| 345 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); | 345 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); |
| 346 | 346 |
| 347 if (ShouldMakeNetworkRequestForURL(common_params_.url) && | 347 if (ShouldMakeNetworkRequestForURL(common_params_.url) && |
| 348 !navigation_handle_->IsSamePage()) { | 348 !navigation_handle_->IsSameDocument()) { |
| 349 // It's safe to use base::Unretained because this NavigationRequest owns | 349 // It's safe to use base::Unretained because this NavigationRequest owns |
| 350 // the NavigationHandle where the callback will be stored. | 350 // the NavigationHandle where the callback will be stored. |
| 351 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 351 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
| 352 // TODO(clamy): pass the method to the NavigationHandle instead of a | 352 // TODO(clamy): pass the method to the NavigationHandle instead of a |
| 353 // boolean. | 353 // boolean. |
| 354 navigation_handle_->WillStartRequest( | 354 navigation_handle_->WillStartRequest( |
| 355 common_params_.method, common_params_.post_data, | 355 common_params_.method, common_params_.post_data, |
| 356 Referrer::SanitizeForRequest(common_params_.url, | 356 Referrer::SanitizeForRequest(common_params_.url, |
| 357 common_params_.referrer), | 357 common_params_.referrer), |
| 358 begin_params_.has_user_gesture, common_params_.transition, false, | 358 begin_params_.has_user_gesture, common_params_.transition, false, |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 loader_->ProceedWithResponse(); | 746 loader_->ProceedWithResponse(); |
| 747 | 747 |
| 748 CommitNavigation(); | 748 CommitNavigation(); |
| 749 | 749 |
| 750 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused | 750 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused |
| 751 // the destruction of the NavigationRequest. | 751 // the destruction of the NavigationRequest. |
| 752 } | 752 } |
| 753 | 753 |
| 754 void NavigationRequest::CommitNavigation() { | 754 void NavigationRequest::CommitNavigation() { |
| 755 DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url) || | 755 DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url) || |
| 756 navigation_handle_->IsSamePage()); | 756 navigation_handle_->IsSameDocument()); |
| 757 DCHECK(!common_params_.url.SchemeIs(url::kJavaScriptScheme)); | 757 DCHECK(!common_params_.url.SchemeIs(url::kJavaScriptScheme)); |
| 758 | 758 |
| 759 // Retrieve the RenderFrameHost that needs to commit the navigation. | 759 // Retrieve the RenderFrameHost that needs to commit the navigation. |
| 760 RenderFrameHostImpl* render_frame_host = | 760 RenderFrameHostImpl* render_frame_host = |
| 761 navigation_handle_->GetRenderFrameHost(); | 761 navigation_handle_->GetRenderFrameHost(); |
| 762 DCHECK(render_frame_host == | 762 DCHECK(render_frame_host == |
| 763 frame_tree_node_->render_manager()->current_frame_host() || | 763 frame_tree_node_->render_manager()->current_frame_host() || |
| 764 render_frame_host == | 764 render_frame_host == |
| 765 frame_tree_node_->render_manager()->speculative_frame_host()); | 765 frame_tree_node_->render_manager()->speculative_frame_host()); |
| 766 | 766 |
| 767 TransferNavigationHandleOwnership(render_frame_host); | 767 TransferNavigationHandleOwnership(render_frame_host); |
| 768 | 768 |
| 769 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 769 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 770 | 770 |
| 771 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 771 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 772 common_params_, request_params_, | 772 common_params_, request_params_, |
| 773 is_view_source_); | 773 is_view_source_); |
| 774 | 774 |
| 775 frame_tree_node_->ResetNavigationRequest(true); | 775 frame_tree_node_->ResetNavigationRequest(true); |
| 776 } | 776 } |
| 777 | 777 |
| 778 } // namespace content | 778 } // namespace content |
| OLD | NEW |