Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / ssl / ssl_error_info.h
blob0ffd5539826ccd56f3d17cde61933dd43636c0f9
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_
6 #define CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_
8 #include <string>
9 #include <vector>
11 #include "base/strings/string16.h"
12 #include "net/cert/cert_status_flags.h"
13 #include "net/cert/x509_certificate.h"
15 class GURL;
17 // This class describes an error that happened while showing a page over SSL.
18 // An SSLErrorInfo object only exists on the UI thread and only contains
19 // information about an error (type of error and text details).
20 // Note no DISALLOW_COPY_AND_ASSIGN as we want the copy constructor.
21 class SSLErrorInfo {
22 public:
23 // This enum is being histogrammed; please only add new values at the end.
24 enum ErrorType {
25 CERT_COMMON_NAME_INVALID = 0,
26 CERT_DATE_INVALID,
27 CERT_AUTHORITY_INVALID,
28 CERT_CONTAINS_ERRORS,
29 CERT_NO_REVOCATION_MECHANISM,
30 CERT_UNABLE_TO_CHECK_REVOCATION,
31 CERT_REVOKED,
32 CERT_INVALID,
33 CERT_WEAK_SIGNATURE_ALGORITHM,
34 CERT_WEAK_KEY,
35 CERT_NAME_CONSTRAINT_VIOLATION,
36 UNKNOWN,
37 CERT_WEAK_KEY_DH,
38 CERT_PINNED_KEY_MISSING,
39 CERT_VALIDITY_TOO_LONG,
40 END_OF_ENUM
43 virtual ~SSLErrorInfo();
45 // Converts a network error code to an ErrorType.
46 static ErrorType NetErrorToErrorType(int net_error);
48 static SSLErrorInfo CreateError(ErrorType error_type,
49 net::X509Certificate* cert,
50 const GURL& request_url);
52 // Populates the specified |errors| vector with the errors contained in
53 // |cert_status|. Returns the number of errors found.
54 // Callers only interested in the error count can pass NULL for |errors|.
55 // TODO(wtc): Document |cert_id| and |url| arguments.
56 static void GetErrorsForCertStatus(int cert_id,
57 net::CertStatus cert_status,
58 const GURL& url,
59 std::vector<SSLErrorInfo>* errors);
61 // A description of the error.
62 const base::string16& details() const { return details_; }
64 // A short message describing the error (1 line).
65 const base::string16& short_description() const { return short_description_; }
67 private:
68 SSLErrorInfo(const base::string16& details,
69 const base::string16& short_description);
71 base::string16 details_;
72 base::string16 short_description_;
75 #endif // CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_