OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" | 5 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 url, config.activation_conditions); | 119 url, config.activation_conditions); |
120 }); | 120 }); |
121 | 121 |
122 if (highest_priority_activated_config == | 122 if (highest_priority_activated_config == |
123 config_list->configs_by_decreasing_priority().end()) { | 123 config_list->configs_by_decreasing_priority().end()) { |
124 activation_decision_ = ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET; | 124 activation_decision_ = ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET; |
125 activation_options_ = Configuration::ActivationOptions(); | 125 activation_options_ = Configuration::ActivationOptions(); |
126 return; | 126 return; |
127 } | 127 } |
128 | 128 |
129 if (client_->ShouldSuppressActivation(navigation_handle)) { | |
130 activation_decision_ = ActivationDecision::URL_WHITELISTED; | |
131 activation_options_ = Configuration::ActivationOptions(); | |
132 return; | |
133 } | |
134 | |
135 activation_options_ = highest_priority_activated_config->activation_options; | 129 activation_options_ = highest_priority_activated_config->activation_options; |
136 activation_decision_ = | 130 activation_decision_ = |
137 activation_options_.activation_level == ActivationLevel::DISABLED | 131 activation_options_.activation_level == ActivationLevel::DISABLED |
138 ? ActivationDecision::ACTIVATION_DISABLED | 132 ? ActivationDecision::ACTIVATION_DISABLED |
139 : ActivationDecision::ACTIVATED; | 133 : ActivationDecision::ACTIVATED; |
140 } | 134 } |
141 | 135 |
142 bool ContentSubresourceFilterDriverFactory:: | 136 bool ContentSubresourceFilterDriverFactory:: |
143 DoesMainFrameURLSatisfyActivationConditions( | 137 DoesMainFrameURLSatisfyActivationConditions( |
144 const GURL& url, | 138 const GURL& url, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 RecordRedirectChainMatchPattern(); | 189 RecordRedirectChainMatchPattern(); |
196 | 190 |
197 if (activation_options_.should_whitelist_site_on_reload && | 191 if (activation_options_.should_whitelist_site_on_reload && |
198 NavigationIsPageReload(url, referrer, transition)) { | 192 NavigationIsPageReload(url, referrer, transition)) { |
199 // Whitelist this host for the current as well as subsequent navigations. | 193 // Whitelist this host for the current as well as subsequent navigations. |
200 client_->WhitelistInCurrentWebContents(url); | 194 client_->WhitelistInCurrentWebContents(url); |
201 } | 195 } |
202 | 196 |
203 ComputeActivationForMainFrameNavigation(navigation_handle); | 197 ComputeActivationForMainFrameNavigation(navigation_handle); |
204 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); | 198 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); |
| 199 |
| 200 // Check for whitelisted status last, so that the client gets an accurate |
| 201 // indication of whether there would be activation otherwise. |
| 202 bool whitelisted = client_->OnPageActivationComputed( |
| 203 navigation_handle, activation_decision_ == ActivationDecision::ACTIVATED); |
| 204 if (whitelisted) { |
| 205 activation_decision_ = ActivationDecision::URL_WHITELISTED; |
| 206 activation_options_ = Configuration::ActivationOptions(); |
| 207 } |
| 208 |
205 if (activation_decision_ != ActivationDecision::ACTIVATED) { | 209 if (activation_decision_ != ActivationDecision::ACTIVATED) { |
206 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); | 210 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); |
207 return; | 211 return; |
208 } | 212 } |
209 | 213 |
210 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); | 214 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); |
211 ActivationState state = ActivationState(activation_options_.activation_level); | 215 ActivationState state = ActivationState(activation_options_.activation_level); |
212 state.measure_performance = ShouldMeasurePerformanceForPageLoad( | 216 state.measure_performance = ShouldMeasurePerformanceForPageLoad( |
213 activation_options_.performance_measurement_rate); | 217 activation_options_.performance_measurement_rate); |
214 // TODO(csharrison): Set state.enable_logging based on metadata returns from | 218 // TODO(csharrison): Set state.enable_logging based on metadata returns from |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, | 332 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, |
329 chain_size); | 333 chain_size); |
330 break; | 334 break; |
331 default: | 335 default: |
332 NOTREACHED(); | 336 NOTREACHED(); |
333 break; | 337 break; |
334 } | 338 } |
335 } | 339 } |
336 | 340 |
337 } // namespace subresource_filter | 341 } // namespace subresource_filter |
OLD | NEW |