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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 } | 1084 } |
1085 | 1085 |
1086 if (!callback.is_null()) | 1086 if (!callback.is_null()) |
1087 callback.Run(result); | 1087 callback.Run(result); |
1088 | 1088 |
1089 // No code after running the callback, as it might have resulted in our | 1089 // No code after running the callback, as it might have resulted in our |
1090 // destruction. | 1090 // destruction. |
1091 } | 1091 } |
1092 | 1092 |
1093 void NavigationHandleImpl::RegisterNavigationThrottles() { | 1093 void NavigationHandleImpl::RegisterNavigationThrottles() { |
1094 // Register the navigation throttles. The vector returned by | 1094 // Note: |throttle_| might not be empty. Some NavigationThrottle might have |
clamy
2017/07/11 12:32:37
s/NavigationThrottle/NavigationThrottles
arthursonzogni
2017/07/11 14:37:23
Done.
| |
1095 // CreateThrottlesForNavigation is not assigned to throttles_ directly because | 1095 // been registered with RegisterThrottleForTesting. These must reside at the |
clamy
2017/07/11 12:32:37
s/These must reside ... elies on this./
TestNaviga
arthursonzogni
2017/07/11 14:37:23
Done.
| |
1096 // it would overwrite any throttles previously added with | 1096 // end of |throttles_|. TestNavigationManagerThrottle relies on this. |
1097 // RegisterThrottleForTesting. | 1097 std::vector<std::unique_ptr<NavigationThrottle>> testing_throttles = |
1098 // TODO(carlosk, arthursonzogni): should simplify this to either use | 1098 std::move(throttles_); |
1099 // |throttles_| directly (except for the case described above) or | 1099 |
1100 // |throttles_to_register| for registering all throttles. | 1100 throttles_ = GetDelegate()->CreateThrottlesForNavigation(this); |
1101 std::vector<std::unique_ptr<NavigationThrottle>> throttles_to_register = | |
1102 GetDelegate()->CreateThrottlesForNavigation(this); | |
1103 | 1101 |
1104 // Check for renderer-inititated main frame navigations to data URLs. This is | 1102 // Check for renderer-inititated main frame navigations to data URLs. This is |
1105 // done first as it may block the main frame navigation altogether. | 1103 // done first as it may block the main frame navigation altogether. |
1106 std::unique_ptr<NavigationThrottle> data_url_navigation_throttle = | 1104 AddThrottle(DataUrlNavigationThrottle::CreateThrottleForNavigation(this)); |
1107 DataUrlNavigationThrottle::CreateThrottleForNavigation(this); | |
1108 if (data_url_navigation_throttle) | |
1109 throttles_to_register.push_back(std::move(data_url_navigation_throttle)); | |
1110 | 1105 |
1111 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = | 1106 AddThrottle(AncestorThrottle::MaybeCreateThrottleFor(this)); |
1112 content::AncestorThrottle::MaybeCreateThrottleFor(this); | 1107 AddThrottle(FormSubmissionThrottle::MaybeCreateThrottleFor(this)); |
1113 if (ancestor_throttle) | |
1114 throttles_.push_back(std::move(ancestor_throttle)); | |
1115 | |
1116 std::unique_ptr<content::NavigationThrottle> form_submission_throttle = | |
1117 content::FormSubmissionThrottle::MaybeCreateThrottleFor(this); | |
1118 if (form_submission_throttle) | |
1119 throttles_.push_back(std::move(form_submission_throttle)); | |
1120 | 1108 |
1121 // Check for mixed content. This is done after the AncestorThrottle and the | 1109 // Check for mixed content. This is done after the AncestorThrottle and the |
1122 // FormSubmissionThrottle so that when folks block mixed content with a CSP | 1110 // FormSubmissionThrottle so that when folks block mixed content with a CSP |
1123 // policy, they don't get a warning. They'll still get a warning in the | 1111 // policy, they don't get a warning. They'll still get a warning in the |
1124 // console about CSP blocking the load. | 1112 // console about CSP blocking the load. |
1125 std::unique_ptr<NavigationThrottle> mixed_content_throttle = | 1113 AddThrottle( |
1126 MixedContentNavigationThrottle::CreateThrottleForNavigation(this); | 1114 MixedContentNavigationThrottle::CreateThrottleForNavigation(this)); |
1127 if (mixed_content_throttle) | |
1128 throttles_to_register.push_back(std::move(mixed_content_throttle)); | |
1129 | 1115 |
1130 std::unique_ptr<NavigationThrottle> devtools_throttle = | 1116 AddThrottle(RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this)); |
1131 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); | |
1132 if (devtools_throttle) | |
1133 throttles_to_register.push_back(std::move(devtools_throttle)); | |
1134 | 1117 |
1135 throttles_.insert(throttles_.begin(), | 1118 throttles_.insert(throttles_.end(), |
clamy
2017/07/11 12:32:37
nit: maybe add a comment
// Insert all testing Nav
arthursonzogni
2017/07/11 14:37:23
Done.
| |
1136 std::make_move_iterator(throttles_to_register.begin()), | 1119 std::make_move_iterator(testing_throttles.begin()), |
1137 std::make_move_iterator(throttles_to_register.end())); | 1120 std::make_move_iterator(testing_throttles.end())); |
1121 } | |
1122 | |
1123 void NavigationHandleImpl::AddThrottle( | |
1124 std::unique_ptr<NavigationThrottle> throttle) { | |
1125 if (throttle) | |
1126 throttles_.push_back(std::move(throttle)); | |
1138 } | 1127 } |
1139 | 1128 |
1140 bool NavigationHandleImpl::IsSelfReferentialURL() { | 1129 bool NavigationHandleImpl::IsSelfReferentialURL() { |
1141 // about: URLs should be exempted since they are reserved for other purposes | 1130 // about: URLs should be exempted since they are reserved for other purposes |
1142 // and cannot be the source of infinite recursion. See | 1131 // and cannot be the source of infinite recursion. See |
1143 // https://crbug.com/341858 . | 1132 // https://crbug.com/341858 . |
1144 if (url_.SchemeIs("about")) | 1133 if (url_.SchemeIs("about")) |
1145 return false; | 1134 return false; |
1146 | 1135 |
1147 // Browser-triggered navigations should be exempted. | 1136 // Browser-triggered navigations should be exempted. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 // Stop expecting a navigation to the current site URL in the current expected | 1173 // Stop expecting a navigation to the current site URL in the current expected |
1185 // process. | 1174 // process. |
1186 SetExpectedProcess(nullptr); | 1175 SetExpectedProcess(nullptr); |
1187 | 1176 |
1188 // Update the site URL and the expected process. | 1177 // Update the site URL and the expected process. |
1189 site_url_ = new_site_url; | 1178 site_url_ = new_site_url; |
1190 SetExpectedProcess(post_redirect_process); | 1179 SetExpectedProcess(post_redirect_process); |
1191 } | 1180 } |
1192 | 1181 |
1193 } // namespace content | 1182 } // namespace content |
OLD | NEW |