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 // TODO(csharrison): The throttle manager also performs this check. Remove | |
130 // this one when the activation decision is sent directly to the throttle | |
131 // manager. | |
132 if (client_->ShouldSuppressActivation(navigation_handle)) { | 129 if (client_->ShouldSuppressActivation(navigation_handle)) { |
133 activation_decision_ = ActivationDecision::URL_WHITELISTED; | 130 activation_decision_ = ActivationDecision::URL_WHITELISTED; |
134 activation_options_ = Configuration::ActivationOptions(); | 131 activation_options_ = Configuration::ActivationOptions(); |
135 return; | 132 return; |
136 } | 133 } |
137 | 134 |
138 activation_options_ = highest_priority_activated_config->activation_options; | 135 activation_options_ = highest_priority_activated_config->activation_options; |
139 activation_decision_ = | 136 activation_decision_ = |
140 activation_options_.activation_level == ActivationLevel::DISABLED | 137 activation_options_.activation_level == ActivationLevel::DISABLED |
141 ? ActivationDecision::ACTIVATION_DISABLED | 138 ? ActivationDecision::ACTIVATION_DISABLED |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 throttle_manager_->NotifyPageActivationComputed(navigation_handle, state); | 217 throttle_manager_->NotifyPageActivationComputed(navigation_handle, state); |
221 } | 218 } |
222 | 219 |
223 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() { | 220 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() { |
224 if (activation_options_.should_suppress_notifications) | 221 if (activation_options_.should_suppress_notifications) |
225 return; | 222 return; |
226 client_->ToggleNotificationVisibility(activation_options_.activation_level == | 223 client_->ToggleNotificationVisibility(activation_options_.activation_level == |
227 ActivationLevel::ENABLED); | 224 ActivationLevel::ENABLED); |
228 } | 225 } |
229 | 226 |
230 bool ContentSubresourceFilterDriverFactory::ShouldSuppressActivation( | |
231 content::NavigationHandle* navigation_handle) { | |
232 return client_->ShouldSuppressActivation(navigation_handle); | |
233 } | |
234 | |
235 void ContentSubresourceFilterDriverFactory::DidStartNavigation( | 227 void ContentSubresourceFilterDriverFactory::DidStartNavigation( |
236 content::NavigationHandle* navigation_handle) { | 228 content::NavigationHandle* navigation_handle) { |
237 if (navigation_handle->IsInMainFrame() && | 229 if (navigation_handle->IsInMainFrame() && |
238 !navigation_handle->IsSameDocument()) { | 230 !navigation_handle->IsSameDocument()) { |
239 activation_decision_ = ActivationDecision::UNKNOWN; | 231 activation_decision_ = ActivationDecision::UNKNOWN; |
240 activation_list_matches_.clear(); | 232 activation_list_matches_.clear(); |
241 navigation_chain_ = {navigation_handle->GetURL()}; | 233 navigation_chain_ = {navigation_handle->GetURL()}; |
242 client_->ToggleNotificationVisibility(false); | 234 client_->ToggleNotificationVisibility(false); |
243 } | 235 } |
244 } | 236 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, | 328 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, |
337 chain_size); | 329 chain_size); |
338 break; | 330 break; |
339 default: | 331 default: |
340 NOTREACHED(); | 332 NOTREACHED(); |
341 break; | 333 break; |
342 } | 334 } |
343 } | 335 } |
344 | 336 |
345 } // namespace subresource_filter | 337 } // namespace subresource_filter |
OLD | NEW |