| 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 return; | 663 return; |
| 664 } | 664 } |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 if (!pingback_enabled_) { | 668 if (!pingback_enabled_) { |
| 669 PostFinishTask(UNKNOWN, REASON_PING_DISABLED); | 669 PostFinishTask(UNKNOWN, REASON_PING_DISABLED); |
| 670 return; | 670 return; |
| 671 } | 671 } |
| 672 | 672 |
| 673 // Currently, the UI is only enabled on Windows and OSX so we don't even | 673 // Currently, the UI is enabled on Windows, OSX and chrome OS. we don't ping |
| 674 // bother with pinging the server if we're not on one of those platforms. | 674 // the server if we're not on one of those platforms. |
| 675 // TODO(noelutz): change this code once the UI is done for Linux. | 675 // TODO(noelutz): change this code once the UI is done for Linux. |
| 676 #if defined(OS_WIN) || defined(OS_MACOSX) | 676 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 677 // The URLFetcher is owned by the UI thread, so post a message to | 677 // The URLFetcher is owned by the UI thread, so post a message to |
| 678 // start the pingback. | 678 // start the pingback. |
| 679 BrowserThread::PostTask( | 679 BrowserThread::PostTask( |
| 680 BrowserThread::UI, | 680 BrowserThread::UI, |
| 681 FROM_HERE, | 681 FROM_HERE, |
| 682 base::Bind(&CheckClientDownloadRequest::GetTabRedirects, this)); | 682 base::Bind(&CheckClientDownloadRequest::GetTabRedirects, this)); |
| 683 #else | 683 #else |
| 684 PostFinishTask(UNKNOWN, REASON_OS_NOT_SUPPORTED); | 684 PostFinishTask(UNKNOWN, REASON_OS_NOT_SUPPORTED); |
| 685 #endif | 685 #endif |
| 686 } | 686 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 // The client will release itself once it is done. | 1011 // The client will release itself once it is done. |
| 1012 BrowserThread::PostTask( | 1012 BrowserThread::PostTask( |
| 1013 BrowserThread::IO, | 1013 BrowserThread::IO, |
| 1014 FROM_HERE, | 1014 FROM_HERE, |
| 1015 base::Bind(&DownloadUrlSBClient::StartCheck, client)); | 1015 base::Bind(&DownloadUrlSBClient::StartCheck, client)); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 bool DownloadProtectionService::IsSupportedDownload( | 1018 bool DownloadProtectionService::IsSupportedDownload( |
| 1019 const content::DownloadItem& item, | 1019 const content::DownloadItem& item, |
| 1020 const base::FilePath& target_path) const { | 1020 const base::FilePath& target_path) const { |
| 1021 // Currently, the UI is only enabled on Windows and OSX. On Linux we still | 1021 // Currently, the UI is only enabled on Windows, OSX and Chrome OS. On |
| 1022 // want to show the dangerous file type warning if the file is possibly | 1022 // Linux we still want to show the dangerous file type warning if the file |
| 1023 // dangerous which means we have to always return false here. | 1023 // is possibly dangerous which means we have to always return false here. |
| 1024 #if defined(OS_WIN) || defined(OS_MACOSX) | 1024 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 1025 DownloadCheckResultReason reason = REASON_MAX; | 1025 DownloadCheckResultReason reason = REASON_MAX; |
| 1026 ClientDownloadRequest::DownloadType type = | 1026 ClientDownloadRequest::DownloadType type = |
| 1027 ClientDownloadRequest::WIN_EXECUTABLE; | 1027 ClientDownloadRequest::WIN_EXECUTABLE; |
| 1028 return (CheckClientDownloadRequest::IsSupportedDownload( | 1028 return (CheckClientDownloadRequest::IsSupportedDownload( |
| 1029 item, target_path, &reason, &type) && | 1029 item, target_path, &reason, &type) && |
| 1030 (ClientDownloadRequest::CHROME_EXTENSION != type)); | 1030 (ClientDownloadRequest::CHROME_EXTENSION != type)); |
| 1031 #else | 1031 #else |
| 1032 return false; | 1032 return false; |
| 1033 #endif | 1033 #endif |
| 1034 } | 1034 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1158 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1159 GURL url(kDownloadRequestUrl); | 1159 GURL url(kDownloadRequestUrl); |
| 1160 std::string api_key = google_apis::GetAPIKey(); | 1160 std::string api_key = google_apis::GetAPIKey(); |
| 1161 if (!api_key.empty()) | 1161 if (!api_key.empty()) |
| 1162 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1162 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1163 | 1163 |
| 1164 return url; | 1164 return url; |
| 1165 } | 1165 } |
| 1166 | 1166 |
| 1167 } // namespace safe_browsing | 1167 } // namespace safe_browsing |
| OLD | NEW |