Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Unified Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc

Issue 2645283007: Add the client for accessing Subresource Filter only list. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0fc1ef58976ae105ac42f2aa5455fb0237ddce53..f7775f799fae4667328bba6f5f936adf3a64974a 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_state_(ActivationState::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);
@@ -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_ONLY);
}
}
@@ -196,6 +200,7 @@ void ContentSubresourceFilterDriverFactory::DidStartNavigation(
activation_state_ = ActivationState::DISABLED;
measure_performance_ = false;
aggregated_document_statistics_ = DocumentLoadStatistics();
+ subresource_filter_only_hit_ = false;
}
}
@@ -309,6 +314,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) {
@@ -322,32 +336,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

Powered by Google App Engine
This is Rietveld 408576698