OLD | NEW |
---|---|
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 Loading... | |
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 = false; | |
93 if (GetCurrentActivationList() == | |
94 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL) { | |
95 proceed = (threat_type_metadata == | |
96 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS); | |
97 } else if (GetCurrentActivationList() == | |
98 ActivationList::PHISHING_INTERSTITIAL) { | |
99 proceed = | |
100 (threat_type == safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | |
engedy
2016/08/26 17:37:17
Could you please double check with Noe if this sho
| |
101 } | |
102 if (!proceed) | |
92 return; | 103 return; |
93 AddHostOfURLToActivationSet(url); | 104 AddHostOfURLToActivationSet(url); |
94 for (const auto& url : redirect_urls) | 105 for (const auto& url : redirect_urls) |
95 AddHostOfURLToActivationSet(url); | 106 AddHostOfURLToActivationSet(url); |
96 } | 107 } |
97 | 108 |
98 void ContentSubresourceFilterDriverFactory::AddHostOfURLToWhitelistSet( | 109 void ContentSubresourceFilterDriverFactory::AddHostOfURLToWhitelistSet( |
99 const GURL& url) { | 110 const GURL& url) { |
100 if (!url.host().empty() && url.SchemeIsHTTPOrHTTPS()) | 111 if (!url.host().empty() && url.SchemeIsHTTPOrHTTPS()) |
101 whitelisted_hosts_.insert(url.host()); | 112 whitelisted_hosts_.insert(url.host()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 | 198 |
188 void ContentSubresourceFilterDriverFactory::PromptUserIfNeeded( | 199 void ContentSubresourceFilterDriverFactory::PromptUserIfNeeded( |
189 content::RenderFrameHost* render_frame_host) { | 200 content::RenderFrameHost* render_frame_host) { |
190 if (render_frame_host->GetParent()) | 201 if (render_frame_host->GetParent()) |
191 return; // Not a main frame, do nothing. | 202 return; // Not a main frame, do nothing. |
192 client_->ToggleNotificationVisibility(activation_state() == | 203 client_->ToggleNotificationVisibility(activation_state() == |
193 ActivationState::ENABLED); | 204 ActivationState::ENABLED); |
194 } | 205 } |
195 | 206 |
196 } // namespace subresource_filter | 207 } // namespace subresource_filter |
OLD | NEW |