OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/ui_manager.h" | 5 #include "chrome/browser/safe_browsing/ui_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/debug/leak_tracker.h" | 10 #include "base/debug/leak_tracker.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 proto.ParseFromString(resource.threat_metadata) && | 110 proto.ParseFromString(resource.threat_metadata) && |
111 proto.pattern_type() == safe_browsing::MalwarePatternType::LANDING)) { | 111 proto.pattern_type() == safe_browsing::MalwarePatternType::LANDING)) { |
112 if (!resource.callback.is_null()) { | 112 if (!resource.callback.is_null()) { |
113 BrowserThread::PostTask( | 113 BrowserThread::PostTask( |
114 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); | 114 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); |
115 } | 115 } |
116 return; | 116 return; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 // For M40, the UwS warning may be gated to not show any UI. | |
121 const bool ping_only = resource.threat_type == SB_THREAT_TYPE_URL_UNWANTED | |
122 && safe_browsing_util::GetUnwantedTrialGroup() < safe_browsing_util::UWS_ON; | |
123 | |
124 // Indicate to interested observers that the resource in question matched the | 120 // Indicate to interested observers that the resource in question matched the |
125 // SB filters, unless the UwS interstitial is in ping-only mode. | 121 // SB filters. |
126 if (resource.threat_type != SB_THREAT_TYPE_SAFE && !ping_only) { | 122 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { |
127 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingMatch(resource)); | 123 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingMatch(resource)); |
128 } | 124 } |
129 | 125 |
130 // Check if the user has already ignored our warning for this render_view | 126 // Check if the user has already ignored our warning for this render_view |
131 // and domain. | 127 // and domain. |
132 if (IsWhitelisted(resource)) { | 128 if (IsWhitelisted(resource)) { |
133 if (!resource.callback.is_null()) { | 129 if (!resource.callback.is_null()) { |
134 BrowserThread::PostTask( | 130 BrowserThread::PostTask( |
135 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); | 131 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); |
136 } | 132 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 !resource.original_url.is_empty() && | 168 !resource.original_url.is_empty() && |
173 resource.original_url != resource.url) { | 169 resource.original_url != resource.url) { |
174 referrer_url = page_url; | 170 referrer_url = page_url; |
175 page_url = resource.original_url; | 171 page_url = resource.original_url; |
176 } | 172 } |
177 ReportSafeBrowsingHit(resource.url, page_url, referrer_url, | 173 ReportSafeBrowsingHit(resource.url, page_url, referrer_url, |
178 resource.is_subresource, resource.threat_type, | 174 resource.is_subresource, resource.threat_type, |
179 std::string() /* post_data */); | 175 std::string() /* post_data */); |
180 } | 176 } |
181 | 177 |
182 // If UwS interstitials are turned off, return here before showing UI. | |
183 if (ping_only) { | |
184 if (!resource.callback.is_null()) { | |
185 BrowserThread::PostTask( | |
186 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); | |
187 } | |
188 return; | |
189 } | |
190 | |
191 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { | 178 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { |
192 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingHit(resource)); | 179 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingHit(resource)); |
193 } | 180 } |
194 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource); | 181 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource); |
195 } | 182 } |
196 | 183 |
197 // A safebrowsing hit is sent after a blocking page for malware/phishing | 184 // A safebrowsing hit is sent after a blocking page for malware/phishing |
198 // or after the warning dialog for download urls, only for UMA users. | 185 // or after the warning dialog for download urls, only for UMA users. |
199 void SafeBrowsingUIManager::ReportSafeBrowsingHit( | 186 void SafeBrowsingUIManager::ReportSafeBrowsingHit( |
200 const GURL& malicious_url, | 187 const GURL& malicious_url, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && | 313 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && |
327 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { | 314 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { |
328 return entry.domain == | 315 return entry.domain == |
329 net::registry_controlled_domains::GetDomainAndRegistry( | 316 net::registry_controlled_domains::GetDomainAndRegistry( |
330 resource.url, | 317 resource.url, |
331 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 318 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
332 } | 319 } |
333 } | 320 } |
334 return false; | 321 return false; |
335 } | 322 } |
OLD | NEW |