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 "base/debug/dump_without_crashing.h" | 7 #include "base/debug/dump_without_crashing.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 9 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
11 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 11 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 12 #include "content/browser/frame_host/ancestor_throttle.h" |
12 #include "content/browser/frame_host/debug_urls.h" | 13 #include "content/browser/frame_host/debug_urls.h" |
13 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
14 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
15 #include "content/browser/frame_host/navigator_delegate.h" | 16 #include "content/browser/frame_host/navigator_delegate.h" |
16 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 17 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
17 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 18 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
18 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 19 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
19 #include "content/common/frame_messages.h" | 20 #include "content/common/frame_messages.h" |
20 #include "content/common/resource_request_body_impl.h" | 21 #include "content/common/resource_request_body_impl.h" |
21 #include "content/common/site_isolation_policy.h" | 22 #include "content/common/site_isolation_policy.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) | 281 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) |
281 return; | 282 return; |
282 } | 283 } |
283 | 284 |
284 if (result != NavigationThrottle::DEFER) | 285 if (result != NavigationThrottle::DEFER) |
285 RunCompleteCallback(result); | 286 RunCompleteCallback(result); |
286 } | 287 } |
287 | 288 |
288 void NavigationHandleImpl::CancelDeferredNavigation( | 289 void NavigationHandleImpl::CancelDeferredNavigation( |
289 NavigationThrottle::ThrottleCheckResult result) { | 290 NavigationThrottle::ThrottleCheckResult result) { |
290 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); | 291 DCHECK(state_ == DEFERRING_START || |
| 292 state_ == DEFERRING_REDIRECT || |
| 293 state_ == DEFERRING_RESPONSE); |
291 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 294 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
292 result == NavigationThrottle::CANCEL); | 295 result == NavigationThrottle::CANCEL); |
293 state_ = CANCELING; | 296 state_ = CANCELING; |
294 RunCompleteCallback(result); | 297 RunCompleteCallback(result); |
295 } | 298 } |
296 | 299 |
297 void NavigationHandleImpl::RegisterThrottleForTesting( | 300 void NavigationHandleImpl::RegisterThrottleForTesting( |
298 std::unique_ptr<NavigationThrottle> navigation_throttle) { | 301 std::unique_ptr<NavigationThrottle> navigation_throttle) { |
299 throttles_.push_back(std::move(navigation_throttle)); | 302 throttles_.push_back(std::move(navigation_throttle)); |
300 } | 303 } |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 case NavigationThrottle::CANCEL: | 588 case NavigationThrottle::CANCEL: |
586 case NavigationThrottle::CANCEL_AND_IGNORE: | 589 case NavigationThrottle::CANCEL_AND_IGNORE: |
587 case NavigationThrottle::BLOCK_REQUEST: | 590 case NavigationThrottle::BLOCK_REQUEST: |
588 state_ = CANCELING; | 591 state_ = CANCELING; |
589 return result; | 592 return result; |
590 | 593 |
591 case NavigationThrottle::DEFER: | 594 case NavigationThrottle::DEFER: |
592 state_ = DEFERRING_START; | 595 state_ = DEFERRING_START; |
593 next_index_ = i + 1; | 596 next_index_ = i + 1; |
594 return result; | 597 return result; |
| 598 |
| 599 case NavigationThrottle::BLOCK_RESPONSE: |
| 600 NOTREACHED(); |
595 } | 601 } |
596 } | 602 } |
597 next_index_ = 0; | 603 next_index_ = 0; |
598 state_ = WILL_SEND_REQUEST; | 604 state_ = WILL_SEND_REQUEST; |
599 return NavigationThrottle::PROCEED; | 605 return NavigationThrottle::PROCEED; |
600 } | 606 } |
601 | 607 |
602 NavigationThrottle::ThrottleCheckResult | 608 NavigationThrottle::ThrottleCheckResult |
603 NavigationHandleImpl::CheckWillRedirectRequest() { | 609 NavigationHandleImpl::CheckWillRedirectRequest() { |
604 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 610 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
(...skipping 10 matching lines...) Expand all Loading... |
615 case NavigationThrottle::CANCEL_AND_IGNORE: | 621 case NavigationThrottle::CANCEL_AND_IGNORE: |
616 state_ = CANCELING; | 622 state_ = CANCELING; |
617 return result; | 623 return result; |
618 | 624 |
619 case NavigationThrottle::DEFER: | 625 case NavigationThrottle::DEFER: |
620 state_ = DEFERRING_REDIRECT; | 626 state_ = DEFERRING_REDIRECT; |
621 next_index_ = i + 1; | 627 next_index_ = i + 1; |
622 return result; | 628 return result; |
623 | 629 |
624 case NavigationThrottle::BLOCK_REQUEST: | 630 case NavigationThrottle::BLOCK_REQUEST: |
| 631 case NavigationThrottle::BLOCK_RESPONSE: |
625 NOTREACHED(); | 632 NOTREACHED(); |
626 } | 633 } |
627 } | 634 } |
628 next_index_ = 0; | 635 next_index_ = 0; |
629 state_ = WILL_REDIRECT_REQUEST; | 636 state_ = WILL_REDIRECT_REQUEST; |
630 | 637 |
631 // Notify the delegate that a redirect was encountered and will be followed. | 638 // Notify the delegate that a redirect was encountered and will be followed. |
632 if (GetDelegate()) | 639 if (GetDelegate()) |
633 GetDelegate()->DidRedirectNavigation(this); | 640 GetDelegate()->DidRedirectNavigation(this); |
634 | 641 |
635 return NavigationThrottle::PROCEED; | 642 return NavigationThrottle::PROCEED; |
636 } | 643 } |
637 | 644 |
638 NavigationThrottle::ThrottleCheckResult | 645 NavigationThrottle::ThrottleCheckResult |
639 NavigationHandleImpl::CheckWillProcessResponse() { | 646 NavigationHandleImpl::CheckWillProcessResponse() { |
640 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); | 647 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); |
641 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); | 648 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); |
642 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); | 649 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); |
643 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 650 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
644 NavigationThrottle::ThrottleCheckResult result = | 651 NavigationThrottle::ThrottleCheckResult result = |
645 throttles_[i]->WillProcessResponse(); | 652 throttles_[i]->WillProcessResponse(); |
646 switch (result) { | 653 switch (result) { |
647 case NavigationThrottle::PROCEED: | 654 case NavigationThrottle::PROCEED: |
648 continue; | 655 continue; |
649 | 656 |
650 case NavigationThrottle::CANCEL: | 657 case NavigationThrottle::CANCEL: |
651 case NavigationThrottle::CANCEL_AND_IGNORE: | 658 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 659 case NavigationThrottle::BLOCK_RESPONSE: |
652 state_ = CANCELING; | 660 state_ = CANCELING; |
653 return result; | 661 return result; |
654 | 662 |
655 case NavigationThrottle::DEFER: | 663 case NavigationThrottle::DEFER: |
656 state_ = DEFERRING_RESPONSE; | 664 state_ = DEFERRING_RESPONSE; |
657 next_index_ = i + 1; | 665 next_index_ = i + 1; |
658 return result; | 666 return result; |
659 | 667 |
660 case NavigationThrottle::BLOCK_REQUEST: | 668 case NavigationThrottle::BLOCK_REQUEST: |
661 NOTREACHED(); | 669 NOTREACHED(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 std::unique_ptr<NavigationThrottle> devtools_throttle = | 788 std::unique_ptr<NavigationThrottle> devtools_throttle = |
781 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); | 789 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); |
782 if (devtools_throttle) | 790 if (devtools_throttle) |
783 throttles_to_register.push_back(std::move(devtools_throttle)); | 791 throttles_to_register.push_back(std::move(devtools_throttle)); |
784 | 792 |
785 std::unique_ptr<NavigationThrottle> clear_site_data_throttle = | 793 std::unique_ptr<NavigationThrottle> clear_site_data_throttle = |
786 ClearSiteDataThrottle::CreateThrottleForNavigation(this); | 794 ClearSiteDataThrottle::CreateThrottleForNavigation(this); |
787 if (clear_site_data_throttle) | 795 if (clear_site_data_throttle) |
788 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 796 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
789 | 797 |
| 798 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = |
| 799 content::AncestorThrottle::MaybeCreateThrottleFor(this); |
| 800 if (ancestor_throttle) |
| 801 throttles_.push_back(std::move(ancestor_throttle)); |
| 802 |
790 if (throttles_to_register.size() > 0) { | 803 if (throttles_to_register.size() > 0) { |
791 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 804 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
792 throttles_to_register.end()); | 805 throttles_to_register.end()); |
793 throttles_to_register.weak_clear(); | 806 throttles_to_register.weak_clear(); |
794 } | 807 } |
795 } | 808 } |
796 | 809 |
797 } // namespace content | 810 } // namespace content |
OLD | NEW |