| 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 0ba6bf3d78a89043455a36cf1391fa9903af4cc2..2725dcc820a62f010612c4f27a94010a0835cf83 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
|
| @@ -76,7 +76,8 @@ ContentSubresourceFilterDriverFactory::ContentSubresourceFilterDriverFactory(
|
| : content::WebContentsObserver(web_contents),
|
| client_(std::move(client)),
|
| activation_level_(ActivationLevel::DISABLED),
|
| - measure_performance_(false) {
|
| + measure_performance_(false),
|
| + subresource_filter_only_hit_(false) {
|
| content::RenderFrameHost* main_frame_host = web_contents->GetMainFrame();
|
| if (main_frame_host && main_frame_host->IsRenderFrameLive())
|
| CreateDriverForFrameHostIfNeeded(main_frame_host);
|
| @@ -136,12 +137,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);
|
| }
|
| }
|
|
|
| @@ -215,6 +219,7 @@ void ContentSubresourceFilterDriverFactory::DidStartNavigation(
|
| ResetActivationState();
|
| navigation_chain_.push_back(navigation_handle->GetURL());
|
| client_->ToggleNotificationVisibility(false);
|
| + subresource_filter_only_hit_ = false;
|
| }
|
| }
|
|
|
| @@ -339,6 +344,15 @@ bool ContentSubresourceFilterDriverFactory::DidURLMatchCurrentActivationList(
|
| match_types->second.end();
|
| }
|
|
|
| +bool ContentSubresourceFilterDriverFactory::
|
| + DidURLMatchSubresourceFilterOnlyList(const GURL& url) const {
|
| + 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) {
|
| @@ -352,32 +366,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
|
|
|