Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/debug/dump_without_crashing.h" 9 #include "base/debug/dump_without_crashing.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (result != NavigationThrottle::DEFER) 331 if (result != NavigationThrottle::DEFER)
332 RunCompleteCallback(result); 332 RunCompleteCallback(result);
333 } 333 }
334 334
335 void NavigationHandleImpl::CancelDeferredNavigation( 335 void NavigationHandleImpl::CancelDeferredNavigation(
336 NavigationThrottle::ThrottleCheckResult result) { 336 NavigationThrottle::ThrottleCheckResult result) {
337 DCHECK(state_ == DEFERRING_START || 337 DCHECK(state_ == DEFERRING_START ||
338 state_ == DEFERRING_REDIRECT || 338 state_ == DEFERRING_REDIRECT ||
339 state_ == DEFERRING_RESPONSE); 339 state_ == DEFERRING_RESPONSE);
340 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || 340 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE ||
341 result == NavigationThrottle::CANCEL); 341 result == NavigationThrottle::CANCEL ||
342 result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
343 DCHECK(state_ != DEFERRING_RESPONSE ||
344 result != NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
345
346 if (result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE)
347 frame_tree_node_->SetFrameOwnerCollapsedState(true);
348
342 state_ = CANCELING; 349 state_ = CANCELING;
343 RunCompleteCallback(result); 350 RunCompleteCallback(result);
344 } 351 }
345 352
346 void NavigationHandleImpl::RegisterThrottleForTesting( 353 void NavigationHandleImpl::RegisterThrottleForTesting(
347 std::unique_ptr<NavigationThrottle> navigation_throttle) { 354 std::unique_ptr<NavigationThrottle> navigation_throttle) {
348 throttles_.push_back(std::move(navigation_throttle)); 355 throttles_.push_back(std::move(navigation_throttle));
349 } 356 }
350 357
351 NavigationThrottle::ThrottleCheckResult 358 NavigationThrottle::ThrottleCheckResult
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 socket_address_ = params.socket_address; 649 socket_address_ = params.socket_address;
643 navigation_type_ = navigation_type; 650 navigation_type_ = navigation_type;
644 651
645 // If an error page reloads, net_error_code might be 200 but we still want to 652 // If an error page reloads, net_error_code might be 200 but we still want to
646 // count it as an error page. 653 // count it as an error page.
647 if (params.base_url.spec() == kUnreachableWebDataURL || 654 if (params.base_url.spec() == kUnreachableWebDataURL ||
648 net_error_code_ != net::OK) { 655 net_error_code_ != net::OK) {
649 state_ = DID_COMMIT_ERROR_PAGE; 656 state_ = DID_COMMIT_ERROR_PAGE;
650 } else { 657 } else {
651 state_ = DID_COMMIT; 658 state_ = DID_COMMIT;
659
660 // Getting this far means that the navigation was not blocked, and neither
661 // is this the error page navigation following a blocked navigation. Ensure
662 // the frame owner element is no longer collapsed as a result of a prior
663 // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE.
664 if (!frame_tree_node()->IsMainFrame())
665 frame_tree_node()->SetFrameOwnerCollapsedState(false);
652 } 666 }
653 } 667 }
654 668
655 void NavigationHandleImpl::Transfer() { 669 void NavigationHandleImpl::Transfer() {
656 DCHECK(!IsBrowserSideNavigationEnabled()); 670 DCHECK(!IsBrowserSideNavigationEnabled());
657 // This is an actual transfer. Inform the NavigationResourceThrottle. This 671 // This is an actual transfer. Inform the NavigationResourceThrottle. This
658 // will allow to mark the URLRequest as transferring. When it is marked as 672 // will allow to mark the URLRequest as transferring. When it is marked as
659 // transferring, the URLRequest can no longer be cancelled by its original 673 // transferring, the URLRequest can no longer be cancelled by its original
660 // RenderFrame. Instead it will persist until being picked up by the transfer 674 // RenderFrame. Instead it will persist until being picked up by the transfer
661 // RenderFrame, even if the original RenderFrame is destroyed. 675 // RenderFrame, even if the original RenderFrame is destroyed.
(...skipping 12 matching lines...) Expand all
674 switch (result) { 688 switch (result) {
675 case NavigationThrottle::PROCEED: 689 case NavigationThrottle::PROCEED:
676 continue; 690 continue;
677 691
678 case NavigationThrottle::CANCEL: 692 case NavigationThrottle::CANCEL:
679 case NavigationThrottle::CANCEL_AND_IGNORE: 693 case NavigationThrottle::CANCEL_AND_IGNORE:
680 case NavigationThrottle::BLOCK_REQUEST: 694 case NavigationThrottle::BLOCK_REQUEST:
681 state_ = CANCELING; 695 state_ = CANCELING;
682 return result; 696 return result;
683 697
698 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
699 frame_tree_node_->SetFrameOwnerCollapsedState(true);
700 state_ = CANCELING;
701 return result;
702
684 case NavigationThrottle::DEFER: 703 case NavigationThrottle::DEFER:
685 state_ = DEFERRING_START; 704 state_ = DEFERRING_START;
686 next_index_ = i + 1; 705 next_index_ = i + 1;
687 return result; 706 return result;
688 707
689 case NavigationThrottle::BLOCK_RESPONSE: 708 case NavigationThrottle::BLOCK_RESPONSE:
690 NOTREACHED(); 709 NOTREACHED();
691 } 710 }
692 } 711 }
693 next_index_ = 0; 712 next_index_ = 0;
(...skipping 11 matching lines...) Expand all
705 throttles_[i]->WillRedirectRequest(); 724 throttles_[i]->WillRedirectRequest();
706 switch (result) { 725 switch (result) {
707 case NavigationThrottle::PROCEED: 726 case NavigationThrottle::PROCEED:
708 continue; 727 continue;
709 728
710 case NavigationThrottle::CANCEL: 729 case NavigationThrottle::CANCEL:
711 case NavigationThrottle::CANCEL_AND_IGNORE: 730 case NavigationThrottle::CANCEL_AND_IGNORE:
712 state_ = CANCELING; 731 state_ = CANCELING;
713 return result; 732 return result;
714 733
734 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
735 frame_tree_node_->SetFrameOwnerCollapsedState(true);
736 state_ = CANCELING;
737 return result;
738
715 case NavigationThrottle::DEFER: 739 case NavigationThrottle::DEFER:
716 state_ = DEFERRING_REDIRECT; 740 state_ = DEFERRING_REDIRECT;
717 next_index_ = i + 1; 741 next_index_ = i + 1;
718 return result; 742 return result;
719 743
720 case NavigationThrottle::BLOCK_REQUEST: 744 case NavigationThrottle::BLOCK_REQUEST:
721 case NavigationThrottle::BLOCK_RESPONSE: 745 case NavigationThrottle::BLOCK_RESPONSE:
722 NOTREACHED(); 746 NOTREACHED();
723 } 747 }
724 } 748 }
(...skipping 24 matching lines...) Expand all
749 case NavigationThrottle::BLOCK_RESPONSE: 773 case NavigationThrottle::BLOCK_RESPONSE:
750 state_ = CANCELING; 774 state_ = CANCELING;
751 return result; 775 return result;
752 776
753 case NavigationThrottle::DEFER: 777 case NavigationThrottle::DEFER:
754 state_ = DEFERRING_RESPONSE; 778 state_ = DEFERRING_RESPONSE;
755 next_index_ = i + 1; 779 next_index_ = i + 1;
756 return result; 780 return result;
757 781
758 case NavigationThrottle::BLOCK_REQUEST: 782 case NavigationThrottle::BLOCK_REQUEST:
783 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
759 NOTREACHED(); 784 NOTREACHED();
760 } 785 }
761 } 786 }
762 next_index_ = 0; 787 next_index_ = 0;
763 state_ = WILL_PROCESS_RESPONSE; 788 state_ = WILL_PROCESS_RESPONSE;
764 return NavigationThrottle::PROCEED; 789 return NavigationThrottle::PROCEED;
765 } 790 }
766 791
767 bool NavigationHandleImpl::MaybeTransferAndProceed() { 792 bool NavigationHandleImpl::MaybeTransferAndProceed() {
768 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); 793 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 if (node->current_url().EqualsIgnoringRef(url_)) { 954 if (node->current_url().EqualsIgnoringRef(url_)) {
930 if (found_self_reference) 955 if (found_self_reference)
931 return true; 956 return true;
932 found_self_reference = true; 957 found_self_reference = true;
933 } 958 }
934 } 959 }
935 return false; 960 return false;
936 } 961 }
937 962
938 } // namespace content 963 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698