| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 5 #ifndef COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
| 6 #define COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 6 #define COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void RecordUMAStatisticsForClockInterstitial(bool overridable, | 101 void RecordUMAStatisticsForClockInterstitial(bool overridable, |
| 102 ssl_errors::ClockState clock_state, | 102 ssl_errors::ClockState clock_state, |
| 103 int cert_error); | 103 int cert_error); |
| 104 | 104 |
| 105 // Helper methods for classification. ------------------------------------------ | 105 // Helper methods for classification. ------------------------------------------ |
| 106 | 106 |
| 107 // Tokenize DNS names and hostnames. | 107 // Tokenize DNS names and hostnames. |
| 108 HostnameTokens Tokenize(const std::string& name); | 108 HostnameTokens Tokenize(const std::string& name); |
| 109 | 109 |
| 110 // Sets a clock for browser tests that check the build time. Used by | 110 // Sets a clock for browser tests that check the build time. Used by |
| 111 // IsUserClockInThePast and IsUserClockInTheFuture. | 111 // GetClockState(). |
| 112 void SetBuildTimeForTesting(const base::Time& testing_time); | 112 void SetBuildTimeForTesting(const base::Time& testing_time); |
| 113 | 113 |
| 114 // Returns true if the hostname has a known Top Level Domain. | 114 // Returns true if the hostname has a known Top Level Domain. |
| 115 bool IsHostNameKnownTLD(const std::string& host_name); | 115 bool IsHostNameKnownTLD(const std::string& host_name); |
| 116 | 116 |
| 117 // Returns true if any one of the following conditions hold: | 117 // Returns true if any one of the following conditions hold: |
| 118 // 1.|hostname| is an IP Address in an IANA-reserved range. | 118 // 1.|hostname| is an IP Address in an IANA-reserved range. |
| 119 // 2.|hostname| is a not-yet-assigned by ICANN gTLD. | 119 // 2.|hostname| is a not-yet-assigned by ICANN gTLD. |
| 120 // 3.|hostname| is a dotless domain. | 120 // 3.|hostname| is a dotless domain. |
| 121 bool IsHostnameNonUniqueOrDotless(const std::string& hostname); | 121 bool IsHostnameNonUniqueOrDotless(const std::string& hostname); |
| 122 | 122 |
| 123 // Returns true if |child| is a subdomain of any of the |potential_parents|. | 123 // Returns true if |child| is a subdomain of any of the |potential_parents|. |
| 124 bool NameUnderAnyNames(const HostnameTokens& child, | 124 bool NameUnderAnyNames(const HostnameTokens& child, |
| 125 const std::vector<HostnameTokens>& potential_parents); | 125 const std::vector<HostnameTokens>& potential_parents); |
| 126 | 126 |
| 127 // Returns true if any of the |potential_children| is a subdomain of the | 127 // Returns true if any of the |potential_children| is a subdomain of the |
| 128 // |parent|. The inverse case should be treated carefully as this is most | 128 // |parent|. The inverse case should be treated carefully as this is most |
| 129 // likely a MITM attack. We don't want foo.appspot.com to be able to MITM for | 129 // likely a MITM attack. We don't want foo.appspot.com to be able to MITM for |
| 130 // appspot.com. | 130 // appspot.com. |
| 131 bool AnyNamesUnderName(const std::vector<HostnameTokens>& potential_children, | 131 bool AnyNamesUnderName(const std::vector<HostnameTokens>& potential_children, |
| 132 const HostnameTokens& parent); | 132 const HostnameTokens& parent); |
| 133 | 133 |
| 134 // Exposed for teshting. | 134 // Exposed for teshting. |
| 135 size_t GetLevenshteinDistance(const std::string& str1, const std::string& str2); | 135 size_t GetLevenshteinDistance(const std::string& str1, const std::string& str2); |
| 136 | 136 |
| 137 } // namespace ssl_errors | 137 } // namespace ssl_errors |
| 138 | 138 |
| 139 #endif // COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 139 #endif // COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
| OLD | NEW |