File: error_info.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (81 lines) | stat: -rw-r--r-- 2,607 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_
#define COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_

#include <string>
#include <vector>

#include "base/macros.h"
#include "base/strings/string16.h"
#include "net/cert/cert_status_flags.h"
#include "net/cert/x509_certificate.h"

class GURL;

namespace ssl_errors {

// This class describes an error that happened while showing a page over SSL.
// An ErrorInfo object only exists on the UI thread and only contains
// information about an error (type of error and text details).
// Note no DISALLOW_COPY_AND_ASSIGN as we want the copy constructor.
class ErrorInfo {
 public:
  // This enum is being histogrammed; please only add new values at the end.
  enum ErrorType {
    CERT_COMMON_NAME_INVALID = 0,
    CERT_DATE_INVALID = 1,
    CERT_AUTHORITY_INVALID = 2,
    CERT_CONTAINS_ERRORS = 3,
    CERT_NO_REVOCATION_MECHANISM = 4,
    CERT_UNABLE_TO_CHECK_REVOCATION = 5,
    CERT_REVOKED = 6,
    CERT_INVALID = 7,
    CERT_WEAK_SIGNATURE_ALGORITHM = 8,
    CERT_WEAK_KEY = 9,
    CERT_NAME_CONSTRAINT_VIOLATION = 10,
    UNKNOWN = 11,
    // CERT_WEAK_KEY_DH = 12,
    CERT_PINNED_KEY_MISSING = 13,
    CERT_VALIDITY_TOO_LONG = 14,
    CERTIFICATE_TRANSPARENCY_REQUIRED = 15,
    END_OF_ENUM
  };

  virtual ~ErrorInfo();

  // Converts a network error code to an ErrorType.
  static ErrorType NetErrorToErrorType(int net_error);

  static ErrorInfo CreateError(ErrorType error_type,
                               net::X509Certificate* cert,
                               const GURL& request_url);

  // Populates the specified |errors| vector with the errors contained in
  // |cert_status| for |cert|.  Returns the number of errors found.
  // Callers only interested in the error count can pass NULL for |errors|.
  static void GetErrorsForCertStatus(
      const scoped_refptr<net::X509Certificate>& cert,
      net::CertStatus cert_status,
      const GURL& url,
      std::vector<ErrorInfo>* errors);

  // A description of the error.
  const base::string16& details() const { return details_; }

  // A short message describing the error (1 line).
  const base::string16& short_description() const { return short_description_; }

 private:
  ErrorInfo(const base::string16& details,
            const base::string16& short_description);

  base::string16 details_;
  base::string16 short_description_;
};

}  // namespace ssl_errors

#endif  // COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_