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