| 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 b9c7d1ca9b46b691aed64c8d89a51f06f1b137f2..f63c66601139ed5c03ebdf4d557ca2043f1d6433 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);
|
| }
|
| }
|
|
|
| @@ -163,8 +167,8 @@ ContentSubresourceFilterDriverFactory::ComputeActivationDecisionForMainFrameURL(
|
| // AddActivationListMatch to ensure the activation list only has relevant
|
| // entries.
|
| DCHECK(url.SchemeIsHTTPOrHTTPS() ||
|
| - !DidURLMatchCurrentActivationList(url));
|
| - return DidURLMatchCurrentActivationList(url)
|
| + !DidURLMatchActivationList(url, GetCurrentActivationList()));
|
| + return DidURLMatchActivationList(url, GetCurrentActivationList())
|
| ? ActivationDecision::ACTIVATED
|
| : ActivationDecision::ACTIVATION_LIST_NOT_MATCHED;
|
| default:
|
| @@ -206,6 +210,7 @@ void ContentSubresourceFilterDriverFactory::DidStartNavigation(
|
| ResetActivationState();
|
| navigation_chain_.push_back(navigation_handle->GetURL());
|
| client_->ToggleNotificationVisibility(false);
|
| + subresource_filter_only_hit_ = false;
|
| }
|
| }
|
|
|
| @@ -321,12 +326,13 @@ void ContentSubresourceFilterDriverFactory::ReadyToCommitNavigationInternal(
|
| ActivateForFrameHostIfNeeded(render_frame_host, url);
|
| }
|
|
|
| -bool ContentSubresourceFilterDriverFactory::DidURLMatchCurrentActivationList(
|
| - const GURL& url) const {
|
| +bool ContentSubresourceFilterDriverFactory::DidURLMatchActivationList(
|
| + const GURL& url,
|
| + ActivationList acttivation_list) const {
|
| auto match_types =
|
| activation_list_matches_.find(DistillURLToHostAndPath(url));
|
| return match_types != activation_list_matches_.end() &&
|
| - match_types->second.find(GetCurrentActivationList()) !=
|
| + match_types->second.find(acttivation_list) !=
|
| match_types->second.end();
|
| }
|
|
|
| @@ -337,38 +343,58 @@ void ContentSubresourceFilterDriverFactory::AddActivationListMatch(
|
| activation_list_matches_[DistillURLToHostAndPath(url)].insert(match_type);
|
| }
|
|
|
| -void ContentSubresourceFilterDriverFactory::RecordRedirectChainMatchPattern()
|
| - const {
|
| +int ContentSubresourceFilterDriverFactory::CalculateHitPatternForActivationList(
|
| + ActivationList activation_list) const {
|
| int hits_pattern = 0;
|
| const int kInitialURLHitMask = 0x4;
|
| const int kRedirectURLHitMask = 0x2;
|
| const int kFinalURLHitMask = 0x1;
|
| +
|
| if (navigation_chain_.size() > 1) {
|
| - if (DidURLMatchCurrentActivationList(navigation_chain_.back()))
|
| + if (DidURLMatchActivationList(navigation_chain_.back(), activation_list))
|
| hits_pattern |= kFinalURLHitMask;
|
| - if (DidURLMatchCurrentActivationList(navigation_chain_.front()))
|
| + if (DidURLMatchActivationList(navigation_chain_.front(), activation_list))
|
| hits_pattern |= kInitialURLHitMask;
|
|
|
| // Examine redirects.
|
| for (size_t i = 1; i < navigation_chain_.size() - 1; ++i) {
|
| - if (DidURLMatchCurrentActivationList(navigation_chain_[i])) {
|
| + if (DidURLMatchActivationList(navigation_chain_[i], activation_list)) {
|
| hits_pattern |= kRedirectURLHitMask;
|
| break;
|
| }
|
| }
|
| } else {
|
| if (navigation_chain_.size() &&
|
| - DidURLMatchCurrentActivationList(navigation_chain_.front())) {
|
| + DidURLMatchActivationList(navigation_chain_.front(), activation_list)) {
|
| hits_pattern = 0x8; // One url hit.
|
| }
|
| }
|
| + return hits_pattern;
|
| +}
|
| +
|
| +void ContentSubresourceFilterDriverFactory::RecordRedirectChainMatchPattern()
|
| + const {
|
| + int hits_pattern = CalculateHitPatternForActivationList(
|
| + !subresource_filter_only_hit_ ? GetCurrentActivationList()
|
| + : ActivationList::SUBRESOURCE_FILTER);
|
| 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
|
|
|