Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 if (result != NavigationThrottle::DEFER) | 348 if (result != NavigationThrottle::DEFER) |
| 349 RunCompleteCallback(result); | 349 RunCompleteCallback(result); |
| 350 } | 350 } |
| 351 | 351 |
| 352 void NavigationHandleImpl::CancelDeferredNavigation( | 352 void NavigationHandleImpl::CancelDeferredNavigation( |
| 353 NavigationThrottle::ThrottleCheckResult result) { | 353 NavigationThrottle::ThrottleCheckResult result) { |
| 354 DCHECK(state_ == DEFERRING_START || | 354 DCHECK(state_ == DEFERRING_START || |
| 355 state_ == DEFERRING_REDIRECT || | 355 state_ == DEFERRING_REDIRECT || |
| 356 state_ == DEFERRING_RESPONSE); | 356 state_ == DEFERRING_RESPONSE); |
| 357 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 357 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| 358 result == NavigationThrottle::CANCEL); | 358 result == NavigationThrottle::CANCEL || |
| 359 result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE); | |
| 360 DCHECK(result != NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE || | |
| 361 state_ == DEFERRING_START || | |
| 362 (state_ == DEFERRING_REDIRECT && IsBrowserSideNavigationEnabled())); | |
| 363 | |
| 364 if (result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) | |
| 365 frame_tree_node_->SetCollapsed(true); | |
| 366 | |
| 359 state_ = CANCELING; | 367 state_ = CANCELING; |
| 360 RunCompleteCallback(result); | 368 RunCompleteCallback(result); |
| 361 } | 369 } |
| 362 | 370 |
| 363 void NavigationHandleImpl::RegisterThrottleForTesting( | 371 void NavigationHandleImpl::RegisterThrottleForTesting( |
| 364 std::unique_ptr<NavigationThrottle> navigation_throttle) { | 372 std::unique_ptr<NavigationThrottle> navigation_throttle) { |
| 365 throttles_.push_back(std::move(navigation_throttle)); | 373 throttles_.push_back(std::move(navigation_throttle)); |
| 366 } | 374 } |
| 367 | 375 |
| 368 NavigationThrottle::ThrottleCheckResult | 376 NavigationThrottle::ThrottleCheckResult |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 << "NavigationEntry"; | 681 << "NavigationEntry"; |
| 674 subframe_entry_committed_ = navigation_entry_committed; | 682 subframe_entry_committed_ = navigation_entry_committed; |
| 675 | 683 |
| 676 // If an error page reloads, net_error_code might be 200 but we still want to | 684 // If an error page reloads, net_error_code might be 200 but we still want to |
| 677 // count it as an error page. | 685 // count it as an error page. |
| 678 if (params.base_url.spec() == kUnreachableWebDataURL || | 686 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 679 net_error_code_ != net::OK) { | 687 net_error_code_ != net::OK) { |
| 680 state_ = DID_COMMIT_ERROR_PAGE; | 688 state_ = DID_COMMIT_ERROR_PAGE; |
| 681 } else { | 689 } else { |
| 682 state_ = DID_COMMIT; | 690 state_ = DID_COMMIT; |
| 691 | |
| 692 // Getting this far means that the navigation was not blocked, and neither | |
| 693 // is this the error page navigation following a blocked navigation. Ensure | |
| 694 // the frame owner element is no longer collapsed as a result of a prior | |
| 695 // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE. | |
| 696 if (!frame_tree_node()->IsMainFrame()) | |
| 697 frame_tree_node()->SetCollapsed(false); | |
|
clamy
2017/04/24 13:15:18
What about SameDocument navigations? We should che
engedy
2017/04/28 13:43:59
If the frame is currently collapsed, it will be sh
| |
| 683 } | 698 } |
| 684 | 699 |
| 685 if (url_.SchemeIs(url::kDataScheme) && IsInMainFrame() && | 700 if (url_.SchemeIs(url::kDataScheme) && IsInMainFrame() && |
| 686 IsRendererInitiated()) { | 701 IsRendererInitiated()) { |
| 687 GetRenderFrameHost()->AddMessageToConsole( | 702 GetRenderFrameHost()->AddMessageToConsole( |
| 688 CONSOLE_MESSAGE_LEVEL_WARNING, | 703 CONSOLE_MESSAGE_LEVEL_WARNING, |
| 689 "Upcoming versions will block content-initiated top frame navigations " | 704 "Upcoming versions will block content-initiated top frame navigations " |
| 690 "to data: URLs. For more information, see https://goo.gl/BaZAea."); | 705 "to data: URLs. For more information, see https://goo.gl/BaZAea."); |
| 691 } | 706 } |
| 692 } | 707 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 715 switch (result) { | 730 switch (result) { |
| 716 case NavigationThrottle::PROCEED: | 731 case NavigationThrottle::PROCEED: |
| 717 continue; | 732 continue; |
| 718 | 733 |
| 719 case NavigationThrottle::BLOCK_REQUEST: | 734 case NavigationThrottle::BLOCK_REQUEST: |
| 720 case NavigationThrottle::CANCEL: | 735 case NavigationThrottle::CANCEL: |
| 721 case NavigationThrottle::CANCEL_AND_IGNORE: | 736 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 722 state_ = CANCELING; | 737 state_ = CANCELING; |
| 723 return result; | 738 return result; |
| 724 | 739 |
| 740 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE: | |
|
clamy
2017/04/24 13:15:18
nit: I'd prefer if we were consistent when using f
engedy
2017/04/28 13:43:58
Done.
| |
| 741 frame_tree_node_->SetCollapsed(true); | |
| 742 state_ = CANCELING; | |
| 743 return result; | |
| 744 | |
| 725 case NavigationThrottle::DEFER: | 745 case NavigationThrottle::DEFER: |
| 726 state_ = DEFERRING_START; | 746 state_ = DEFERRING_START; |
| 727 next_index_ = i + 1; | 747 next_index_ = i + 1; |
| 728 return result; | 748 return result; |
| 729 | 749 |
| 730 case NavigationThrottle::BLOCK_RESPONSE: | 750 case NavigationThrottle::BLOCK_RESPONSE: |
| 731 NOTREACHED(); | 751 NOTREACHED(); |
| 732 } | 752 } |
| 733 } | 753 } |
| 734 next_index_ = 0; | 754 next_index_ = 0; |
| 735 state_ = WILL_SEND_REQUEST; | 755 state_ = WILL_SEND_REQUEST; |
| 736 return NavigationThrottle::PROCEED; | 756 return NavigationThrottle::PROCEED; |
| 737 } | 757 } |
| 738 | 758 |
| 739 NavigationThrottle::ThrottleCheckResult | 759 NavigationThrottle::ThrottleCheckResult |
| 740 NavigationHandleImpl::CheckWillRedirectRequest() { | 760 NavigationHandleImpl::CheckWillRedirectRequest() { |
| 741 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 761 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
| 742 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); | 762 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); |
| 743 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); | 763 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); |
| 744 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 764 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 745 NavigationThrottle::ThrottleCheckResult result = | 765 NavigationThrottle::ThrottleCheckResult result = |
| 746 throttles_[i]->WillRedirectRequest(); | 766 throttles_[i]->WillRedirectRequest(); |
| 747 switch (result) { | 767 switch (result) { |
| 748 case NavigationThrottle::PROCEED: | 768 case NavigationThrottle::PROCEED: |
| 749 continue; | 769 continue; |
| 750 | 770 |
| 771 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE: | |
| 772 frame_tree_node_->SetCollapsed(true); | |
| 773 // Fall through. | |
|
nasko
2017/04/20 15:53:40
nit: Indent this to match the call above.
engedy
2017/04/28 13:43:59
I moved it after the call, clang-format does not l
| |
| 751 case NavigationThrottle::BLOCK_REQUEST: | 774 case NavigationThrottle::BLOCK_REQUEST: |
| 752 CHECK(IsBrowserSideNavigationEnabled()) | 775 CHECK(IsBrowserSideNavigationEnabled()) |
| 753 << "BLOCK_REQUEST must not be used on redirect without PlzNavigate"; | 776 << "BLOCK_REQUEST and BLOCK_REQUEST_AND_COLLAPSE must not be used " |
| 777 "on redirect without PlzNavigate"; | |
| 754 case NavigationThrottle::CANCEL: | 778 case NavigationThrottle::CANCEL: |
| 755 case NavigationThrottle::CANCEL_AND_IGNORE: | 779 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 756 state_ = CANCELING; | 780 state_ = CANCELING; |
| 757 return result; | 781 return result; |
| 758 | 782 |
| 759 case NavigationThrottle::DEFER: | 783 case NavigationThrottle::DEFER: |
| 760 state_ = DEFERRING_REDIRECT; | 784 state_ = DEFERRING_REDIRECT; |
| 761 next_index_ = i + 1; | 785 next_index_ = i + 1; |
| 762 return result; | 786 return result; |
| 763 | 787 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 792 case NavigationThrottle::BLOCK_RESPONSE: | 816 case NavigationThrottle::BLOCK_RESPONSE: |
| 793 state_ = CANCELING; | 817 state_ = CANCELING; |
| 794 return result; | 818 return result; |
| 795 | 819 |
| 796 case NavigationThrottle::DEFER: | 820 case NavigationThrottle::DEFER: |
| 797 state_ = DEFERRING_RESPONSE; | 821 state_ = DEFERRING_RESPONSE; |
| 798 next_index_ = i + 1; | 822 next_index_ = i + 1; |
| 799 return result; | 823 return result; |
| 800 | 824 |
| 801 case NavigationThrottle::BLOCK_REQUEST: | 825 case NavigationThrottle::BLOCK_REQUEST: |
| 826 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE: | |
| 802 NOTREACHED(); | 827 NOTREACHED(); |
| 803 } | 828 } |
| 804 } | 829 } |
| 805 next_index_ = 0; | 830 next_index_ = 0; |
| 806 state_ = WILL_PROCESS_RESPONSE; | 831 state_ = WILL_PROCESS_RESPONSE; |
| 807 return NavigationThrottle::PROCEED; | 832 return NavigationThrottle::PROCEED; |
| 808 } | 833 } |
| 809 | 834 |
| 810 bool NavigationHandleImpl::MaybeTransferAndProceed() { | 835 bool NavigationHandleImpl::MaybeTransferAndProceed() { |
| 811 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); | 836 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 if (node->current_url().EqualsIgnoringRef(url_)) { | 1008 if (node->current_url().EqualsIgnoringRef(url_)) { |
| 984 if (found_self_reference) | 1009 if (found_self_reference) |
| 985 return true; | 1010 return true; |
| 986 found_self_reference = true; | 1011 found_self_reference = true; |
| 987 } | 1012 } |
| 988 } | 1013 } |
| 989 return false; | 1014 return false; |
| 990 } | 1015 } |
| 991 | 1016 |
| 992 } // namespace content | 1017 } // namespace content |
| OLD | NEW |