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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 } | 563 } |
564 OnFileFeatureExtractionDone(); | 564 OnFileFeatureExtractionDone(); |
565 } | 565 } |
566 | 566 |
567 void CheckWhitelists() { | 567 void CheckWhitelists() { |
568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
569 DownloadCheckResultReason reason = REASON_MAX; | 569 DownloadCheckResultReason reason = REASON_MAX; |
570 if (!database_manager_.get()) { | 570 if (!database_manager_.get()) { |
571 reason = REASON_SB_DISABLED; | 571 reason = REASON_SB_DISABLED; |
572 } else { | 572 } else { |
573 for (size_t i = 0; i < url_chain_.size(); ++i) { | 573 const GURL& url = url_chain_.back(); |
574 const GURL& url = url_chain_[i]; | 574 if (url.is_valid() && database_manager_->MatchDownloadWhitelistUrl(url)) { |
575 if (url.is_valid() && | 575 VLOG(2) << url << " is on the download whitelist."; |
576 database_manager_->MatchDownloadWhitelistUrl(url)) { | 576 reason = REASON_WHITELISTED_URL; |
577 VLOG(2) << url << " is on the download whitelist."; | |
578 reason = REASON_WHITELISTED_URL; | |
579 break; | |
580 } | |
581 } | |
582 if (referrer_url_.is_valid() && reason == REASON_MAX && | |
583 database_manager_->MatchDownloadWhitelistUrl( | |
584 referrer_url_)) { | |
585 VLOG(2) << "Referrer url " << referrer_url_ | |
586 << " is on the download whitelist."; | |
587 reason = REASON_WHITELISTED_REFERRER; | |
588 } | 577 } |
589 if (reason != REASON_MAX || signature_info_.trusted()) { | 578 if (reason != REASON_MAX || signature_info_.trusted()) { |
590 UMA_HISTOGRAM_COUNTS("SBClientDownload.SignedOrWhitelistedDownload", 1); | 579 UMA_HISTOGRAM_COUNTS("SBClientDownload.SignedOrWhitelistedDownload", 1); |
591 } | 580 } |
592 } | 581 } |
593 if (reason == REASON_MAX && signature_info_.trusted()) { | 582 if (reason == REASON_MAX && signature_info_.trusted()) { |
594 for (int i = 0; i < signature_info_.certificate_chain_size(); ++i) { | 583 for (int i = 0; i < signature_info_.certificate_chain_size(); ++i) { |
595 if (CertificateChainIsWhitelisted( | 584 if (CertificateChainIsWhitelisted( |
596 signature_info_.certificate_chain(i))) { | 585 signature_info_.certificate_chain(i))) { |
597 reason = REASON_TRUSTED_EXECUTABLE; | 586 reason = REASON_TRUSTED_EXECUTABLE; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 956 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
968 GURL url(kDownloadRequestUrl); | 957 GURL url(kDownloadRequestUrl); |
969 std::string api_key = google_apis::GetAPIKey(); | 958 std::string api_key = google_apis::GetAPIKey(); |
970 if (!api_key.empty()) | 959 if (!api_key.empty()) |
971 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 960 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
972 | 961 |
973 return url; | 962 return url; |
974 } | 963 } |
975 | 964 |
976 } // namespace safe_browsing | 965 } // namespace safe_browsing |
OLD | NEW |