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

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: engedy review 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ActivationLevel::DISABLED) 113 ActivationLevel::DISABLED)
114 return ActivationDecision::ACTIVATION_DISABLED; 114 return ActivationDecision::ACTIVATION_DISABLED;
115 115
116 if (configurations->the_one_and_only().activation_scope == 116 if (configurations->the_one_and_only().activation_scope ==
117 ActivationScope::NO_SITES) 117 ActivationScope::NO_SITES)
118 return ActivationDecision::ACTIVATION_DISABLED; 118 return ActivationDecision::ACTIVATION_DISABLED;
119 119
120 if (!url.SchemeIsHTTPOrHTTPS()) 120 if (!url.SchemeIsHTTPOrHTTPS())
121 return ActivationDecision::UNSUPPORTED_SCHEME; 121 return ActivationDecision::UNSUPPORTED_SCHEME;
122 122
123 if (client_->ShouldSuppressActivation(navigation_handle))
124 return ActivationDecision::URL_WHITELISTED;
125
126 switch (configurations->the_one_and_only().activation_scope) { 123 switch (configurations->the_one_and_only().activation_scope) {
127 case ActivationScope::ALL_SITES: 124 case ActivationScope::ALL_SITES:
128 return ActivationDecision::ACTIVATED; 125 return ActivationDecision::ACTIVATED;
129 case ActivationScope::ACTIVATION_LIST: { 126 case ActivationScope::ACTIVATION_LIST: {
130 // The logic to ensure only http/https URLs are activated lives in 127 // The logic to ensure only http/https URLs are activated lives in
131 // AddActivationListMatch to ensure the activation list only has relevant 128 // AddActivationListMatch to ensure the activation list only has relevant
132 // entries. 129 // entries.
133 DCHECK(url.SchemeIsHTTPOrHTTPS() || 130 DCHECK(url.SchemeIsHTTPOrHTTPS() ||
134 !DidURLMatchActivationList( 131 !DidURLMatchActivationList(
135 url, configurations->the_one_and_only().activation_list)); 132 url, configurations->the_one_and_only().activation_list));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 179
183 const auto configurations = GetActiveConfigurations(); 180 const auto configurations = GetActiveConfigurations();
184 if (configurations->the_one_and_only().should_whitelist_site_on_reload && 181 if (configurations->the_one_and_only().should_whitelist_site_on_reload &&
185 NavigationIsPageReload(url, referrer, transition)) { 182 NavigationIsPageReload(url, referrer, transition)) {
186 // Whitelist this host for the current as well as subsequent navigations. 183 // Whitelist this host for the current as well as subsequent navigations.
187 client_->WhitelistInCurrentWebContents(url); 184 client_->WhitelistInCurrentWebContents(url);
188 } 185 }
189 186
190 activation_decision_ = 187 activation_decision_ =
191 ComputeActivationDecisionForMainFrameNavigation(navigation_handle); 188 ComputeActivationDecisionForMainFrameNavigation(navigation_handle);
189
190 // Check for the whitelisted status last, so that the client gets an accurate
191 // indication of whether there would be activation otherwise.
192 bool whitelisted = client_->OnPageActivationComputed(
193 navigation_handle, activation_decision_ == ActivationDecision::ACTIVATED);
194 if (whitelisted)
195 activation_decision_ = ActivationDecision::URL_WHITELISTED;
192 DCHECK(activation_decision_ != ActivationDecision::UNKNOWN); 196 DCHECK(activation_decision_ != ActivationDecision::UNKNOWN);
193 if (activation_decision_ != ActivationDecision::ACTIVATED) { 197 if (activation_decision_ != ActivationDecision::ACTIVATED) {
194 ResetActivationState(); 198 ResetActivationState();
195 return; 199 return;
196 } 200 }
197 201
198 activation_level_ = configurations->the_one_and_only().activation_level; 202 activation_level_ = configurations->the_one_and_only().activation_level;
199 measure_performance_ = 203 measure_performance_ =
200 activation_level_ != ActivationLevel::DISABLED && 204 activation_level_ != ActivationLevel::DISABLED &&
201 ShouldMeasurePerformanceForPageLoad( 205 ShouldMeasurePerformanceForPageLoad(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, 321 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern,
318 chain_size); 322 chain_size);
319 break; 323 break;
320 default: 324 default:
321 NOTREACHED(); 325 NOTREACHED();
322 break; 326 break;
323 } 327 }
324 } 328 }
325 329
326 } // namespace subresource_filter 330 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698