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/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 187 } |
188 | 188 |
189 void ReportMalware(SBThreatType threat_type) { | 189 void ReportMalware(SBThreatType threat_type) { |
190 std::string post_data; | 190 std::string post_data; |
191 if (!sha256_hash_.empty()) | 191 if (!sha256_hash_.empty()) |
192 post_data += base::HexEncode(sha256_hash_.data(), | 192 post_data += base::HexEncode(sha256_hash_.data(), |
193 sha256_hash_.size()) + "\n"; | 193 sha256_hash_.size()) + "\n"; |
194 for (size_t i = 0; i < url_chain_.size(); ++i) { | 194 for (size_t i = 0; i < url_chain_.size(); ++i) { |
195 post_data += url_chain_[i].spec() + "\n"; | 195 post_data += url_chain_[i].spec() + "\n"; |
196 } | 196 } |
| 197 // Be careful about taking the front()/back() of possibly-empty vectors! |
| 198 // http://crbug.com/190096 |
| 199 const GURL& malicious_url = url_chain_.empty() ? GURL::EmptyGURL() |
| 200 : url_chain_.back(); |
| 201 const GURL& page_url = url_chain_.empty() ? GURL::EmptyGURL() |
| 202 : url_chain_.front(); |
197 ui_manager_->ReportSafeBrowsingHit( | 203 ui_manager_->ReportSafeBrowsingHit( |
198 url_chain_.back(), // malicious_url | 204 malicious_url, |
199 url_chain_.front(), // page_url | 205 page_url, |
200 referrer_url_, | 206 referrer_url_, |
201 true, // is_subresource | 207 true, // is_subresource |
202 threat_type, | 208 threat_type, |
203 post_data); | 209 post_data); |
204 } | 210 } |
205 | 211 |
206 void UpdateDownloadCheckStats(SBStatsType stat_type) { | 212 void UpdateDownloadCheckStats(SBStatsType stat_type) { |
207 UMA_HISTOGRAM_ENUMERATION("SB2.DownloadChecks", | 213 UMA_HISTOGRAM_ENUMERATION("SB2.DownloadChecks", |
208 stat_type, | 214 stat_type, |
209 DOWNLOAD_CHECKS_MAX); | 215 DOWNLOAD_CHECKS_MAX); |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 std::string url = kDownloadRequestUrl; | 950 std::string url = kDownloadRequestUrl; |
945 std::string api_key = google_apis::GetAPIKey(); | 951 std::string api_key = google_apis::GetAPIKey(); |
946 if (!api_key.empty()) { | 952 if (!api_key.empty()) { |
947 base::StringAppendF(&url, "?key=%s", | 953 base::StringAppendF(&url, "?key=%s", |
948 net::EscapeQueryParamValue(api_key, true).c_str()); | 954 net::EscapeQueryParamValue(api_key, true).c_str()); |
949 } | 955 } |
950 return url; | 956 return url; |
951 } | 957 } |
952 | 958 |
953 } // namespace safe_browsing | 959 } // namespace safe_browsing |
OLD | NEW |