| 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 | 5 |
| 6 #include "chrome/browser/download/download_safe_browsing_client.h" | 6 #include "chrome/browser/download/download_safe_browsing_client.h" |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SafeBrowsingService::Client is changed to RefCountedThreadSafe<>. | 21 // SafeBrowsingService::Client is changed to RefCountedThreadSafe<>. |
| 22 | 22 |
| 23 DownloadSBClient::DownloadSBClient(int32 download_id, | 23 DownloadSBClient::DownloadSBClient(int32 download_id, |
| 24 const std::vector<GURL>& url_chain, | 24 const std::vector<GURL>& url_chain, |
| 25 const GURL& referrer_url) | 25 const GURL& referrer_url) |
| 26 : info_(NULL), | 26 : info_(NULL), |
| 27 download_id_(download_id), | 27 download_id_(download_id), |
| 28 url_chain_(url_chain), | 28 url_chain_(url_chain), |
| 29 referrer_url_(referrer_url) { | 29 referrer_url_(referrer_url) { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 31 DCHECK(!url_chain.empty()); |
| 31 ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host(); | 32 ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host(); |
| 32 if (rdh) | 33 if (rdh) |
| 33 sb_service_ = rdh->safe_browsing_service(); | 34 sb_service_ = rdh->safe_browsing_service(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 DownloadSBClient::~DownloadSBClient() {} | 37 DownloadSBClient::~DownloadSBClient() {} |
| 37 | 38 |
| 38 void DownloadSBClient::CheckDownloadUrl(DownloadCreateInfo* info, | 39 void DownloadSBClient::CheckDownloadUrl(DownloadCreateInfo* info, |
| 39 UrlDoneCallback* callback) { | 40 UrlDoneCallback* callback) { |
| 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 UpdateDownloadCheckStats(DOWNLOAD_HASH_CHECKS_TOTAL); | 152 UpdateDownloadCheckStats(DOWNLOAD_HASH_CHECKS_TOTAL); |
| 152 if (is_dangerous) { | 153 if (is_dangerous) { |
| 153 UpdateDownloadCheckStats(DOWNLOAD_HASH_CHECKS_MALWARE); | 154 UpdateDownloadCheckStats(DOWNLOAD_HASH_CHECKS_MALWARE); |
| 154 ReportMalware(result); | 155 ReportMalware(result); |
| 155 } | 156 } |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 | 159 |
| 159 void DownloadSBClient::ReportMalware( | 160 void DownloadSBClient::ReportMalware( |
| 160 SafeBrowsingService::UrlCheckResult result) { | 161 SafeBrowsingService::UrlCheckResult result) { |
| 162 std::string post_data; |
| 163 for (size_t i = 0; i < url_chain_.size(); ++i) |
| 164 post_data += url_chain_[i].spec() + "\n"; |
| 165 |
| 161 sb_service_->ReportSafeBrowsingHit(url_chain_.back(), // malicious_url | 166 sb_service_->ReportSafeBrowsingHit(url_chain_.back(), // malicious_url |
| 162 url_chain_.front(), // page_url | 167 url_chain_.front(), // page_url |
| 163 referrer_url_, | 168 referrer_url_, |
| 164 true, | 169 true, |
| 165 result); | 170 result, |
| 171 post_data); |
| 166 } | 172 } |
| 167 | 173 |
| 168 void DownloadSBClient::UpdateDownloadCheckStats(SBStatsType stat_type) { | 174 void DownloadSBClient::UpdateDownloadCheckStats(SBStatsType stat_type) { |
| 169 UMA_HISTOGRAM_ENUMERATION("SB2.DownloadChecks", | 175 UMA_HISTOGRAM_ENUMERATION("SB2.DownloadChecks", |
| 170 stat_type, | 176 stat_type, |
| 171 DOWNLOAD_CHECKS_MAX); | 177 DOWNLOAD_CHECKS_MAX); |
| 172 } | 178 } |
| OLD | NEW |