OLD | NEW |
1 // Copyright (c) 2011 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" |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 NewRunnableMethod( | 1049 NewRunnableMethod( |
1050 this, | 1050 this, |
1051 &SafeBrowsingService::ReportSafeBrowsingHitOnIOThread, | 1051 &SafeBrowsingService::ReportSafeBrowsingHitOnIOThread, |
1052 malicious_url, | 1052 malicious_url, |
1053 page_url, | 1053 page_url, |
1054 referrer_url, | 1054 referrer_url, |
1055 is_subresource, | 1055 is_subresource, |
1056 threat_type)); | 1056 threat_type)); |
1057 } | 1057 } |
1058 | 1058 |
| 1059 void SafeBrowsingService::ReportSafeBrowsingHitWithChain( |
| 1060 const std::vector<GURL>& url_chain, |
| 1061 const GURL& referrer_url, |
| 1062 bool is_subresource, |
| 1063 SafeBrowsingService::UrlCheckResult threat_type) { |
| 1064 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1065 if (!CanReportStats()) |
| 1066 return; |
| 1067 |
| 1068 BrowserThread::PostTask( |
| 1069 BrowserThread::IO, FROM_HERE, |
| 1070 NewRunnableMethod( |
| 1071 this, |
| 1072 &SafeBrowsingService::ReportSafeBrowsingHitWithChainOnIOThread, |
| 1073 url_chain, |
| 1074 referrer_url, |
| 1075 is_subresource, |
| 1076 threat_type)); |
| 1077 } |
| 1078 |
1059 void SafeBrowsingService::ReportSafeBrowsingHitOnIOThread( | 1079 void SafeBrowsingService::ReportSafeBrowsingHitOnIOThread( |
1060 const GURL& malicious_url, | 1080 const GURL& malicious_url, |
1061 const GURL& page_url, | 1081 const GURL& page_url, |
1062 const GURL& referrer_url, | 1082 const GURL& referrer_url, |
1063 bool is_subresource, | 1083 bool is_subresource, |
1064 SafeBrowsingService::UrlCheckResult threat_type) { | 1084 SafeBrowsingService::UrlCheckResult threat_type) { |
1065 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1085 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1066 if (!enabled_) | 1086 if (!enabled_) |
1067 return; | 1087 return; |
1068 | 1088 |
1069 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url | 1089 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url |
1070 << " " << referrer_url << " " << is_subresource << " " | 1090 << " " << referrer_url << " " << is_subresource << " " |
1071 << threat_type; | 1091 << threat_type; |
1072 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, | 1092 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, |
1073 referrer_url, is_subresource, | 1093 referrer_url, is_subresource, |
1074 threat_type); | 1094 threat_type); |
1075 } | 1095 } |
1076 | 1096 |
| 1097 void SafeBrowsingService::ReportSafeBrowsingHitWithChainOnIOThread( |
| 1098 const std::vector<GURL>& url_chain, |
| 1099 const GURL& referrer_url, |
| 1100 bool is_subresource, |
| 1101 SafeBrowsingService::UrlCheckResult threat_type) { |
| 1102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1103 if (!enabled_) |
| 1104 return; |
| 1105 |
| 1106 DVLOG(1) << "ReportSafeBrowsingHitWithChain: " << url_chain.size() |
| 1107 << " " << url_chain.back() << " " << url_chain.front() |
| 1108 << " " << referrer_url << " " << is_subresource |
| 1109 << " " << threat_type; |
| 1110 protocol_manager_->ReportSafeBrowsingHitWithChain( |
| 1111 url_chain, referrer_url, is_subresource, threat_type); |
| 1112 } |
| 1113 |
1077 // If the user had opted-in to send MalwareDetails, this gets called | 1114 // If the user had opted-in to send MalwareDetails, this gets called |
1078 // when the report is ready. | 1115 // when the report is ready. |
1079 void SafeBrowsingService::SendSerializedMalwareDetails( | 1116 void SafeBrowsingService::SendSerializedMalwareDetails( |
1080 const std::string& serialized) { | 1117 const std::string& serialized) { |
1081 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1082 if (!serialized.empty()) { | 1119 if (!serialized.empty()) { |
1083 DVLOG(1) << "Sending serialized malware details."; | 1120 DVLOG(1) << "Sending serialized malware details."; |
1084 protocol_manager_->ReportMalwareDetails(serialized); | 1121 protocol_manager_->ReportMalwareDetails(serialized); |
1085 } | 1122 } |
1086 } | 1123 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 check->is_download = true; | 1223 check->is_download = true; |
1187 check->timeout_task = | 1224 check->timeout_task = |
1188 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); | 1225 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); |
1189 checks_.insert(check); | 1226 checks_.insert(check); |
1190 | 1227 |
1191 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1228 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
1192 | 1229 |
1193 MessageLoop::current()->PostDelayedTask( | 1230 MessageLoop::current()->PostDelayedTask( |
1194 FROM_HERE, check->timeout_task, timeout_ms); | 1231 FROM_HERE, check->timeout_task, timeout_ms); |
1195 } | 1232 } |
OLD | NEW |