| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 } else { | 662 } else { |
| 663 PostFinishTask(UNKNOWN, REASON_ARCHIVE_WITHOUT_BINARIES); | 663 PostFinishTask(UNKNOWN, REASON_ARCHIVE_WITHOUT_BINARIES); |
| 664 return; | 664 return; |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 OnFileFeatureExtractionDone(); | 668 OnFileFeatureExtractionDone(); |
| 669 } | 669 } |
| 670 #endif // defined(OS_MACOSX) | 670 #endif // defined(OS_MACOSX) |
| 671 | 671 |
| 672 static void RecordCountOfSignedOrWhitelistedDownload() { | 672 enum WhitelistType { |
| 673 UMA_HISTOGRAM_COUNTS("SBClientDownload.SignedOrWhitelistedDownload", 1); | 673 URL_WHITELIST, |
| 674 SIGNATURE_WHITELIST, |
| 675 WHITELIST_TYPE_MAX |
| 676 }; |
| 677 |
| 678 static void RecordCountOfWhitelistedDownload(WhitelistType type) { |
| 679 UMA_HISTOGRAM_ENUMERATION("SBClientDownload.WhitelistedDownload", |
| 680 type, |
| 681 WHITELIST_TYPE_MAX); |
| 674 } | 682 } |
| 675 | 683 |
| 676 void CheckWhitelists() { | 684 void CheckWhitelists() { |
| 677 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 685 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 678 | 686 |
| 679 if (!database_manager_.get()) { | 687 if (!database_manager_.get()) { |
| 680 PostFinishTask(UNKNOWN, REASON_SB_DISABLED); | 688 PostFinishTask(UNKNOWN, REASON_SB_DISABLED); |
| 681 return; | 689 return; |
| 682 } | 690 } |
| 683 | 691 |
| 684 const GURL& url = url_chain_.back(); | 692 const GURL& url = url_chain_.back(); |
| 685 // TODO(asanka): This may acquire a lock on the SB DB on the IO thread. | 693 // TODO(asanka): This may acquire a lock on the SB DB on the IO thread. |
| 686 if (url.is_valid() && database_manager_->MatchDownloadWhitelistUrl(url)) { | 694 if (url.is_valid() && database_manager_->MatchDownloadWhitelistUrl(url)) { |
| 687 DVLOG(2) << url << " is on the download whitelist."; | 695 DVLOG(2) << url << " is on the download whitelist."; |
| 688 RecordCountOfSignedOrWhitelistedDownload(); | 696 RecordCountOfWhitelistedDownload(URL_WHITELIST); |
| 689 // TODO(grt): Continue processing without uploading so that | 697 // TODO(grt): Continue processing without uploading so that |
| 690 // ClientDownloadRequest callbacks can be run even for this type of safe | 698 // ClientDownloadRequest callbacks can be run even for this type of safe |
| 691 // download. | 699 // download. |
| 692 PostFinishTask(SAFE, REASON_WHITELISTED_URL); | 700 PostFinishTask(SAFE, REASON_WHITELISTED_URL); |
| 693 return; | 701 return; |
| 694 } | 702 } |
| 695 | 703 |
| 696 if (signature_info_.trusted()) { | 704 if (signature_info_.trusted()) { |
| 697 RecordCountOfSignedOrWhitelistedDownload(); | |
| 698 for (int i = 0; i < signature_info_.certificate_chain_size(); ++i) { | 705 for (int i = 0; i < signature_info_.certificate_chain_size(); ++i) { |
| 699 if (CertificateChainIsWhitelisted( | 706 if (CertificateChainIsWhitelisted( |
| 700 signature_info_.certificate_chain(i))) { | 707 signature_info_.certificate_chain(i))) { |
| 708 RecordCountOfWhitelistedDownload(SIGNATURE_WHITELIST); |
| 701 // TODO(grt): Continue processing without uploading so that | 709 // TODO(grt): Continue processing without uploading so that |
| 702 // ClientDownloadRequest callbacks can be run even for this type of | 710 // ClientDownloadRequest callbacks can be run even for this type of |
| 703 // safe download. | 711 // safe download. |
| 704 PostFinishTask(SAFE, REASON_TRUSTED_EXECUTABLE); | 712 PostFinishTask(SAFE, REASON_TRUSTED_EXECUTABLE); |
| 705 return; | 713 return; |
| 706 } | 714 } |
| 707 } | 715 } |
| 708 } | 716 } |
| 709 | 717 |
| 710 if (!pingback_enabled_) { | 718 if (!pingback_enabled_) { |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1250 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1243 GURL url(kDownloadRequestUrl); | 1251 GURL url(kDownloadRequestUrl); |
| 1244 std::string api_key = google_apis::GetAPIKey(); | 1252 std::string api_key = google_apis::GetAPIKey(); |
| 1245 if (!api_key.empty()) | 1253 if (!api_key.empty()) |
| 1246 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1254 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1247 | 1255 |
| 1248 return url; | 1256 return url; |
| 1249 } | 1257 } |
| 1250 | 1258 |
| 1251 } // namespace safe_browsing | 1259 } // namespace safe_browsing |
| OLD | NEW |