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> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/metrics/sparse_histogram.h" | 20 #include "base/metrics/sparse_histogram.h" |
21 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
22 #include "base/sequenced_task_runner_helpers.h" | 22 #include "base/sequenced_task_runner_helpers.h" |
| 23 #include "base/sha1.h" |
23 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
24 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
25 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" |
26 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
27 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
28 #include "base/task/cancelable_task_tracker.h" | 29 #include "base/task/cancelable_task_tracker.h" |
29 #include "base/threading/sequenced_worker_pool.h" | 30 #include "base/threading/sequenced_worker_pool.h" |
30 #include "base/time/time.h" | 31 #include "base/time/time.h" |
31 #include "build/build_config.h" | 32 #include "build/build_config.h" |
32 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 for (size_t j = 0; j < ou_tokens.size(); ++j) { | 1637 for (size_t j = 0; j < ou_tokens.size(); ++j) { |
1637 paths_to_check.insert(cn_token + o_tokens[i] + ou_tokens[j]); | 1638 paths_to_check.insert(cn_token + o_tokens[i] + ou_tokens[j]); |
1638 paths_to_check.insert(o_tokens[i] + ou_tokens[j]); | 1639 paths_to_check.insert(o_tokens[i] + ou_tokens[j]); |
1639 } | 1640 } |
1640 } | 1641 } |
1641 for (size_t i = 0; i < ou_tokens.size(); ++i) { | 1642 for (size_t i = 0; i < ou_tokens.size(); ++i) { |
1642 paths_to_check.insert(cn_token + ou_tokens[i]); | 1643 paths_to_check.insert(cn_token + ou_tokens[i]); |
1643 paths_to_check.insert(ou_tokens[i]); | 1644 paths_to_check.insert(ou_tokens[i]); |
1644 } | 1645 } |
1645 | 1646 |
1646 std::string issuer_fp = base::HexEncode(issuer.fingerprint().data, | 1647 std::string issuer_der; |
1647 sizeof(issuer.fingerprint().data)); | 1648 net::X509Certificate::GetDEREncoded(issuer.os_cert_handle(), &issuer_der); |
| 1649 std::string hashed = base::SHA1HashString(issuer_der); |
| 1650 std::string issuer_fp = base::HexEncode(hashed.data(), hashed.size()); |
1648 for (std::set<std::string>::iterator it = paths_to_check.begin(); | 1651 for (std::set<std::string>::iterator it = paths_to_check.begin(); |
1649 it != paths_to_check.end(); ++it) { | 1652 it != paths_to_check.end(); ++it) { |
1650 whitelist_strings->push_back("cert/" + issuer_fp + *it); | 1653 whitelist_strings->push_back("cert/" + issuer_fp + *it); |
1651 } | 1654 } |
1652 } | 1655 } |
1653 | 1656 |
1654 // static | 1657 // static |
1655 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1658 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
1656 GURL url(kDownloadRequestUrl); | 1659 GURL url(kDownloadRequestUrl); |
1657 std::string api_key = google_apis::GetAPIKey(); | 1660 std::string api_key = google_apis::GetAPIKey(); |
1658 if (!api_key.empty()) | 1661 if (!api_key.empty()) |
1659 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1662 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
1660 | 1663 |
1661 return url; | 1664 return url; |
1662 } | 1665 } |
1663 | 1666 |
1664 } // namespace safe_browsing | 1667 } // namespace safe_browsing |
OLD | NEW |