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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 DCHECK(result != NavigationThrottle::DEFER); | 575 DCHECK(result != NavigationThrottle::DEFER); |
576 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); | 576 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); |
577 | 577 |
578 if (on_start_checks_complete_closure_) | 578 if (on_start_checks_complete_closure_) |
579 on_start_checks_complete_closure_.Run(); | 579 on_start_checks_complete_closure_.Run(); |
580 | 580 |
581 // Abort the request if needed. This will destroy the NavigationRequest. | 581 // Abort the request if needed. This will destroy the NavigationRequest. |
582 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 582 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
583 result == NavigationThrottle::CANCEL) { | 583 result == NavigationThrottle::CANCEL) { |
584 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 584 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
585 frame_tree_node_->ResetNavigationRequest(false); | 585 OnRequestFailed(false, net::ERR_ABORTED); |
| 586 |
| 587 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 588 // destroyed the NavigationRequest. |
586 return; | 589 return; |
587 } | 590 } |
588 | 591 |
589 if (result == NavigationThrottle::BLOCK_REQUEST) { | 592 if (result == NavigationThrottle::BLOCK_REQUEST) { |
590 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); | 593 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); |
| 594 |
591 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 595 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
592 // destroyed the NavigationRequest. | 596 // destroyed the NavigationRequest. |
593 return; | 597 return; |
594 } | 598 } |
595 | 599 |
596 // Use the SiteInstance of the navigating RenderFrameHost to get access to | 600 // Use the SiteInstance of the navigating RenderFrameHost to get access to |
597 // the StoragePartition. Using the url of the navigation will result in a | 601 // the StoragePartition. Using the url of the navigation will result in a |
598 // wrong StoragePartition being picked when a WebView is navigating. | 602 // wrong StoragePartition being picked when a WebView is navigating. |
599 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); | 603 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); |
600 RenderFrameHostImpl* navigating_frame_host = | 604 RenderFrameHostImpl* navigating_frame_host = |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 | 672 |
669 void NavigationRequest::OnRedirectChecksComplete( | 673 void NavigationRequest::OnRedirectChecksComplete( |
670 NavigationThrottle::ThrottleCheckResult result) { | 674 NavigationThrottle::ThrottleCheckResult result) { |
671 DCHECK(result != NavigationThrottle::DEFER); | 675 DCHECK(result != NavigationThrottle::DEFER); |
672 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); | 676 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); |
673 | 677 |
674 // Abort the request if needed. This will destroy the NavigationRequest. | 678 // Abort the request if needed. This will destroy the NavigationRequest. |
675 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 679 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
676 result == NavigationThrottle::CANCEL) { | 680 result == NavigationThrottle::CANCEL) { |
677 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 681 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
678 frame_tree_node_->ResetNavigationRequest(false); | 682 OnRequestFailed(false, net::ERR_ABORTED); |
| 683 |
| 684 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 685 // destroyed the NavigationRequest. |
679 return; | 686 return; |
680 } | 687 } |
681 | 688 |
682 loader_->FollowRedirect(); | 689 loader_->FollowRedirect(); |
683 } | 690 } |
684 | 691 |
685 void NavigationRequest::OnWillProcessResponseChecksComplete( | 692 void NavigationRequest::OnWillProcessResponseChecksComplete( |
686 NavigationThrottle::ThrottleCheckResult result) { | 693 NavigationThrottle::ThrottleCheckResult result) { |
687 DCHECK(result != NavigationThrottle::DEFER); | 694 DCHECK(result != NavigationThrottle::DEFER); |
688 | 695 |
689 // Abort the request if needed. This includes requests that were blocked by | 696 // Abort the request if needed. This includes requests that were blocked by |
690 // NavigationThrottles and requests that should not commit (e.g. downloads, | 697 // NavigationThrottles and requests that should not commit (e.g. downloads, |
691 // 204/205s). This will destroy the NavigationRequest. | 698 // 204/205s). This will destroy the NavigationRequest. |
692 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 699 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
693 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { | 700 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { |
694 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 701 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
695 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( | 702 OnRequestFailed(false, net::ERR_ABORTED); |
696 navigation_handle_.get()); | 703 |
697 frame_tree_node_->ResetNavigationRequest(false); | 704 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 705 // destroyed the NavigationRequest. |
698 return; | 706 return; |
699 } | 707 } |
700 | 708 |
701 if (result == NavigationThrottle::BLOCK_RESPONSE) { | 709 if (result == NavigationThrottle::BLOCK_RESPONSE) { |
702 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE); | 710 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE); |
703 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 711 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
704 // destroyed the NavigationRequest. | 712 // destroyed the NavigationRequest. |
705 return; | 713 return; |
706 } | 714 } |
707 | 715 |
(...skipping 23 matching lines...) Expand all Loading... |
731 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 739 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
732 | 740 |
733 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 741 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
734 common_params_, request_params_, | 742 common_params_, request_params_, |
735 is_view_source_); | 743 is_view_source_); |
736 | 744 |
737 frame_tree_node_->ResetNavigationRequest(true); | 745 frame_tree_node_->ResetNavigationRequest(true); |
738 } | 746 } |
739 | 747 |
740 } // namespace content | 748 } // namespace content |
OLD | NEW |