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_
11 #include "base/strings/string16.h"
12 #include "net/cert/cert_status_flags.h"
13 #include "net/cert/x509_certificate.h"
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.
23 // This enum is being histogrammed; please only add new values at the end.
25 CERT_COMMON_NAME_INVALID = 0,
27 CERT_AUTHORITY_INVALID,
29 CERT_NO_REVOCATION_MECHANISM,
30 CERT_UNABLE_TO_CHECK_REVOCATION,
33 CERT_WEAK_SIGNATURE_ALGORITHM,
37 CERT_PINNED_KEY_MISSING,
41 virtual ~SSLErrorInfo();
43 // Converts a network error code to an ErrorType.
44 static ErrorType NetErrorToErrorType(int net_error);
46 static SSLErrorInfo CreateError(ErrorType error_type,
47 net::X509Certificate* cert,
48 const GURL& request_url);
50 // Populates the specified |errors| vector with the errors contained in
51 // |cert_status|. Returns the number of errors found.
52 // Callers only interested in the error count can pass NULL for |errors|.
53 // TODO(wtc): Document |cert_id| and |url| arguments.
54 static int GetErrorsForCertStatus(int cert_id,
55 net::CertStatus cert_status,
57 std::vector<SSLErrorInfo>* errors);
59 // A title describing the error, usually to be used with the details below.
60 const string16& title() const { return title_; }
62 // A description of the error.
63 const string16& details() const { return details_; }
65 // A short message describing the error (1 line).
66 const string16& short_description() const { return short_description_; }
68 // A lengthy explanation of what the error is. Each entry in the returned
69 // vector is a paragraph.
70 const std::vector<string16>& extra_information() const {
71 return extra_information_;
75 SSLErrorInfo(const string16& title,
76 const string16& details,
77 const string16& short_description,
78 const std::vector<string16>& extra_info);
82 string16 short_description_;
83 // Extra-informations contains paragraphs of text explaining in details what
84 // the error is and what the risks are.
85 std::vector<string16> extra_information_;
88 #endif // CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_