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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 reason = REASON_DOWNLOAD_NOT_SUPPORTED; | 410 reason = REASON_DOWNLOAD_NOT_SUPPORTED; |
411 } else if (response.verdict() == ClientDownloadResponse::DANGEROUS) { | 411 } else if (response.verdict() == ClientDownloadResponse::DANGEROUS) { |
412 reason = REASON_DOWNLOAD_DANGEROUS; | 412 reason = REASON_DOWNLOAD_DANGEROUS; |
413 result = DANGEROUS; | 413 result = DANGEROUS; |
414 } else if (response.verdict() == ClientDownloadResponse::UNCOMMON) { | 414 } else if (response.verdict() == ClientDownloadResponse::UNCOMMON) { |
415 reason = REASON_DOWNLOAD_UNCOMMON; | 415 reason = REASON_DOWNLOAD_UNCOMMON; |
416 result = UNCOMMON; | 416 result = UNCOMMON; |
417 } else if (response.verdict() == ClientDownloadResponse::DANGEROUS_HOST) { | 417 } else if (response.verdict() == ClientDownloadResponse::DANGEROUS_HOST) { |
418 reason = REASON_DOWNLOAD_DANGEROUS_HOST; | 418 reason = REASON_DOWNLOAD_DANGEROUS_HOST; |
419 result = DANGEROUS_HOST; | 419 result = DANGEROUS_HOST; |
| 420 } else if ( |
| 421 response.verdict() == ClientDownloadResponse::POTENTIALLY_UNWANTED) { |
| 422 reason = REASON_DOWNLOAD_POTENTIALLY_UNWANTED; |
| 423 result = POTENTIALLY_UNWANTED; |
420 } else { | 424 } else { |
421 LOG(DFATAL) << "Unknown download response verdict: " | 425 LOG(DFATAL) << "Unknown download response verdict: " |
422 << response.verdict(); | 426 << response.verdict(); |
423 reason = REASON_INVALID_RESPONSE_VERDICT; | 427 reason = REASON_INVALID_RESPONSE_VERDICT; |
424 } | 428 } |
425 DownloadFeedbackService::MaybeStorePingsForDownload( | 429 DownloadFeedbackService::MaybeStorePingsForDownload( |
426 result, item_, client_download_request_data_, data); | 430 result, item_, client_download_request_data_, data); |
427 } | 431 } |
428 // We don't need the fetcher anymore. | 432 // We don't need the fetcher anymore. |
429 fetcher_.reset(); | 433 fetcher_.reset(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
858 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = | 862 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = |
859 download_requests_.find(request); | 863 download_requests_.find(request); |
860 DCHECK(it != download_requests_.end()); | 864 DCHECK(it != download_requests_.end()); |
861 download_requests_.erase(*it); | 865 download_requests_.erase(*it); |
862 } | 866 } |
863 | 867 |
864 void DownloadProtectionService::ShowDetailsForDownload( | 868 void DownloadProtectionService::ShowDetailsForDownload( |
865 const content::DownloadItem& item, | 869 const content::DownloadItem& item, |
866 content::PageNavigator* navigator) { | 870 content::PageNavigator* navigator) { |
| 871 GURL learn_more_url(chrome::kDownloadScanningLearnMoreURL); |
| 872 if (item.GetDangerType() == |
| 873 content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) |
| 874 learn_more_url = GURL(chrome::kDownloadPotentiallyUnwantedLearnMoreURL); |
867 navigator->OpenURL( | 875 navigator->OpenURL( |
868 content::OpenURLParams(GURL(chrome::kDownloadScanningLearnMoreURL), | 876 content::OpenURLParams(learn_more_url, |
869 content::Referrer(), | 877 content::Referrer(), |
870 NEW_FOREGROUND_TAB, | 878 NEW_FOREGROUND_TAB, |
871 content::PAGE_TRANSITION_LINK, | 879 content::PAGE_TRANSITION_LINK, |
872 false)); | 880 false)); |
873 } | 881 } |
874 | 882 |
875 namespace { | 883 namespace { |
876 // Escapes a certificate attribute so that it can be used in a whitelist | 884 // Escapes a certificate attribute so that it can be used in a whitelist |
877 // entry. Currently, we only escape slashes, since they are used as a | 885 // entry. Currently, we only escape slashes, since they are used as a |
878 // separator between attributes. | 886 // separator between attributes. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 std::string url = kDownloadRequestUrl; | 960 std::string url = kDownloadRequestUrl; |
953 std::string api_key = google_apis::GetAPIKey(); | 961 std::string api_key = google_apis::GetAPIKey(); |
954 if (!api_key.empty()) { | 962 if (!api_key.empty()) { |
955 base::StringAppendF(&url, "?key=%s", | 963 base::StringAppendF(&url, "?key=%s", |
956 net::EscapeQueryParamValue(api_key, true).c_str()); | 964 net::EscapeQueryParamValue(api_key, true).c_str()); |
957 } | 965 } |
958 return url; | 966 return url; |
959 } | 967 } |
960 | 968 |
961 } // namespace safe_browsing | 969 } // namespace safe_browsing |
OLD | NEW |