| 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 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 for (size_t j = 0; j < ou_tokens.size(); ++j) { | 1669 for (size_t j = 0; j < ou_tokens.size(); ++j) { |
| 1669 paths_to_check.insert(cn_token + o_tokens[i] + ou_tokens[j]); | 1670 paths_to_check.insert(cn_token + o_tokens[i] + ou_tokens[j]); |
| 1670 paths_to_check.insert(o_tokens[i] + ou_tokens[j]); | 1671 paths_to_check.insert(o_tokens[i] + ou_tokens[j]); |
| 1671 } | 1672 } |
| 1672 } | 1673 } |
| 1673 for (size_t i = 0; i < ou_tokens.size(); ++i) { | 1674 for (size_t i = 0; i < ou_tokens.size(); ++i) { |
| 1674 paths_to_check.insert(cn_token + ou_tokens[i]); | 1675 paths_to_check.insert(cn_token + ou_tokens[i]); |
| 1675 paths_to_check.insert(ou_tokens[i]); | 1676 paths_to_check.insert(ou_tokens[i]); |
| 1676 } | 1677 } |
| 1677 | 1678 |
| 1678 std::string issuer_fp = base::HexEncode(issuer.fingerprint().data, | 1679 std::string issuer_der; |
| 1679 sizeof(issuer.fingerprint().data)); | 1680 net::X509Certificate::GetDEREncoded(issuer.os_cert_handle(), &issuer_der); |
| 1681 std::string hashed = base::SHA1HashString(issuer_der); |
| 1682 std::string issuer_fp = base::HexEncode(hashed.data(), hashed.size()); |
| 1680 for (std::set<std::string>::iterator it = paths_to_check.begin(); | 1683 for (std::set<std::string>::iterator it = paths_to_check.begin(); |
| 1681 it != paths_to_check.end(); ++it) { | 1684 it != paths_to_check.end(); ++it) { |
| 1682 whitelist_strings->push_back("cert/" + issuer_fp + *it); | 1685 whitelist_strings->push_back("cert/" + issuer_fp + *it); |
| 1683 } | 1686 } |
| 1684 } | 1687 } |
| 1685 | 1688 |
| 1686 // static | 1689 // static |
| 1687 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1690 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1688 GURL url(kDownloadRequestUrl); | 1691 GURL url(kDownloadRequestUrl); |
| 1689 std::string api_key = google_apis::GetAPIKey(); | 1692 std::string api_key = google_apis::GetAPIKey(); |
| 1690 if (!api_key.empty()) | 1693 if (!api_key.empty()) |
| 1691 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1694 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1692 | 1695 |
| 1693 return url; | 1696 return url; |
| 1694 } | 1697 } |
| 1695 | 1698 |
| 1696 } // namespace safe_browsing | 1699 } // namespace safe_browsing |
| OLD | NEW |