diff options
Diffstat (limited to 'chrome/browser/safe_browsing/download_protection_service.cc')
-rw-r--r-- | chrome/browser/safe_browsing/download_protection_service.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc index afb797d..ce10f13 100644 --- a/chrome/browser/safe_browsing/download_protection_service.cc +++ b/chrome/browser/safe_browsing/download_protection_service.cc @@ -186,26 +186,27 @@ class DownloadProtectionService::CheckClientDownloadRequest << info_.download_url_chain.back() << ": success=" << source->GetStatus().is_success() << " response_code=" << source->GetResponseCode(); - DownloadCheckResultReason reason = REASON_MAX; - reason = REASON_SERVER_PING_FAILED; + DownloadCheckResultReason reason = REASON_SERVER_PING_FAILED; + DownloadCheckResult result = SAFE; if (source->GetStatus().is_success() && RC_REQUEST_OK == source->GetResponseCode()) { + ClientDownloadResponse response; std::string data; - source->GetResponseAsString(&data); - if (data.size() > 0) { - // For now no matter what we'll always say the download is safe. - // TODO(noelutz): Parse the response body to see exactly what's going - // on. + bool got_data = source->GetResponseAsString(&data); + DCHECK(got_data); + if (!response.ParseFromString(data)) { reason = REASON_INVALID_RESPONSE_PROTO; + } else if (response.verdict() == ClientDownloadResponse::DANGEROUS) { + reason = REASON_DOWNLOAD_DANGEROUS; + result = DANGEROUS; + } else { + reason = REASON_DOWNLOAD_SAFE; } } - - if (reason != REASON_MAX) { - RecordStats(reason); - } // We don't need the fetcher anymore. fetcher_.reset(); - FinishRequest(SAFE); + RecordStats(reason); + FinishRequest(result); } private: |