| 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 c9125d23fbb319664c335f175564453f230a8144..b7699071b60cedfeb4a21f39b4dc9d6872b4c7a2 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
|
| @@ -68,7 +68,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);
|
| @@ -128,12 +129,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_ONLY);
|
| }
|
| }
|
|
|
| @@ -204,6 +208,7 @@ void ContentSubresourceFilterDriverFactory::DidStartNavigation(
|
| activation_level_ = ActivationLevel::DISABLED;
|
| measure_performance_ = false;
|
| aggregated_document_statistics_ = DocumentLoadStatistics();
|
| + subresource_filter_only_hit_ = false;
|
| }
|
| }
|
|
|
| @@ -317,6 +322,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_ONLY) !=
|
| + match_types->second.end();
|
| +}
|
| +
|
| void ContentSubresourceFilterDriverFactory::AddActivationListMatch(
|
| const GURL& url,
|
| ActivationList match_type) {
|
| @@ -330,32 +344,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
|
|
|