@@ -127,25 +127,28 @@ void ContentSubresourceFilterDriverFactory::OnSafeBrowsingMatchComputed(
127
127
throttle_manager_->NotifyPageActivationComputed (navigation_handle, state);
128
128
}
129
129
130
+ // Be careful when modifying this method, as the order in which the
131
+ // activation_decision_ is decided is very important and corresponds to UMA
132
+ // metrics. In general we want to follow the pattern that
133
+ // ACTIVATION_CONDITIONS_NOT_MET will always be logged if no configuration
134
+ // matches this navigation. We log other decisions only if a configuration
135
+ // matches and also would have activated.
130
136
void ContentSubresourceFilterDriverFactory::
131
137
ComputeActivationForMainFrameNavigation (
132
138
content::NavigationHandle* navigation_handle,
133
139
ActivationList matched_list) {
134
140
const GURL& url (navigation_handle->GetURL ());
135
141
136
- if (!url.SchemeIsHTTPOrHTTPS ()) {
137
- activation_decision_ = ActivationDecision::UNSUPPORTED_SCHEME;
138
- activation_options_ = Configuration::ActivationOptions ();
139
- return ;
140
- }
141
-
142
+ bool scheme_is_http_or_https = url.SchemeIsHTTPOrHTTPS ();
142
143
const auto config_list = GetEnabledConfigurations ();
143
144
const auto highest_priority_activated_config =
144
145
std::find_if (config_list->configs_by_decreasing_priority ().begin (),
145
146
config_list->configs_by_decreasing_priority ().end (),
146
- [&url, matched_list, this ](const Configuration& config) {
147
+ [&url, scheme_is_http_or_https, matched_list,
148
+ this ](const Configuration& config) {
147
149
return DoesMainFrameURLSatisfyActivationConditions (
148
- url, config.activation_conditions , matched_list);
150
+ url, scheme_is_http_or_https,
151
+ config.activation_conditions , matched_list);
149
152
});
150
153
151
154
bool has_activated_config =
@@ -164,7 +167,18 @@ void ContentSubresourceFilterDriverFactory::
164
167
return ;
165
168
}
166
169
167
- activation_options_ = highest_priority_activated_config->activation_options ;
170
+ const Configuration::ActivationOptions& activation_options =
171
+ highest_priority_activated_config->activation_options ;
172
+
173
+ // Log UNSUPPORTED_SCHEME if we would have otherwise activated.
174
+ if (!scheme_is_http_or_https &&
175
+ activation_options.activation_level != ActivationLevel::DISABLED) {
176
+ activation_decision_ = ActivationDecision::UNSUPPORTED_SCHEME;
177
+ activation_options_ = Configuration::ActivationOptions ();
178
+ return ;
179
+ }
180
+
181
+ activation_options_ = activation_options;
168
182
activation_decision_ =
169
183
activation_options_.activation_level == ActivationLevel::DISABLED
170
184
? ActivationDecision::ACTIVATION_DISABLED
@@ -174,12 +188,18 @@ void ContentSubresourceFilterDriverFactory::
174
188
bool ContentSubresourceFilterDriverFactory::
175
189
DoesMainFrameURLSatisfyActivationConditions (
176
190
const GURL& url,
191
+ bool scheme_is_http_or_https,
177
192
const Configuration::ActivationConditions& conditions,
178
193
ActivationList matched_list) const {
194
+ // scheme_is_http_or_https implies url.SchemeIsHTTPOrHTTPS().
195
+ DCHECK (!scheme_is_http_or_https || url.SchemeIsHTTPOrHTTPS ());
179
196
switch (conditions.activation_scope ) {
180
197
case ActivationScope::ALL_SITES:
181
198
return true ;
182
199
case ActivationScope::ACTIVATION_LIST:
200
+ // ACTIVATION_LIST does not support non http/s URLs.
201
+ if (!scheme_is_http_or_https)
202
+ return false ;
183
203
if (conditions.activation_list == matched_list)
184
204
return true ;
185
205
if (conditions.activation_list == ActivationList::PHISHING_INTERSTITIAL &&
0 commit comments