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

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

Issue 2396133003: Change the logic how Subesource Filter propagates activation. (Closed)
Patch Set: fix tests Created 4 years, 2 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 3f2947d3de54ff8681b5daa2e7df7374ad504b4d..3a3747d4b1e251d9c1e18f133720ed14f18fb535 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
@@ -74,15 +74,12 @@ bool ContentSubresourceFilterDriverFactory::IsWhitelisted(
return whitelisted_set().find(url.host()) != whitelisted_set().end();
}
-bool ContentSubresourceFilterDriverFactory::IsBlacklisted(
- const GURL& url) const {
- return activation_set().find(url.host()) != activation_set().end();
+bool ContentSubresourceFilterDriverFactory::IsHit(const GURL& url) const {
+ return safe_browsing_blacklisted_patterns_set().find(url.host() +
+ url.path()) !=
+ safe_browsing_blacklisted_patterns_set().end();
}
-bool ContentSubresourceFilterDriverFactory::ShouldActivateForURL(
- const GURL& url) const {
- return IsBlacklisted(url) && !IsWhitelisted(url);
-}
void ContentSubresourceFilterDriverFactory::
OnMainResourceMatchedSafeBrowsingBlacklist(
@@ -101,9 +98,7 @@ void ContentSubresourceFilterDriverFactory::
}
if (!proceed)
return;
- AddHostOfURLToActivationSet(url);
- for (const auto& url : redirect_urls)
- AddHostOfURLToActivationSet(url);
+ AddToActivationHitsSet(url);
}
void ContentSubresourceFilterDriverFactory::AddHostOfURLToWhitelistSet(
@@ -112,10 +107,10 @@ void ContentSubresourceFilterDriverFactory::AddHostOfURLToWhitelistSet(
whitelisted_hosts_.insert(url.host());
}
-void ContentSubresourceFilterDriverFactory::AddHostOfURLToActivationSet(
+void ContentSubresourceFilterDriverFactory::AddToActivationHitsSet(
const GURL& url) {
if (!url.host().empty() && url.SchemeIsHTTPOrHTTPS())
- activate_on_hosts_.insert(url.host());
+ safe_browsing_blacklisted_patterns_.insert(url.host() + url.path());
}
void ContentSubresourceFilterDriverFactory::ReadyToCommitMainFrameNavigation(
@@ -132,7 +127,7 @@ bool ContentSubresourceFilterDriverFactory::ShouldActivateForMainFrameURL(
if (GetCurrentActivationScope() == ActivationScope::ALL_SITES)
return !IsWhitelisted(url);
else if (GetCurrentActivationScope() == ActivationScope::ACTIVATION_LIST)
- return ShouldActivateForURL(url);
+ return IsHit(url) && !IsWhitelisted(url);
return false;
}
@@ -182,6 +177,7 @@ void ContentSubresourceFilterDriverFactory::DidStartProvisionalLoadForFrame(
const GURL& validated_url,
bool is_error_page,
bool is_iframe_srcdoc) {
+ safe_browsing_blacklisted_patterns_.clear();
if (!render_frame_host->GetParent()) {
client_->ToggleNotificationVisibility(false);
set_activation_state(ActivationState::DISABLED);

Powered by Google App Engine
This is Rietveld 408576698