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" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/net/cert_logger.pb.h" |
16 #include "chrome/browser/safe_browsing/malware_details.h" | 17 #include "chrome/browser/safe_browsing/malware_details.h" |
17 #include "chrome/browser/safe_browsing/metadata.pb.h" | 18 #include "chrome/browser/safe_browsing/metadata.pb.h" |
18 #include "chrome/browser/safe_browsing/ping_manager.h" | 19 #include "chrome/browser/safe_browsing/ping_manager.h" |
19 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
21 #include "chrome/browser/tab_contents/tab_util.h" | 22 #include "chrome/browser/tab_contents/tab_util.h" |
22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
23 #include "components/metrics/metrics_service.h" | 24 #include "components/metrics/metrics_service.h" |
24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return; | 209 return; |
209 | 210 |
210 BrowserThread::PostTask( | 211 BrowserThread::PostTask( |
211 BrowserThread::IO, FROM_HERE, | 212 BrowserThread::IO, FROM_HERE, |
212 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, this, | 213 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, this, |
213 malicious_url, page_url, referrer_url, is_subresource, | 214 malicious_url, page_url, referrer_url, is_subresource, |
214 threat_type, post_data)); | 215 threat_type, post_data)); |
215 } | 216 } |
216 | 217 |
217 void SafeBrowsingUIManager::ReportInvalidCertificateChain( | 218 void SafeBrowsingUIManager::ReportInvalidCertificateChain( |
218 const std::string& hostname, | 219 const chrome_browser_net::CertLoggerRequest& report, |
219 const net::SSLInfo& ssl_info, | |
220 const base::Closure& callback) { | 220 const base::Closure& callback) { |
221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
222 BrowserThread::PostTaskAndReply( | 222 BrowserThread::PostTaskAndReply( |
223 BrowserThread::IO, FROM_HERE, | 223 BrowserThread::IO, FROM_HERE, |
224 base::Bind( | 224 base::Bind( |
225 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, | 225 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, |
226 hostname, ssl_info), | 226 report), |
227 callback); | 227 callback); |
228 } | 228 } |
229 | 229 |
230 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 230 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
232 observer_list_.AddObserver(observer); | 232 observer_list_.AddObserver(observer); |
233 } | 233 } |
234 | 234 |
235 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { | 235 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { |
236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 17 matching lines...) Expand all Loading... |
254 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url | 254 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url |
255 << " " << referrer_url << " " << is_subresource << " " | 255 << " " << referrer_url << " " << is_subresource << " " |
256 << threat_type; | 256 << threat_type; |
257 sb_service_->ping_manager()->ReportSafeBrowsingHit( | 257 sb_service_->ping_manager()->ReportSafeBrowsingHit( |
258 malicious_url, page_url, | 258 malicious_url, page_url, |
259 referrer_url, is_subresource, | 259 referrer_url, is_subresource, |
260 threat_type, post_data); | 260 threat_type, post_data); |
261 } | 261 } |
262 | 262 |
263 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( | 263 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( |
264 const std::string& hostname, | 264 const chrome_browser_net::CertLoggerRequest& report) { |
265 const net::SSLInfo& ssl_info) { | |
266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
267 | 266 |
268 // The service may delete the ping manager (i.e. when user disabling service, | 267 // The service may delete the ping manager (i.e. when user disabling service, |
269 // etc). This happens on the IO thread. | 268 // etc). This happens on the IO thread. |
270 if (!sb_service_ || !sb_service_->ping_manager()) | 269 if (!sb_service_ || !sb_service_->ping_manager()) |
271 return; | 270 return; |
272 | 271 |
273 sb_service_->ping_manager()->ReportInvalidCertificateChain(hostname, | 272 sb_service_->ping_manager()->ReportInvalidCertificateChain(report); |
274 ssl_info); | |
275 } | 273 } |
276 | 274 |
277 // If the user had opted-in to send MalwareDetails, this gets called | 275 // If the user had opted-in to send MalwareDetails, this gets called |
278 // when the report is ready. | 276 // when the report is ready. |
279 void SafeBrowsingUIManager::SendSerializedMalwareDetails( | 277 void SafeBrowsingUIManager::SendSerializedMalwareDetails( |
280 const std::string& serialized) { | 278 const std::string& serialized) { |
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
282 | 280 |
283 // The service may delete the ping manager (i.e. when user disabling service, | 281 // The service may delete the ping manager (i.e. when user disabling service, |
284 // etc). This happens on the IO thread. | 282 // etc). This happens on the IO thread. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && | 324 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && |
327 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { | 325 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { |
328 return entry.domain == | 326 return entry.domain == |
329 net::registry_controlled_domains::GetDomainAndRegistry( | 327 net::registry_controlled_domains::GetDomainAndRegistry( |
330 resource.url, | 328 resource.url, |
331 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 329 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
332 } | 330 } |
333 } | 331 } |
334 return false; | 332 return false; |
335 } | 333 } |
OLD | NEW |