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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // static | 59 // static |
60 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 60 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
61 const GURL& url, | 61 const GURL& url, |
62 const std::vector<GURL>& redirect_chain, | 62 const std::vector<GURL>& redirect_chain, |
63 FrameTreeNode* frame_tree_node, | 63 FrameTreeNode* frame_tree_node, |
64 bool is_renderer_initiated, | 64 bool is_renderer_initiated, |
65 bool is_same_page, | 65 bool is_same_page, |
66 const base::TimeTicks& navigation_start, | 66 const base::TimeTicks& navigation_start, |
67 int pending_nav_entry_id, | 67 int pending_nav_entry_id, |
68 bool started_from_context_menu) { | 68 bool started_from_context_menu, |
| 69 bool should_bypass_main_world_csp) { |
69 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( | 70 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
70 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, | 71 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, |
71 navigation_start, pending_nav_entry_id, | 72 navigation_start, pending_nav_entry_id, started_from_context_menu, |
72 started_from_context_menu)); | 73 should_bypass_main_world_csp)); |
73 } | 74 } |
74 | 75 |
75 NavigationHandleImpl::NavigationHandleImpl( | 76 NavigationHandleImpl::NavigationHandleImpl( |
76 const GURL& url, | 77 const GURL& url, |
77 const std::vector<GURL>& redirect_chain, | 78 const std::vector<GURL>& redirect_chain, |
78 FrameTreeNode* frame_tree_node, | 79 FrameTreeNode* frame_tree_node, |
79 bool is_renderer_initiated, | 80 bool is_renderer_initiated, |
80 bool is_same_page, | 81 bool is_same_page, |
81 const base::TimeTicks& navigation_start, | 82 const base::TimeTicks& navigation_start, |
82 int pending_nav_entry_id, | 83 int pending_nav_entry_id, |
83 bool started_from_context_menu) | 84 bool started_from_context_menu, |
| 85 bool should_bypass_main_world_csp) |
84 : url_(url), | 86 : url_(url), |
85 has_user_gesture_(false), | 87 has_user_gesture_(false), |
86 transition_(ui::PAGE_TRANSITION_LINK), | 88 transition_(ui::PAGE_TRANSITION_LINK), |
87 is_external_protocol_(false), | 89 is_external_protocol_(false), |
88 net_error_code_(net::OK), | 90 net_error_code_(net::OK), |
89 render_frame_host_(nullptr), | 91 render_frame_host_(nullptr), |
90 is_renderer_initiated_(is_renderer_initiated), | 92 is_renderer_initiated_(is_renderer_initiated), |
91 is_same_page_(is_same_page), | 93 is_same_page_(is_same_page), |
92 was_redirected_(false), | 94 was_redirected_(false), |
93 did_replace_entry_(false), | 95 did_replace_entry_(false), |
94 should_update_history_(false), | 96 should_update_history_(false), |
95 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), | 97 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), |
96 original_url_(url), | 98 original_url_(url), |
97 state_(INITIAL), | 99 state_(INITIAL), |
98 is_transferring_(false), | 100 is_transferring_(false), |
99 frame_tree_node_(frame_tree_node), | 101 frame_tree_node_(frame_tree_node), |
100 next_index_(0), | 102 next_index_(0), |
101 navigation_start_(navigation_start), | 103 navigation_start_(navigation_start), |
102 pending_nav_entry_id_(pending_nav_entry_id), | 104 pending_nav_entry_id_(pending_nav_entry_id), |
103 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), | 105 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
104 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), | 106 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), |
105 should_replace_current_entry_(false), | 107 should_replace_current_entry_(false), |
106 redirect_chain_(redirect_chain), | 108 redirect_chain_(redirect_chain), |
107 is_download_(false), | 109 is_download_(false), |
108 is_stream_(false), | 110 is_stream_(false), |
109 started_from_context_menu_(started_from_context_menu), | 111 started_from_context_menu_(started_from_context_menu), |
110 reload_type_(ReloadType::NONE), | 112 reload_type_(ReloadType::NONE), |
111 restore_type_(RestoreType::NONE), | 113 restore_type_(RestoreType::NONE), |
112 navigation_type_(NAVIGATION_TYPE_UNKNOWN), | 114 navigation_type_(NAVIGATION_TYPE_UNKNOWN), |
| 115 should_bypass_main_world_csp_(should_bypass_main_world_csp), |
113 weak_factory_(this) { | 116 weak_factory_(this) { |
114 DCHECK(!navigation_start.is_null()); | 117 DCHECK(!navigation_start.is_null()); |
115 if (redirect_chain_.empty()) | 118 if (redirect_chain_.empty()) |
116 redirect_chain_.push_back(url); | 119 redirect_chain_.push_back(url); |
117 | 120 |
118 starting_site_instance_ = | 121 starting_site_instance_ = |
119 frame_tree_node_->current_frame_host()->GetSiteInstance(); | 122 frame_tree_node_->current_frame_host()->GetSiteInstance(); |
120 | 123 |
121 if (pending_nav_entry_id_) { | 124 if (pending_nav_entry_id_) { |
122 NavigationControllerImpl* nav_controller = | 125 NavigationControllerImpl* nav_controller = |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 678 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
676 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 679 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
677 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 680 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
678 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 681 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
679 NavigationThrottle::ThrottleCheckResult result = | 682 NavigationThrottle::ThrottleCheckResult result = |
680 throttles_[i]->WillStartRequest(); | 683 throttles_[i]->WillStartRequest(); |
681 switch (result) { | 684 switch (result) { |
682 case NavigationThrottle::PROCEED: | 685 case NavigationThrottle::PROCEED: |
683 continue; | 686 continue; |
684 | 687 |
| 688 case NavigationThrottle::BLOCK_REQUEST: |
685 case NavigationThrottle::CANCEL: | 689 case NavigationThrottle::CANCEL: |
686 case NavigationThrottle::CANCEL_AND_IGNORE: | 690 case NavigationThrottle::CANCEL_AND_IGNORE: |
687 case NavigationThrottle::BLOCK_REQUEST: | |
688 state_ = CANCELING; | 691 state_ = CANCELING; |
689 return result; | 692 return result; |
690 | 693 |
691 case NavigationThrottle::DEFER: | 694 case NavigationThrottle::DEFER: |
692 state_ = DEFERRING_START; | 695 state_ = DEFERRING_START; |
693 next_index_ = i + 1; | 696 next_index_ = i + 1; |
694 return result; | 697 return result; |
695 | 698 |
696 case NavigationThrottle::BLOCK_RESPONSE: | 699 case NavigationThrottle::BLOCK_RESPONSE: |
697 NOTREACHED(); | 700 NOTREACHED(); |
698 } | 701 } |
699 } | 702 } |
700 next_index_ = 0; | 703 next_index_ = 0; |
701 state_ = WILL_SEND_REQUEST; | 704 state_ = WILL_SEND_REQUEST; |
702 return NavigationThrottle::PROCEED; | 705 return NavigationThrottle::PROCEED; |
703 } | 706 } |
704 | 707 |
705 NavigationThrottle::ThrottleCheckResult | 708 NavigationThrottle::ThrottleCheckResult |
706 NavigationHandleImpl::CheckWillRedirectRequest() { | 709 NavigationHandleImpl::CheckWillRedirectRequest() { |
707 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 710 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
708 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); | 711 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); |
709 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); | 712 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); |
710 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 713 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
711 NavigationThrottle::ThrottleCheckResult result = | 714 NavigationThrottle::ThrottleCheckResult result = |
712 throttles_[i]->WillRedirectRequest(); | 715 throttles_[i]->WillRedirectRequest(); |
713 switch (result) { | 716 switch (result) { |
714 case NavigationThrottle::PROCEED: | 717 case NavigationThrottle::PROCEED: |
715 continue; | 718 continue; |
716 | 719 |
| 720 case NavigationThrottle::BLOCK_REQUEST: |
717 case NavigationThrottle::CANCEL: | 721 case NavigationThrottle::CANCEL: |
718 case NavigationThrottle::CANCEL_AND_IGNORE: | 722 case NavigationThrottle::CANCEL_AND_IGNORE: |
719 state_ = CANCELING; | 723 state_ = CANCELING; |
720 return result; | 724 return result; |
721 | 725 |
722 case NavigationThrottle::DEFER: | 726 case NavigationThrottle::DEFER: |
723 state_ = DEFERRING_REDIRECT; | 727 state_ = DEFERRING_REDIRECT; |
724 next_index_ = i + 1; | 728 next_index_ = i + 1; |
725 return result; | 729 return result; |
726 | 730 |
727 case NavigationThrottle::BLOCK_REQUEST: | |
728 case NavigationThrottle::BLOCK_RESPONSE: | 731 case NavigationThrottle::BLOCK_RESPONSE: |
729 NOTREACHED(); | 732 NOTREACHED(); |
730 } | 733 } |
731 } | 734 } |
732 next_index_ = 0; | 735 next_index_ = 0; |
733 state_ = WILL_REDIRECT_REQUEST; | 736 state_ = WILL_REDIRECT_REQUEST; |
734 | 737 |
735 // Notify the delegate that a redirect was encountered and will be followed. | 738 // Notify the delegate that a redirect was encountered and will be followed. |
736 if (GetDelegate()) | 739 if (GetDelegate()) |
737 GetDelegate()->DidRedirectNavigation(this); | 740 GetDelegate()->DidRedirectNavigation(this); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 if (node->current_url().EqualsIgnoringRef(url_)) { | 939 if (node->current_url().EqualsIgnoringRef(url_)) { |
937 if (found_self_reference) | 940 if (found_self_reference) |
938 return true; | 941 return true; |
939 found_self_reference = true; | 942 found_self_reference = true; |
940 } | 943 } |
941 } | 944 } |
942 return false; | 945 return false; |
943 } | 946 } |
944 | 947 |
945 } // namespace content | 948 } // namespace content |
OLD | NEW |