Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc

Issue 2874663002: [subresource_filter] s/ShouldSuppressActivation/OnPageActivationComputed (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
engedy 2017/05/11 09:13:14 follow up nit: Any reason to not do this block of
Charlie Harrison 2017/05/11 12:07:15 I chose to do this here so that we can continue to
201 // indication of whether there would be activation otherwise.
202 bool whitelisted = client_->OnPageActivationComputed(
203 navigation_handle,
204 activation_options_.activation_level == ActivationLevel::ENABLED);
205
206 // Only reset the activation decision reason if we would have activated.
207 if (whitelisted && activation_decision_ == ActivationDecision::ACTIVATED) {
208 activation_decision_ = ActivationDecision::URL_WHITELISTED;
209 activation_options_ = Configuration::ActivationOptions();
210 }
211
205 if (activation_decision_ != ActivationDecision::ACTIVATED) { 212 if (activation_decision_ != ActivationDecision::ACTIVATED) {
206 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); 213 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED);
207 return; 214 return;
208 } 215 }
209 216
210 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); 217 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED);
211 ActivationState state = ActivationState(activation_options_.activation_level); 218 ActivationState state = ActivationState(activation_options_.activation_level);
212 state.measure_performance = ShouldMeasurePerformanceForPageLoad( 219 state.measure_performance = ShouldMeasurePerformanceForPageLoad(
213 activation_options_.performance_measurement_rate); 220 activation_options_.performance_measurement_rate);
214 // TODO(csharrison): Set state.enable_logging based on metadata returns from 221 // TODO(csharrison): Set state.enable_logging based on metadata returns from
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, 335 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern,
329 chain_size); 336 chain_size);
330 break; 337 break;
331 default: 338 default:
332 NOTREACHED(); 339 NOTREACHED();
333 break; 340 break;
334 } 341 }
335 } 342 }
336 343
337 } // namespace subresource_filter 344 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698