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

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

Issue 2060313002: Navigation throttle for the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pre-tab-activation
Patch Set: adressing engedy@ comments Created 4 years, 5 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 aec0b81d45c34b6a46b2514b98a008285002e338..fa88ee677adf7d2c877b796adbbd0a1ba0108200 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
@@ -63,17 +63,32 @@ void ContentSubresourceFilterDriverFactory::
safe_browsing::ThreatPatternType threat_type) {
if (threat_type != safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS)
return;
- activate_on_origins_.insert(url.host());
- for (const auto& url : redirect_urls) {
- activate_on_origins_.insert(url.host());
- }
+ AddOriginOfURLToActivationSet(url);
+ for (const auto& url : redirect_urls)
+ AddOriginOfURLToActivationSet(url);
}
bool ContentSubresourceFilterDriverFactory::ShouldActivateForURL(
- const GURL& url) {
+ const GURL& url) const {
return activation_set().find(url.host()) != activation_set().end();
}
+void ContentSubresourceFilterDriverFactory::AddOriginOfURLToActivationSet(
+ const GURL& url) {
+ if (!url.host().empty() && url.SchemeIsHTTPOrHTTPS())
+ activate_on_origins_.insert(url.host());
+}
+
+void ContentSubresourceFilterDriverFactory::SetDriverForFrameHostForTesting(
+ content::RenderFrameHost* render_frame_host,
+ std::unique_ptr<ContentSubresourceFilterDriver> driver) {
+ auto iterator_and_inserted =
+ frame_drivers_.insert(std::make_pair(render_frame_host, nullptr));
+ if (iterator_and_inserted.second) {
+ iterator_and_inserted.first->second = std::move(driver);
+ }
+}
+
ContentSubresourceFilterDriver*
ContentSubresourceFilterDriverFactory::DriverFromFrameHost(
content::RenderFrameHost* render_frame_host) {

Powered by Google App Engine
This is Rietveld 408576698