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" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "base/trace_event/trace_event.h" | |
13 #include "base/trace_event/trace_event_argument.h" | |
12 #include "components/subresource_filter/content/browser/content_activation_list_ utils.h" | 14 #include "components/subresource_filter/content/browser/content_activation_list_ utils.h" |
13 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h" | 15 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h" |
14 #include "components/subresource_filter/core/browser/subresource_filter_features .h" | 16 #include "components/subresource_filter/core/browser/subresource_filter_features .h" |
15 #include "components/subresource_filter/core/common/activation_list.h" | 17 #include "components/subresource_filter/core/common/activation_list.h" |
16 #include "components/subresource_filter/core/common/activation_state.h" | 18 #include "components/subresource_filter/core/common/activation_state.h" |
17 #include "content/public/browser/navigation_handle.h" | 19 #include "content/public/browser/navigation_handle.h" |
18 #include "content/public/browser/navigation_throttle.h" | 20 #include "content/public/browser/navigation_throttle.h" |
19 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
20 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
21 #include "url/gurl.h" | 23 #include "url/gurl.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 114 |
113 const auto config_list = GetEnabledConfigurations(); | 115 const auto config_list = GetEnabledConfigurations(); |
114 const auto highest_priority_activated_config = | 116 const auto highest_priority_activated_config = |
115 std::find_if(config_list->configs_by_decreasing_priority().begin(), | 117 std::find_if(config_list->configs_by_decreasing_priority().begin(), |
116 config_list->configs_by_decreasing_priority().end(), | 118 config_list->configs_by_decreasing_priority().end(), |
117 [&url, this](const Configuration& config) { | 119 [&url, this](const Configuration& config) { |
118 return DoesMainFrameURLSatisfyActivationConditions( | 120 return DoesMainFrameURLSatisfyActivationConditions( |
119 url, config.activation_conditions); | 121 url, config.activation_conditions); |
120 }); | 122 }); |
121 | 123 |
122 if (highest_priority_activated_config == | 124 bool matched_config = highest_priority_activated_config != |
engedy
2017/05/15 12:10:38
nit: s//has_activated_config/ for consistency with
Charlie Harrison
2017/05/15 15:14:22
Done.
| |
123 config_list->configs_by_decreasing_priority().end()) { | 125 config_list->configs_by_decreasing_priority().end(); |
126 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("loading"), | |
engedy
2017/05/15 12:10:37
nit: The TRACE_EVENT in document_subresource_filte
Charlie Harrison
2017/05/15 15:14:22
I think "loading" is the category we should be usi
| |
127 "ContentSubresourceFilterDriverFactory::" | |
128 "ComputeActivationForMainFrameNavigation", | |
129 "highest_priority_activated_config", | |
130 matched_config | |
131 ? highest_priority_activated_config->GetTracedValue() | |
132 : base::MakeUnique<base::trace_event::TracedValue>()); | |
133 if (!matched_config) { | |
124 activation_decision_ = ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET; | 134 activation_decision_ = ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET; |
125 activation_options_ = Configuration::ActivationOptions(); | 135 activation_options_ = Configuration::ActivationOptions(); |
126 return; | 136 return; |
127 } | 137 } |
128 | 138 |
129 activation_options_ = highest_priority_activated_config->activation_options; | 139 activation_options_ = highest_priority_activated_config->activation_options; |
130 activation_decision_ = | 140 activation_decision_ = |
131 activation_options_.activation_level == ActivationLevel::DISABLED | 141 activation_options_.activation_level == ActivationLevel::DISABLED |
132 ? ActivationDecision::ACTIVATION_DISABLED | 142 ? ActivationDecision::ACTIVATION_DISABLED |
133 : ActivationDecision::ACTIVATED; | 143 : ActivationDecision::ACTIVATED; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); | 208 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); |
199 | 209 |
200 // Check for whitelisted status last, so that the client gets an accurate | 210 // Check for whitelisted status last, so that the client gets an accurate |
201 // indication of whether there would be activation otherwise. | 211 // indication of whether there would be activation otherwise. |
202 bool whitelisted = client_->OnPageActivationComputed( | 212 bool whitelisted = client_->OnPageActivationComputed( |
203 navigation_handle, | 213 navigation_handle, |
204 activation_options_.activation_level == ActivationLevel::ENABLED); | 214 activation_options_.activation_level == ActivationLevel::ENABLED); |
205 | 215 |
206 // Only reset the activation decision reason if we would have activated. | 216 // Only reset the activation decision reason if we would have activated. |
207 if (whitelisted && activation_decision_ == ActivationDecision::ACTIVATED) { | 217 if (whitelisted && activation_decision_ == ActivationDecision::ACTIVATED) { |
218 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"), "ActivationWhitelisted"); | |
208 activation_decision_ = ActivationDecision::URL_WHITELISTED; | 219 activation_decision_ = ActivationDecision::URL_WHITELISTED; |
209 activation_options_ = Configuration::ActivationOptions(); | 220 activation_options_ = Configuration::ActivationOptions(); |
210 } | 221 } |
211 | 222 |
212 if (activation_decision_ != ActivationDecision::ACTIVATED) { | 223 if (activation_decision_ != ActivationDecision::ACTIVATED) { |
213 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); | 224 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); |
214 return; | 225 return; |
215 } | 226 } |
216 | 227 |
217 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); | 228 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, | 346 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, |
336 chain_size); | 347 chain_size); |
337 break; | 348 break; |
338 default: | 349 default: |
339 NOTREACHED(); | 350 NOTREACHED(); |
340 break; | 351 break; |
341 } | 352 } |
342 } | 353 } |
343 | 354 |
344 } // namespace subresource_filter | 355 } // namespace subresource_filter |
OLD | NEW |