| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 BrowserThread::PostTask( | 210 BrowserThread::PostTask( |
| 211 BrowserThread::IO, FROM_HERE, | 211 BrowserThread::IO, FROM_HERE, |
| 212 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, this, | 212 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, this, |
| 213 malicious_url, page_url, referrer_url, is_subresource, | 213 malicious_url, page_url, referrer_url, is_subresource, |
| 214 threat_type, post_data)); | 214 threat_type, post_data)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void SafeBrowsingUIManager::ReportInvalidCertificateChain( | 217 void SafeBrowsingUIManager::ReportInvalidCertificateChain( |
| 218 const std::string& hostname, | 218 const std::string& serialized_report, |
| 219 const net::SSLInfo& ssl_info, | |
| 220 const base::Closure& callback) { | 219 const base::Closure& callback) { |
| 221 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 220 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 222 BrowserThread::PostTaskAndReply( | 221 BrowserThread::PostTaskAndReply( |
| 223 BrowserThread::IO, FROM_HERE, | 222 BrowserThread::IO, FROM_HERE, |
| 224 base::Bind( | 223 base::Bind( |
| 225 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, | 224 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, |
| 226 hostname, ssl_info), | 225 serialized_report), |
| 227 callback); | 226 callback); |
| 228 } | 227 } |
| 229 | 228 |
| 230 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 229 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
| 231 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 230 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 232 observer_list_.AddObserver(observer); | 231 observer_list_.AddObserver(observer); |
| 233 } | 232 } |
| 234 | 233 |
| 235 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { | 234 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { |
| 236 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 235 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 254 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url | 253 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url |
| 255 << " " << referrer_url << " " << is_subresource << " " | 254 << " " << referrer_url << " " << is_subresource << " " |
| 256 << threat_type; | 255 << threat_type; |
| 257 sb_service_->ping_manager()->ReportSafeBrowsingHit( | 256 sb_service_->ping_manager()->ReportSafeBrowsingHit( |
| 258 malicious_url, page_url, | 257 malicious_url, page_url, |
| 259 referrer_url, is_subresource, | 258 referrer_url, is_subresource, |
| 260 threat_type, post_data); | 259 threat_type, post_data); |
| 261 } | 260 } |
| 262 | 261 |
| 263 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( | 262 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( |
| 264 const std::string& hostname, | 263 const std::string& serialized_report) { |
| 265 const net::SSLInfo& ssl_info) { | |
| 266 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 264 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 267 | 265 |
| 268 // The service may delete the ping manager (i.e. when user disabling service, | 266 // The service may delete the ping manager (i.e. when user disabling service, |
| 269 // etc). This happens on the IO thread. | 267 // etc). This happens on the IO thread. |
| 270 if (!sb_service_ || !sb_service_->ping_manager()) | 268 if (!sb_service_ || !sb_service_->ping_manager()) |
| 271 return; | 269 return; |
| 272 | 270 |
| 273 sb_service_->ping_manager()->ReportInvalidCertificateChain(hostname, | 271 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); |
| 274 ssl_info); | |
| 275 } | 272 } |
| 276 | 273 |
| 277 // If the user had opted-in to send MalwareDetails, this gets called | 274 // If the user had opted-in to send MalwareDetails, this gets called |
| 278 // when the report is ready. | 275 // when the report is ready. |
| 279 void SafeBrowsingUIManager::SendSerializedMalwareDetails( | 276 void SafeBrowsingUIManager::SendSerializedMalwareDetails( |
| 280 const std::string& serialized) { | 277 const std::string& serialized) { |
| 281 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 278 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 282 | 279 |
| 283 // The service may delete the ping manager (i.e. when user disabling service, | 280 // The service may delete the ping manager (i.e. when user disabling service, |
| 284 // etc). This happens on the IO thread. | 281 // 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 && | 323 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && |
| 327 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { | 324 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { |
| 328 return entry.domain == | 325 return entry.domain == |
| 329 net::registry_controlled_domains::GetDomainAndRegistry( | 326 net::registry_controlled_domains::GetDomainAndRegistry( |
| 330 resource.url, | 327 resource.url, |
| 331 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 328 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 332 } | 329 } |
| 333 } | 330 } |
| 334 return false; | 331 return false; |
| 335 } | 332 } |
| OLD | NEW |