Index: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc |
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc |
index 7711de302b38347e3e9d3fc2d2e89c4e701629c7..b4cdac764da1e55f38b9ebda8d5923820afa412c 100644 |
--- a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc |
+++ b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc |
@@ -79,7 +79,8 @@ ContentSubresourceFilterDriverFactory::ContentSubresourceFilterDriverFactory( |
client_(std::move(client)), |
activation_level_(ActivationLevel::DISABLED), |
activation_decision_(ActivationDecision::UNKNOWN), |
- measure_performance_(false) {} |
+ measure_performance_(false), |
+ subresource_filter_only_hit_(false) {} |
ContentSubresourceFilterDriverFactory:: |
~ContentSubresourceFilterDriverFactory() {} |
@@ -125,12 +126,15 @@ void ContentSubresourceFilterDriverFactory:: |
bool is_soc_engineering_ads_interstitial = |
threat_type_metadata == |
safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS; |
- |
+ subresource_filter_only_hit_ = |
+ threat_type == safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER; |
if (is_phishing_interstitial) { |
if (is_soc_engineering_ads_interstitial) { |
AddActivationListMatch(url, ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL); |
} |
AddActivationListMatch(url, ActivationList::PHISHING_INTERSTITIAL); |
+ } else if (subresource_filter_only_hit_) { |
+ AddActivationListMatch(url, ActivationList::SUBRESOURCE_FILTER); |
} |
} |
@@ -205,6 +209,7 @@ void ContentSubresourceFilterDriverFactory::DidStartNavigation( |
ResetActivationState(); |
navigation_chain_.push_back(navigation_handle->GetURL()); |
client_->ToggleNotificationVisibility(false); |
+ subresource_filter_only_hit_ = false; |
} |
} |
@@ -329,6 +334,15 @@ bool ContentSubresourceFilterDriverFactory::DidURLMatchCurrentActivationList( |
match_types->second.end(); |
} |
+bool ContentSubresourceFilterDriverFactory:: |
+ DidURLMatchSubresourceFilterOnlyList(const GURL& url) const { |
engedy
2017/03/02 12:00:42
Let's try to avoid duplicating the code above, and
melandory
2017/03/06 15:00:00
Done.
|
+ auto match_types = |
+ activation_list_matches_.find(DistillURLToHostAndPath(url)); |
+ return match_types != activation_list_matches_.end() && |
+ match_types->second.find(ActivationList::SUBRESOURCE_FILTER) != |
+ match_types->second.end(); |
+} |
+ |
void ContentSubresourceFilterDriverFactory::AddActivationListMatch( |
const GURL& url, |
ActivationList match_type) { |
@@ -342,32 +356,47 @@ void ContentSubresourceFilterDriverFactory::RecordRedirectChainMatchPattern() |
const int kInitialURLHitMask = 0x4; |
const int kRedirectURLHitMask = 0x2; |
const int kFinalURLHitMask = 0x1; |
+ auto in_list = [this](const GURL& url) { |
+ return subresource_filter_only_hit_ |
+ ? DidURLMatchSubresourceFilterOnlyList(url) |
+ : DidURLMatchCurrentActivationList(url); |
+ }; |
if (navigation_chain_.size() > 1) { |
- if (DidURLMatchCurrentActivationList(navigation_chain_.back())) |
+ if (in_list(navigation_chain_.back())) |
hits_pattern |= kFinalURLHitMask; |
- if (DidURLMatchCurrentActivationList(navigation_chain_.front())) |
+ if (in_list(navigation_chain_.front())) |
hits_pattern |= kInitialURLHitMask; |
// Examine redirects. |
for (size_t i = 1; i < navigation_chain_.size() - 1; ++i) { |
- if (DidURLMatchCurrentActivationList(navigation_chain_[i])) { |
+ if (in_list(navigation_chain_[i])) { |
hits_pattern |= kRedirectURLHitMask; |
break; |
} |
} |
} else { |
- if (navigation_chain_.size() && |
- DidURLMatchCurrentActivationList(navigation_chain_.front())) { |
+ if (navigation_chain_.size() && in_list(navigation_chain_.front())) { |
hits_pattern = 0x8; // One url hit. |
} |
} |
if (!hits_pattern) |
return; |
- UMA_HISTOGRAM_ENUMERATION( |
- "SubresourceFilter.PageLoad.RedirectChainMatchPattern", hits_pattern, |
- 0x10 /* max value */); |
- UMA_HISTOGRAM_COUNTS("SubresourceFilter.PageLoad.RedirectChainLength", |
- navigation_chain_.size()); |
+ if (subresource_filter_only_hit_) { |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "SubresourceFilter.PageLoad.RedirectChainMatchPattern." |
+ "SubresourceFilterOnly", |
+ hits_pattern, 0x10 /* max value */); |
+ UMA_HISTOGRAM_COUNTS( |
+ "SubresourceFilter.PageLoad.RedirectChainLength.SubresourceFilterOnly", |
+ navigation_chain_.size()); |
+ |
+ } else { |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "SubresourceFilter.PageLoad.RedirectChainMatchPattern", hits_pattern, |
+ 0x10 /* max value */); |
+ UMA_HISTOGRAM_COUNTS("SubresourceFilter.PageLoad.RedirectChainLength", |
+ navigation_chain_.size()); |
+ } |
} |
} // namespace subresource_filter |