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 |
11 namespace base { | 11 namespace base { |
12 class Time; | 12 class Time; |
13 } | 13 } |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class X509Certificate; | 18 class X509Certificate; |
19 } | 19 } |
20 | 20 |
21 namespace network_time { | |
22 class NetworkTimeTracker; | |
23 } | |
24 | |
21 namespace ssl_errors { | 25 namespace ssl_errors { |
22 | 26 |
23 typedef std::vector<std::string> HostnameTokens; | 27 typedef std::vector<std::string> HostnameTokens; |
24 | 28 |
25 // Methods for identifying specific error causes. ------------------------------ | 29 // Methods for identifying specific error causes. ------------------------------ |
26 | 30 |
27 // Returns true if the system time is in the past. | 31 // Returns true if the system time is in the past. |
28 bool IsUserClockInThePast(const base::Time& time_now); | 32 bool IsUserClockAhead(const base::Time& time_now, |
estark
2016/03/08 23:17:36
My brain might not be doing logic correctly but it
estark
2016/03/08 23:17:36
Can you name these |now_system|, like you did in t
mab
2016/03/09 23:35:28
I changed it to be shorter, but I've changed it ba
mab
2016/03/09 23:35:28
Done.
| |
33 const network_time::NetworkTimeTracker* network_time); | |
29 | 34 |
30 // Returns true if the system time is too far in the future or the user is | 35 // Returns true if the system time is too far in the future or the user is |
31 // using a version of Chrome which is more than 1 year old. | 36 // using a version of Chrome which is more than 1 year old. |
32 bool IsUserClockInTheFuture(const base::Time& time_now); | 37 bool IsUserClockBehind(const base::Time& time_now, |
38 const network_time::NetworkTimeTracker* network_time); | |
33 | 39 |
34 // Returns true if |hostname| is too broad for the scope of a wildcard | 40 // Returns true if |hostname| is too broad for the scope of a wildcard |
35 // certificate. E.g.: | 41 // certificate. E.g.: |
36 // a.b.example.com ~ *.example.com --> true | 42 // a.b.example.com ~ *.example.com --> true |
37 // b.example.com ~ *.example.com --> false | 43 // b.example.com ~ *.example.com --> false |
38 bool IsSubDomainOutsideWildcard(const GURL& request_url, | 44 bool IsSubDomainOutsideWildcard(const GURL& request_url, |
39 const net::X509Certificate& cert); | 45 const net::X509Certificate& cert); |
40 | 46 |
41 // Returns true if the certificate is a shared certificate. Note - This | 47 // Returns true if the certificate is a shared certificate. Note - This |
42 // function should be used with caution (only for UMA histogram) as an | 48 // function should be used with caution (only for UMA histogram) as an |
(...skipping 17 matching lines...) Expand all Loading... | |
60 // www.food.example.com ~ example.com -> false | 66 // www.food.example.com ~ example.com -> false |
61 // mail.example.com ~ example.com -> false | 67 // mail.example.com ~ example.com -> false |
62 bool GetWWWSubDomainMatch(const GURL& request_url, | 68 bool GetWWWSubDomainMatch(const GURL& request_url, |
63 const std::vector<std::string>& dns_names, | 69 const std::vector<std::string>& dns_names, |
64 std::string* www_match_host_name); | 70 std::string* www_match_host_name); |
65 | 71 |
66 // Method for recording results. ----------------------------------------------- | 72 // Method for recording results. ----------------------------------------------- |
67 | 73 |
68 void RecordUMAStatistics(bool overridable, | 74 void RecordUMAStatistics(bool overridable, |
69 const base::Time& current_time, | 75 const base::Time& current_time, |
76 const network_time::NetworkTimeTracker* network_time, | |
70 const GURL& request_url, | 77 const GURL& request_url, |
71 int cert_error, | 78 int cert_error, |
72 const net::X509Certificate& cert); | 79 const net::X509Certificate& cert); |
73 | 80 |
74 // Helper methods for classification. ------------------------------------------ | 81 // Helper methods for classification. ------------------------------------------ |
75 | 82 |
76 // Tokenize DNS names and hostnames. | 83 // Tokenize DNS names and hostnames. |
77 HostnameTokens Tokenize(const std::string& name); | 84 HostnameTokens Tokenize(const std::string& name); |
78 | 85 |
79 // Sets a clock for browser tests that check the build time. Used by | 86 // Sets a clock for browser tests that check the build time. Used by |
(...skipping 19 matching lines...) Expand all Loading... | |
99 // appspot.com. | 106 // appspot.com. |
100 bool AnyNamesUnderName(const std::vector<HostnameTokens>& potential_children, | 107 bool AnyNamesUnderName(const std::vector<HostnameTokens>& potential_children, |
101 const HostnameTokens& parent); | 108 const HostnameTokens& parent); |
102 | 109 |
103 // Exposed for teshting. | 110 // Exposed for teshting. |
104 size_t GetLevenshteinDistance(const std::string& str1, const std::string& str2); | 111 size_t GetLevenshteinDistance(const std::string& str1, const std::string& str2); |
105 | 112 |
106 } // namespace ssl_errors | 113 } // namespace ssl_errors |
107 | 114 |
108 #endif // COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 115 #endif // COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
OLD | NEW |