Chromium Code Reviews| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/task/cancelable_task_tracker.h" | 19 #include "base/task/cancelable_task_tracker.h" |
| 20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "chrome/browser/browser_process.h" | |
| 22 #include "chrome/browser/history/history_service.h" | 23 #include "chrome/browser/history/history_service.h" |
| 23 #include "chrome/browser/history/history_service_factory.h" | 24 #include "chrome/browser/history/history_service_factory.h" |
| 24 #include "chrome/browser/safe_browsing/binary_feature_extractor.h" | 25 #include "chrome/browser/safe_browsing/binary_feature_extractor.h" |
| 25 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 26 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
| 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 27 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 28 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
| 28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
| 30 #include "chrome/common/safe_browsing/csd.pb.h" | 31 #include "chrome/common/safe_browsing/csd.pb.h" |
| 31 #include "chrome/common/safe_browsing/download_protection_util.h" | 32 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 32 #include "chrome/common/safe_browsing/zip_analyzer.h" | 33 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 33 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 35 #include "components/google/core/browser/google_util.h" | |
| 34 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/download_item.h" | 37 #include "content/public/browser/download_item.h" |
| 36 #include "content/public/browser/page_navigator.h" | 38 #include "content/public/browser/page_navigator.h" |
| 37 #include "google_apis/google_api_keys.h" | 39 #include "google_apis/google_api_keys.h" |
| 38 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
| 39 #include "net/base/load_flags.h" | 41 #include "net/base/load_flags.h" |
| 40 #include "net/cert/x509_cert_types.h" | 42 #include "net/cert/x509_cert_types.h" |
| 41 #include "net/cert/x509_certificate.h" | 43 #include "net/cert/x509_certificate.h" |
| 42 #include "net/http/http_status_code.h" | 44 #include "net/http/http_status_code.h" |
| 43 #include "net/url_request/url_fetcher.h" | 45 #include "net/url_request/url_fetcher.h" |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 953 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 952 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = | 954 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = |
| 953 download_requests_.find(request); | 955 download_requests_.find(request); |
| 954 DCHECK(it != download_requests_.end()); | 956 DCHECK(it != download_requests_.end()); |
| 955 download_requests_.erase(*it); | 957 download_requests_.erase(*it); |
| 956 } | 958 } |
| 957 | 959 |
| 958 void DownloadProtectionService::ShowDetailsForDownload( | 960 void DownloadProtectionService::ShowDetailsForDownload( |
| 959 const content::DownloadItem& item, | 961 const content::DownloadItem& item, |
| 960 content::PageNavigator* navigator) { | 962 content::PageNavigator* navigator) { |
| 961 GURL learn_more_url(chrome::kDownloadScanningLearnMoreURL); | 963 GURL learn_more_url(chrome::kDownloadScanningLearnMoreURL); |
|
mattm
2014/08/28 21:07:58
This one doesn't seem to work, I think the redirec
felt
2014/08/28 21:54:22
I filed a help center bug to get the redirect to s
| |
| 964 learn_more_url = google_util::AppendGoogleLocaleParam( | |
| 965 learn_more_url, g_browser_process->GetApplicationLocale()); | |
| 962 navigator->OpenURL( | 966 navigator->OpenURL( |
| 963 content::OpenURLParams(learn_more_url, | 967 content::OpenURLParams(learn_more_url, |
| 964 content::Referrer(), | 968 content::Referrer(), |
| 965 NEW_FOREGROUND_TAB, | 969 NEW_FOREGROUND_TAB, |
| 966 content::PAGE_TRANSITION_LINK, | 970 content::PAGE_TRANSITION_LINK, |
| 967 false)); | 971 false)); |
| 968 } | 972 } |
| 969 | 973 |
| 970 namespace { | 974 namespace { |
| 971 // Escapes a certificate attribute so that it can be used in a whitelist | 975 // Escapes a certificate attribute so that it can be used in a whitelist |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1046 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1050 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1047 GURL url(kDownloadRequestUrl); | 1051 GURL url(kDownloadRequestUrl); |
| 1048 std::string api_key = google_apis::GetAPIKey(); | 1052 std::string api_key = google_apis::GetAPIKey(); |
| 1049 if (!api_key.empty()) | 1053 if (!api_key.empty()) |
| 1050 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1054 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1051 | 1055 |
| 1052 return url; | 1056 return url; |
| 1053 } | 1057 } |
| 1054 | 1058 |
| 1055 } // namespace safe_browsing | 1059 } // namespace safe_browsing |
| OLD | NEW |