| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/safe_browsing_db/v4_protocol_manager_util.h" | 5 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "build/build_config.h" |
| 13 #include "crypto/sha2.h" | 14 #include "crypto/sha2.h" |
| 14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 15 #include "net/base/ip_address.h" | 16 #include "net/base/ip_address.h" |
| 16 #include "net/http/http_request_headers.h" | 17 #include "net/http/http_request_headers.h" |
| 17 #include "url/url_util.h" | 18 #include "url/url_util.h" |
| 18 | 19 |
| 19 using base::Time; | 20 using base::Time; |
| 20 using base::TimeDelta; | 21 using base::TimeDelta; |
| 21 | 22 |
| 22 namespace safe_browsing { | 23 namespace safe_browsing { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 } // namespace | 65 } // namespace |
| 65 | 66 |
| 66 std::ostream& operator<<(std::ostream& os, const ListIdentifier& id) { | 67 std::ostream& operator<<(std::ostream& os, const ListIdentifier& id) { |
| 67 os << "{hash: " << id.hash() << "; platform_type: " << id.platform_type() | 68 os << "{hash: " << id.hash() << "; platform_type: " << id.platform_type() |
| 68 << "; threat_entry_type: " << id.threat_entry_type() | 69 << "; threat_entry_type: " << id.threat_entry_type() |
| 69 << "; threat_type: " << id.threat_type() << "}"; | 70 << "; threat_type: " << id.threat_type() << "}"; |
| 70 return os; | 71 return os; |
| 71 } | 72 } |
| 72 | 73 |
| 74 bool EnableInternalLists() { |
| 75 #if defined(GOOGLE_CHROME_BUILD) |
| 76 return true; |
| 77 #else |
| 78 return false; |
| 79 #endif |
| 80 } |
| 81 |
| 73 PlatformType GetCurrentPlatformType() { | 82 PlatformType GetCurrentPlatformType() { |
| 74 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 75 return WINDOWS_PLATFORM; | 84 return WINDOWS_PLATFORM; |
| 76 #elif defined(OS_LINUX) | 85 #elif defined(OS_LINUX) |
| 77 return LINUX_PLATFORM; | 86 return LINUX_PLATFORM; |
| 78 #elif defined(OS_MACOSX) | 87 #elif defined(OS_MACOSX) |
| 79 return OSX_PLATFORM; | 88 return OSX_PLATFORM; |
| 80 #else | 89 #else |
| 81 // This should ideally never compile but it is getting compiled on Android. | 90 // This should ideally never compile but it is getting compiled on Android. |
| 82 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647 | 91 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647 |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 586 |
| 578 const std::string hash = base::SHA1HashString(packed_ip); | 587 const std::string hash = base::SHA1HashString(packed_ip); |
| 579 DCHECK_EQ(20u, hash.size()); | 588 DCHECK_EQ(20u, hash.size()); |
| 580 hashed_encoded_ip->resize(hash.size() + 1); | 589 hashed_encoded_ip->resize(hash.size() + 1); |
| 581 hashed_encoded_ip->replace(0, hash.size(), hash); | 590 hashed_encoded_ip->replace(0, hash.size(), hash); |
| 582 (*hashed_encoded_ip)[hash.size()] = static_cast<unsigned char>(128); | 591 (*hashed_encoded_ip)[hash.size()] = static_cast<unsigned char>(128); |
| 583 return true; | 592 return true; |
| 584 } | 593 } |
| 585 | 594 |
| 586 } // namespace safe_browsing | 595 } // namespace safe_browsing |
| OLD | NEW |