| 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/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 if (result != NavigationThrottle::DEFER) | 280 if (result != NavigationThrottle::DEFER) |
| 281 RunCompleteCallback(result); | 281 RunCompleteCallback(result); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void NavigationHandleImpl::CancelDeferredNavigation( | 284 void NavigationHandleImpl::CancelDeferredNavigation( |
| 285 NavigationThrottle::ThrottleCheckResult result) { | 285 NavigationThrottle::ThrottleCheckResult result) { |
| 286 DCHECK(state_ == DEFERRING_START || | 286 DCHECK(state_ == DEFERRING_START || |
| 287 state_ == DEFERRING_REDIRECT || | 287 state_ == DEFERRING_REDIRECT || |
| 288 state_ == DEFERRING_RESPONSE); | 288 state_ == DEFERRING_RESPONSE); |
| 289 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 289 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| 290 result == NavigationThrottle::CANCEL); | 290 result == NavigationThrottle::CANCEL || |
| 291 result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE); |
| 292 DCHECK(state_ != DEFERRING_RESPONSE || |
| 293 result != NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE); |
| 294 |
| 295 if (result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) |
| 296 frame_tree_node_->SetFrameOwnerCollapsedState(true); |
| 297 |
| 291 state_ = CANCELING; | 298 state_ = CANCELING; |
| 292 RunCompleteCallback(result); | 299 RunCompleteCallback(result); |
| 293 } | 300 } |
| 294 | 301 |
| 295 void NavigationHandleImpl::RegisterThrottleForTesting( | 302 void NavigationHandleImpl::RegisterThrottleForTesting( |
| 296 std::unique_ptr<NavigationThrottle> navigation_throttle) { | 303 std::unique_ptr<NavigationThrottle> navigation_throttle) { |
| 297 throttles_.push_back(std::move(navigation_throttle)); | 304 throttles_.push_back(std::move(navigation_throttle)); |
| 298 } | 305 } |
| 299 | 306 |
| 300 NavigationThrottle::ThrottleCheckResult | 307 NavigationThrottle::ThrottleCheckResult |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 transition_ = params.transition; | 560 transition_ = params.transition; |
| 554 render_frame_host_ = render_frame_host; | 561 render_frame_host_ = render_frame_host; |
| 555 | 562 |
| 556 // If an error page reloads, net_error_code might be 200 but we still want to | 563 // If an error page reloads, net_error_code might be 200 but we still want to |
| 557 // count it as an error page. | 564 // count it as an error page. |
| 558 if (params.base_url.spec() == kUnreachableWebDataURL || | 565 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 559 net_error_code_ != net::OK) { | 566 net_error_code_ != net::OK) { |
| 560 state_ = DID_COMMIT_ERROR_PAGE; | 567 state_ = DID_COMMIT_ERROR_PAGE; |
| 561 } else { | 568 } else { |
| 562 state_ = DID_COMMIT; | 569 state_ = DID_COMMIT; |
| 570 |
| 571 // Getting this far means that the navigation was not blocked, and neither |
| 572 // is this the error page navigation following a blocked navigation. Ensure |
| 573 // the frame owner element is no longer collapsed as a result of a prior |
| 574 // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE. |
| 575 if (!frame_tree_node()->IsMainFrame()) |
| 576 frame_tree_node()->SetFrameOwnerCollapsedState(false); |
| 563 } | 577 } |
| 564 } | 578 } |
| 565 | 579 |
| 566 void NavigationHandleImpl::Transfer() { | 580 void NavigationHandleImpl::Transfer() { |
| 567 DCHECK(!IsBrowserSideNavigationEnabled()); | 581 DCHECK(!IsBrowserSideNavigationEnabled()); |
| 568 // This is an actual transfer. Inform the NavigationResourceThrottle. This | 582 // This is an actual transfer. Inform the NavigationResourceThrottle. This |
| 569 // will allow to mark the URLRequest as transferring. When it is marked as | 583 // will allow to mark the URLRequest as transferring. When it is marked as |
| 570 // transferring, the URLRequest can no longer be cancelled by its original | 584 // transferring, the URLRequest can no longer be cancelled by its original |
| 571 // RenderFrame. Instead it will persist until being picked up by the transfer | 585 // RenderFrame. Instead it will persist until being picked up by the transfer |
| 572 // RenderFrame, even if the original RenderFrame is destroyed. | 586 // RenderFrame, even if the original RenderFrame is destroyed. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 585 switch (result) { | 599 switch (result) { |
| 586 case NavigationThrottle::PROCEED: | 600 case NavigationThrottle::PROCEED: |
| 587 continue; | 601 continue; |
| 588 | 602 |
| 589 case NavigationThrottle::CANCEL: | 603 case NavigationThrottle::CANCEL: |
| 590 case NavigationThrottle::CANCEL_AND_IGNORE: | 604 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 591 case NavigationThrottle::BLOCK_REQUEST: | 605 case NavigationThrottle::BLOCK_REQUEST: |
| 592 state_ = CANCELING; | 606 state_ = CANCELING; |
| 593 return result; | 607 return result; |
| 594 | 608 |
| 609 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE: |
| 610 frame_tree_node_->SetFrameOwnerCollapsedState(true); |
| 611 state_ = CANCELING; |
| 612 return result; |
| 613 |
| 595 case NavigationThrottle::DEFER: | 614 case NavigationThrottle::DEFER: |
| 596 state_ = DEFERRING_START; | 615 state_ = DEFERRING_START; |
| 597 next_index_ = i + 1; | 616 next_index_ = i + 1; |
| 598 return result; | 617 return result; |
| 599 | 618 |
| 600 case NavigationThrottle::BLOCK_RESPONSE: | 619 case NavigationThrottle::BLOCK_RESPONSE: |
| 601 NOTREACHED(); | 620 NOTREACHED(); |
| 602 } | 621 } |
| 603 } | 622 } |
| 604 next_index_ = 0; | 623 next_index_ = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 616 throttles_[i]->WillRedirectRequest(); | 635 throttles_[i]->WillRedirectRequest(); |
| 617 switch (result) { | 636 switch (result) { |
| 618 case NavigationThrottle::PROCEED: | 637 case NavigationThrottle::PROCEED: |
| 619 continue; | 638 continue; |
| 620 | 639 |
| 621 case NavigationThrottle::CANCEL: | 640 case NavigationThrottle::CANCEL: |
| 622 case NavigationThrottle::CANCEL_AND_IGNORE: | 641 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 623 state_ = CANCELING; | 642 state_ = CANCELING; |
| 624 return result; | 643 return result; |
| 625 | 644 |
| 645 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE: |
| 646 frame_tree_node_->SetFrameOwnerCollapsedState(true); |
| 647 state_ = CANCELING; |
| 648 return result; |
| 649 |
| 626 case NavigationThrottle::DEFER: | 650 case NavigationThrottle::DEFER: |
| 627 state_ = DEFERRING_REDIRECT; | 651 state_ = DEFERRING_REDIRECT; |
| 628 next_index_ = i + 1; | 652 next_index_ = i + 1; |
| 629 return result; | 653 return result; |
| 630 | 654 |
| 631 case NavigationThrottle::BLOCK_REQUEST: | 655 case NavigationThrottle::BLOCK_REQUEST: |
| 632 case NavigationThrottle::BLOCK_RESPONSE: | 656 case NavigationThrottle::BLOCK_RESPONSE: |
| 633 NOTREACHED(); | 657 NOTREACHED(); |
| 634 } | 658 } |
| 635 } | 659 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 660 case NavigationThrottle::BLOCK_RESPONSE: | 684 case NavigationThrottle::BLOCK_RESPONSE: |
| 661 state_ = CANCELING; | 685 state_ = CANCELING; |
| 662 return result; | 686 return result; |
| 663 | 687 |
| 664 case NavigationThrottle::DEFER: | 688 case NavigationThrottle::DEFER: |
| 665 state_ = DEFERRING_RESPONSE; | 689 state_ = DEFERRING_RESPONSE; |
| 666 next_index_ = i + 1; | 690 next_index_ = i + 1; |
| 667 return result; | 691 return result; |
| 668 | 692 |
| 669 case NavigationThrottle::BLOCK_REQUEST: | 693 case NavigationThrottle::BLOCK_REQUEST: |
| 694 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE: |
| 670 NOTREACHED(); | 695 NOTREACHED(); |
| 671 } | 696 } |
| 672 } | 697 } |
| 673 next_index_ = 0; | 698 next_index_ = 0; |
| 674 state_ = WILL_PROCESS_RESPONSE; | 699 state_ = WILL_PROCESS_RESPONSE; |
| 675 return NavigationThrottle::PROCEED; | 700 return NavigationThrottle::PROCEED; |
| 676 } | 701 } |
| 677 | 702 |
| 678 bool NavigationHandleImpl::MaybeTransferAndProceed() { | 703 bool NavigationHandleImpl::MaybeTransferAndProceed() { |
| 679 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); | 704 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 content::AncestorThrottle::MaybeCreateThrottleFor(this); | 831 content::AncestorThrottle::MaybeCreateThrottleFor(this); |
| 807 if (ancestor_throttle) | 832 if (ancestor_throttle) |
| 808 throttles_.push_back(std::move(ancestor_throttle)); | 833 throttles_.push_back(std::move(ancestor_throttle)); |
| 809 | 834 |
| 810 throttles_.insert(throttles_.begin(), | 835 throttles_.insert(throttles_.begin(), |
| 811 std::make_move_iterator(throttles_to_register.begin()), | 836 std::make_move_iterator(throttles_to_register.begin()), |
| 812 std::make_move_iterator(throttles_to_register.end())); | 837 std::make_move_iterator(throttles_to_register.end())); |
| 813 } | 838 } |
| 814 | 839 |
| 815 } // namespace content | 840 } // namespace content |
| OLD | NEW |