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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
10 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
13 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
14 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
15 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/sparse_histogram.h" |
16 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
17 #include "base/sequenced_task_runner_helpers.h" | 20 #include "base/sequenced_task_runner_helpers.h" |
18 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
19 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
21 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
23 #include "base/task/cancelable_task_tracker.h" | 26 #include "base/task/cancelable_task_tracker.h" |
24 #include "base/threading/sequenced_worker_pool.h" | 27 #include "base/threading/sequenced_worker_pool.h" |
25 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 29 #include "build/build_config.h" |
26 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
28 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
30 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 34 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
31 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 35 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
32 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 36 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
33 #include "chrome/browser/ui/browser.h" | 37 #include "chrome/browser/ui/browser.h" |
34 #include "chrome/browser/ui/browser_list.h" | 38 #include "chrome/browser/ui/browser_list.h" |
35 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
(...skipping 20 matching lines...) Expand all Loading... |
56 #include "net/url_request/url_fetcher_delegate.h" | 60 #include "net/url_request/url_fetcher_delegate.h" |
57 #include "net/url_request/url_request_status.h" | 61 #include "net/url_request/url_request_status.h" |
58 | 62 |
59 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
60 #include "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h" | 64 #include "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h" |
61 #endif | 65 #endif |
62 | 66 |
63 using content::BrowserThread; | 67 using content::BrowserThread; |
64 | 68 |
65 namespace { | 69 namespace { |
66 static const int64 kDownloadRequestTimeoutMs = 7000; | 70 static const int64_t kDownloadRequestTimeoutMs = 7000; |
67 } // namespace | 71 } // namespace |
68 | 72 |
69 namespace safe_browsing { | 73 namespace safe_browsing { |
70 | 74 |
71 const char DownloadProtectionService::kDownloadRequestUrl[] = | 75 const char DownloadProtectionService::kDownloadRequestUrl[] = |
72 "https://sb-ssl.google.com/safebrowsing/clientreport/download"; | 76 "https://sb-ssl.google.com/safebrowsing/clientreport/download"; |
73 | 77 |
74 namespace { | 78 namespace { |
75 void RecordFileExtensionType(const base::FilePath& file) { | 79 void RecordFileExtensionType(const base::FilePath& file) { |
76 UMA_HISTOGRAM_SPARSE_SLOWLY( | 80 UMA_HISTOGRAM_SPARSE_SLOWLY( |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 | 1058 |
1055 void DownloadProtectionService::ParseManualBlacklistFlag() { | 1059 void DownloadProtectionService::ParseManualBlacklistFlag() { |
1056 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1060 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
1057 if (!command_line->HasSwitch(switches::kSbManualDownloadBlacklist)) | 1061 if (!command_line->HasSwitch(switches::kSbManualDownloadBlacklist)) |
1058 return; | 1062 return; |
1059 | 1063 |
1060 std::string flag_val = | 1064 std::string flag_val = |
1061 command_line->GetSwitchValueASCII(switches::kSbManualDownloadBlacklist); | 1065 command_line->GetSwitchValueASCII(switches::kSbManualDownloadBlacklist); |
1062 for (const std::string& hash_hex : base::SplitString( | 1066 for (const std::string& hash_hex : base::SplitString( |
1063 flag_val, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | 1067 flag_val, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
1064 std::vector<uint8> bytes; | 1068 std::vector<uint8_t> bytes; |
1065 if (base::HexStringToBytes(hash_hex, &bytes) && bytes.size() == 32) { | 1069 if (base::HexStringToBytes(hash_hex, &bytes) && bytes.size() == 32) { |
1066 manual_blacklist_hashes_.insert( | 1070 manual_blacklist_hashes_.insert( |
1067 std::string(bytes.begin(), bytes.end())); | 1071 std::string(bytes.begin(), bytes.end())); |
1068 } else { | 1072 } else { |
1069 LOG(FATAL) << "Bad sha256 hex value '" << hash_hex << "' found in --" | 1073 LOG(FATAL) << "Bad sha256 hex value '" << hash_hex << "' found in --" |
1070 << switches::kSbManualDownloadBlacklist; | 1074 << switches::kSbManualDownloadBlacklist; |
1071 } | 1075 } |
1072 } | 1076 } |
1073 } | 1077 } |
1074 | 1078 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1241 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
1238 GURL url(kDownloadRequestUrl); | 1242 GURL url(kDownloadRequestUrl); |
1239 std::string api_key = google_apis::GetAPIKey(); | 1243 std::string api_key = google_apis::GetAPIKey(); |
1240 if (!api_key.empty()) | 1244 if (!api_key.empty()) |
1241 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1245 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
1242 | 1246 |
1243 return url; | 1247 return url; |
1244 } | 1248 } |
1245 | 1249 |
1246 } // namespace safe_browsing | 1250 } // namespace safe_browsing |
OLD | NEW |