| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 | 1052 |
| 1053 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url | 1053 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url |
| 1054 << " " << referrer_url << " " << is_subresource << " " | 1054 << " " << referrer_url << " " << is_subresource << " " |
| 1055 << threat_type; | 1055 << threat_type; |
| 1056 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, | 1056 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, |
| 1057 referrer_url, is_subresource, | 1057 referrer_url, is_subresource, |
| 1058 threat_type); | 1058 threat_type); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 // If the user had opted-in to send MalwareDetails, this gets called | 1061 // If the user had opted-in to send MalwareDetails, this gets called |
| 1062 // at the time that the blocking page is going away. | 1062 // when the report is ready. |
| 1063 void SafeBrowsingService::ReportMalwareDetails( | 1063 void SafeBrowsingService::SendSerializedMalwareDetails( |
| 1064 scoped_refptr<MalwareDetails> details) { | 1064 const std::string& serialized) { |
| 1065 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1065 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1066 scoped_ptr<const std::string> serialized(details->GetSerializedReport()); | 1066 if (!serialized.empty()) { |
| 1067 if (!serialized->empty()) { | |
| 1068 DVLOG(1) << "Sending serialized malware details."; | 1067 DVLOG(1) << "Sending serialized malware details."; |
| 1069 protocol_manager_->ReportMalwareDetails(*serialized); | 1068 protocol_manager_->ReportMalwareDetails(serialized); |
| 1070 } | 1069 } |
| 1071 } | 1070 } |
| 1072 | 1071 |
| 1073 void SafeBrowsingService::CheckDownloadHashOnSBThread( | 1072 void SafeBrowsingService::CheckDownloadHashOnSBThread( |
| 1074 SafeBrowsingCheck* check) { | 1073 SafeBrowsingCheck* check) { |
| 1075 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); | 1074 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); |
| 1076 DCHECK(enable_download_protection_); | 1075 DCHECK(enable_download_protection_); |
| 1077 | 1076 |
| 1078 if (!database_->ContainsDownloadHashPrefix(check->full_hash->prefix)) { | 1077 if (!database_->ContainsDownloadHashPrefix(check->full_hash->prefix)) { |
| 1079 // Good, we don't have hash for this url prefix. | 1078 // Good, we don't have hash for this url prefix. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 check->is_download = true; | 1170 check->is_download = true; |
| 1172 check->timeout_task = | 1171 check->timeout_task = |
| 1173 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); | 1172 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); |
| 1174 checks_.insert(check); | 1173 checks_.insert(check); |
| 1175 | 1174 |
| 1176 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1175 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
| 1177 | 1176 |
| 1178 MessageLoop::current()->PostDelayedTask( | 1177 MessageLoop::current()->PostDelayedTask( |
| 1179 FROM_HERE, check->timeout_task, timeout_ms); | 1178 FROM_HERE, check->timeout_task, timeout_ms); |
| 1180 } | 1179 } |
| OLD | NEW |