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

Side by Side Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc

Issue 2272323002: Allow Safe Browsing Saresource Filter to distinguish between different lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow Safe Browsing Saresource Filter to distinguish between different lists. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h" 5 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "components/safe_browsing_db/util.h"
9 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver.h" 8 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver.h"
10 #include "components/subresource_filter/content/common/subresource_filter_messag es.h" 9 #include "components/subresource_filter/content/common/subresource_filter_messag es.h"
11 #include "components/subresource_filter/core/browser/subresource_filter_client.h " 10 #include "components/subresource_filter/core/browser/subresource_filter_client.h "
12 #include "components/subresource_filter/core/browser/subresource_filter_features .h" 11 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
12 #include "components/subresource_filter/core/common/activation_list.h"
13 #include "content/public/browser/render_frame_host.h" 13 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "ipc/ipc_message_macros.h" 15 #include "ipc/ipc_message_macros.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace subresource_filter { 18 namespace subresource_filter {
19 19
20 // static 20 // static
21 const char ContentSubresourceFilterDriverFactory::kWebContentsUserDataKey[] = 21 const char ContentSubresourceFilterDriverFactory::kWebContentsUserDataKey[] =
22 "web_contents_subresource_filter_driver_factory"; 22 "web_contents_subresource_filter_driver_factory";
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 bool ContentSubresourceFilterDriverFactory::ShouldActivateForURL( 81 bool ContentSubresourceFilterDriverFactory::ShouldActivateForURL(
82 const GURL& url) const { 82 const GURL& url) const {
83 return IsBlacklisted(url) && !IsWhitelisted(url); 83 return IsBlacklisted(url) && !IsWhitelisted(url);
84 } 84 }
85 85
86 void ContentSubresourceFilterDriverFactory:: 86 void ContentSubresourceFilterDriverFactory::
87 OnMainResourceMatchedSafeBrowsingBlacklist( 87 OnMainResourceMatchedSafeBrowsingBlacklist(
88 const GURL& url, 88 const GURL& url,
89 const std::vector<GURL>& redirect_urls, 89 const std::vector<GURL>& redirect_urls,
90 safe_browsing::ThreatPatternType threat_type) { 90 safe_browsing::SBThreatType threat_type,
91 if (threat_type != safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS) 91 safe_browsing::ThreatPatternType threat_type_metadata) {
92 bool proceed =
engedy 2016/08/25 21:32:54 We should have at least one test that verifies thi
melandory 2016/08/25 23:38:27 Yes, I'm trying to add at least some basic tests.
93 GetCurrentActivationList() == ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL
94 ? (threat_type_metadata ==
95 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS)
96 : threat_type == safe_browsing::SB_THREAT_TYPE_URL_PHISHING;
97 if (!proceed)
92 return; 98 return;
93 AddHostOfURLToActivationSet(url); 99 AddHostOfURLToActivationSet(url);
94 for (const auto& url : redirect_urls) 100 for (const auto& url : redirect_urls)
95 AddHostOfURLToActivationSet(url); 101 AddHostOfURLToActivationSet(url);
96 } 102 }
97 103
98 void ContentSubresourceFilterDriverFactory::AddHostOfURLToWhitelistSet( 104 void ContentSubresourceFilterDriverFactory::AddHostOfURLToWhitelistSet(
99 const GURL& url) { 105 const GURL& url) {
100 if (!url.host().empty() && url.SchemeIsHTTPOrHTTPS()) 106 if (!url.host().empty() && url.SchemeIsHTTPOrHTTPS())
101 whitelisted_hosts_.insert(url.host()); 107 whitelisted_hosts_.insert(url.host());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 193
188 void ContentSubresourceFilterDriverFactory::PromptUserIfNeeded( 194 void ContentSubresourceFilterDriverFactory::PromptUserIfNeeded(
189 content::RenderFrameHost* render_frame_host) { 195 content::RenderFrameHost* render_frame_host) {
190 if (render_frame_host->GetParent()) 196 if (render_frame_host->GetParent())
191 return; // Not a main frame, do nothing. 197 return; // Not a main frame, do nothing.
192 client_->ToggleNotificationVisibility(activation_state() == 198 client_->ToggleNotificationVisibility(activation_state() ==
193 ActivationState::ENABLED); 199 ActivationState::ENABLED);
194 } 200 }
195 201
196 } // namespace subresource_filter 202 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698