OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SSL_ERROR_INFO_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_ |
6 #define COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_ | 6 #define CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "net/cert/cert_status_flags.h" | 12 #include "net/cert/cert_status_flags.h" |
13 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace ssl_errors { | |
18 | |
19 // This class describes an error that happened while showing a page over SSL. | 17 // This class describes an error that happened while showing a page over SSL. |
20 // An ErrorInfo object only exists on the UI thread and only contains | 18 // An SSLErrorInfo object only exists on the UI thread and only contains |
21 // information about an error (type of error and text details). | 19 // information about an error (type of error and text details). |
22 // Note no DISALLOW_COPY_AND_ASSIGN as we want the copy constructor. | 20 // Note no DISALLOW_COPY_AND_ASSIGN as we want the copy constructor. |
23 class ErrorInfo { | 21 class SSLErrorInfo { |
24 public: | 22 public: |
25 // This enum is being histogrammed; please only add new values at the end. | 23 // This enum is being histogrammed; please only add new values at the end. |
26 enum ErrorType { | 24 enum ErrorType { |
27 CERT_COMMON_NAME_INVALID = 0, | 25 CERT_COMMON_NAME_INVALID = 0, |
28 CERT_DATE_INVALID, | 26 CERT_DATE_INVALID, |
29 CERT_AUTHORITY_INVALID, | 27 CERT_AUTHORITY_INVALID, |
30 CERT_CONTAINS_ERRORS, | 28 CERT_CONTAINS_ERRORS, |
31 CERT_NO_REVOCATION_MECHANISM, | 29 CERT_NO_REVOCATION_MECHANISM, |
32 CERT_UNABLE_TO_CHECK_REVOCATION, | 30 CERT_UNABLE_TO_CHECK_REVOCATION, |
33 CERT_REVOKED, | 31 CERT_REVOKED, |
34 CERT_INVALID, | 32 CERT_INVALID, |
35 CERT_WEAK_SIGNATURE_ALGORITHM, | 33 CERT_WEAK_SIGNATURE_ALGORITHM, |
36 CERT_WEAK_KEY, | 34 CERT_WEAK_KEY, |
37 CERT_NAME_CONSTRAINT_VIOLATION, | 35 CERT_NAME_CONSTRAINT_VIOLATION, |
38 UNKNOWN, | 36 UNKNOWN, |
39 CERT_WEAK_KEY_DH, | 37 CERT_WEAK_KEY_DH, |
40 CERT_PINNED_KEY_MISSING, | 38 CERT_PINNED_KEY_MISSING, |
41 CERT_VALIDITY_TOO_LONG, | 39 CERT_VALIDITY_TOO_LONG, |
42 END_OF_ENUM | 40 END_OF_ENUM |
43 }; | 41 }; |
44 | 42 |
45 virtual ~ErrorInfo(); | 43 virtual ~SSLErrorInfo(); |
46 | 44 |
47 // Converts a network error code to an ErrorType. | 45 // Converts a network error code to an ErrorType. |
48 static ErrorType NetErrorToErrorType(int net_error); | 46 static ErrorType NetErrorToErrorType(int net_error); |
49 | 47 |
50 static ErrorInfo CreateError(ErrorType error_type, | 48 static SSLErrorInfo CreateError(ErrorType error_type, |
51 net::X509Certificate* cert, | 49 net::X509Certificate* cert, |
52 const GURL& request_url); | 50 const GURL& request_url); |
53 | 51 |
54 // Populates the specified |errors| vector with the errors contained in | 52 // Populates the specified |errors| vector with the errors contained in |
55 // |cert_status| for |cert|. Returns the number of errors found. | 53 // |cert_status|. Returns the number of errors found. |
56 // Callers only interested in the error count can pass NULL for |errors|. | 54 // Callers only interested in the error count can pass NULL for |errors|. |
57 static void GetErrorsForCertStatus( | 55 // TODO(wtc): Document |cert_id| and |url| arguments. |
58 const scoped_refptr<net::X509Certificate>& cert, | 56 static void GetErrorsForCertStatus(int cert_id, |
59 net::CertStatus cert_status, | 57 net::CertStatus cert_status, |
60 const GURL& url, | 58 const GURL& url, |
61 std::vector<ErrorInfo>* errors); | 59 std::vector<SSLErrorInfo>* errors); |
62 | 60 |
63 // A description of the error. | 61 // A description of the error. |
64 const base::string16& details() const { return details_; } | 62 const base::string16& details() const { return details_; } |
65 | 63 |
66 // A short message describing the error (1 line). | 64 // A short message describing the error (1 line). |
67 const base::string16& short_description() const { return short_description_; } | 65 const base::string16& short_description() const { return short_description_; } |
68 | 66 |
69 private: | 67 private: |
70 ErrorInfo(const base::string16& details, | 68 SSLErrorInfo(const base::string16& details, |
71 const base::string16& short_description); | 69 const base::string16& short_description); |
72 | 70 |
73 base::string16 details_; | 71 base::string16 details_; |
74 base::string16 short_description_; | 72 base::string16 short_description_; |
75 }; | 73 }; |
76 | 74 |
77 } // namespace ssl_errors | 75 #endif // CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_ |
78 | |
79 #endif // COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_ | |
OLD | NEW |