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

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

Issue 2837163004: Make call sites of subresource_filter::GetActiveConfigurations const-correct. (Closed)
Patch Set: Addressed comments from pkalinnikov@. 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/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 AddActivationListMatch( 108 AddActivationListMatch(
109 url, GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata)); 109 url, GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata));
110 } 110 }
111 111
112 ContentSubresourceFilterDriverFactory::ActivationDecision 112 ContentSubresourceFilterDriverFactory::ActivationDecision
113 ContentSubresourceFilterDriverFactory:: 113 ContentSubresourceFilterDriverFactory::
114 ComputeActivationDecisionForMainFrameNavigation( 114 ComputeActivationDecisionForMainFrameNavigation(
115 content::NavigationHandle* navigation_handle) const { 115 content::NavigationHandle* navigation_handle) const {
116 const GURL& url(navigation_handle->GetURL()); 116 const GURL& url(navigation_handle->GetURL());
117 117
118 auto configurations = GetActiveConfigurations(); 118 const auto configurations = GetActiveConfigurations();
119 if (configurations->the_one_and_only().activation_level == 119 if (configurations->the_one_and_only().activation_level ==
120 ActivationLevel::DISABLED) 120 ActivationLevel::DISABLED)
121 return ActivationDecision::ACTIVATION_DISABLED; 121 return ActivationDecision::ACTIVATION_DISABLED;
122 122
123 if (configurations->the_one_and_only().activation_scope == 123 if (configurations->the_one_and_only().activation_scope ==
124 ActivationScope::NO_SITES) 124 ActivationScope::NO_SITES)
125 return ActivationDecision::ACTIVATION_DISABLED; 125 return ActivationDecision::ACTIVATION_DISABLED;
126 126
127 if (!url.SchemeIsHTTPOrHTTPS()) 127 if (!url.SchemeIsHTTPOrHTTPS())
128 return ActivationDecision::UNSUPPORTED_SCHEME; 128 return ActivationDecision::UNSUPPORTED_SCHEME;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 navigation_handle->GetNetErrorCode() != net::OK) { 182 navigation_handle->GetNetErrorCode() != net::OK) {
183 return; 183 return;
184 } 184 }
185 185
186 const GURL& url = navigation_handle->GetURL(); 186 const GURL& url = navigation_handle->GetURL();
187 const content::Referrer& referrer = navigation_handle->GetReferrer(); 187 const content::Referrer& referrer = navigation_handle->GetReferrer();
188 ui::PageTransition transition = navigation_handle->GetPageTransition(); 188 ui::PageTransition transition = navigation_handle->GetPageTransition();
189 189
190 RecordRedirectChainMatchPattern(); 190 RecordRedirectChainMatchPattern();
191 191
192 auto configurations = GetActiveConfigurations(); 192 const auto configurations = GetActiveConfigurations();
193 if (configurations->the_one_and_only().should_whitelist_site_on_reload && 193 if (configurations->the_one_and_only().should_whitelist_site_on_reload &&
194 NavigationIsPageReload(url, referrer, transition)) { 194 NavigationIsPageReload(url, referrer, transition)) {
195 // Whitelist this host for the current as well as subsequent navigations. 195 // Whitelist this host for the current as well as subsequent navigations.
196 client_->WhitelistInCurrentWebContents(url); 196 client_->WhitelistInCurrentWebContents(url);
197 } 197 }
198 198
199 activation_decision_ = 199 activation_decision_ =
200 ComputeActivationDecisionForMainFrameNavigation(navigation_handle); 200 ComputeActivationDecisionForMainFrameNavigation(navigation_handle);
201 DCHECK(activation_decision_ != ActivationDecision::UNKNOWN); 201 DCHECK(activation_decision_ != ActivationDecision::UNKNOWN);
202 if (activation_decision_ != ActivationDecision::ACTIVATED) { 202 if (activation_decision_ != ActivationDecision::ACTIVATED) {
203 ResetActivationState(); 203 ResetActivationState();
204 return; 204 return;
205 } 205 }
206 206
207 activation_level_ = configurations->the_one_and_only().activation_level; 207 activation_level_ = configurations->the_one_and_only().activation_level;
208 measure_performance_ = 208 measure_performance_ =
209 activation_level_ != ActivationLevel::DISABLED && 209 activation_level_ != ActivationLevel::DISABLED &&
210 ShouldMeasurePerformanceForPageLoad( 210 ShouldMeasurePerformanceForPageLoad(
211 configurations->the_one_and_only().performance_measurement_rate); 211 configurations->the_one_and_only().performance_measurement_rate);
212 ActivationState state = ActivationState(activation_level_); 212 ActivationState state = ActivationState(activation_level_);
213 state.measure_performance = measure_performance_; 213 state.measure_performance = measure_performance_;
214 throttle_manager_->NotifyPageActivationComputed(navigation_handle, state); 214 throttle_manager_->NotifyPageActivationComputed(navigation_handle, state);
215 } 215 }
216 216
217 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() { 217 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() {
218 auto configurations = GetActiveConfigurations(); 218 const auto configurations = GetActiveConfigurations();
219 if (configurations->the_one_and_only().should_suppress_notifications) 219 if (configurations->the_one_and_only().should_suppress_notifications)
220 return; 220 return;
221 221
222 client_->ToggleNotificationVisibility(activation_level_ == 222 client_->ToggleNotificationVisibility(activation_level_ ==
223 ActivationLevel::ENABLED); 223 ActivationLevel::ENABLED);
224 } 224 }
225 225
226 bool ContentSubresourceFilterDriverFactory::ShouldSuppressActivation( 226 bool ContentSubresourceFilterDriverFactory::ShouldSuppressActivation(
227 content::NavigationHandle* navigation_handle) { 227 content::NavigationHandle* navigation_handle) {
228 return client_->ShouldSuppressActivation(navigation_handle); 228 return client_->ShouldSuppressActivation(navigation_handle);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, 328 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern,
329 chain_size); 329 chain_size);
330 break; 330 break;
331 default: 331 default:
332 NOTREACHED(); 332 NOTREACHED();
333 break; 333 break;
334 } 334 }
335 } 335 }
336 336
337 } // namespace subresource_filter 337 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698