Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / certificate_reporting / error_report.h
blob8600cecd84b58026d74bea28c5481c956e1c7332
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORT_H_
6 #define COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORT_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
12 namespace net {
13 class SSLInfo;
14 } // namespace net
16 namespace certificate_reporting {
18 class CertLoggerRequest;
20 // This class builds and serializes reports for invalid SSL certificate
21 // chains, intended to be sent with ErrorReporter.
22 class ErrorReport {
23 public:
24 // Describes the type of interstitial that the user was shown for the
25 // error that this report represents. Gets mapped to
26 // |CertLoggerInterstitialInfo::InterstitialReason|.
27 enum InterstitialReason {
28 INTERSTITIAL_SSL,
29 INTERSTITIAL_CAPTIVE_PORTAL,
30 INTERSTITIAL_CLOCK
33 // Whether the user clicked through the interstitial or not.
34 enum ProceedDecision { USER_PROCEEDED, USER_DID_NOT_PROCEED };
36 // Whether the user was shown an option to click through the
37 // interstitial.
38 enum Overridable { INTERSTITIAL_OVERRIDABLE, INTERSTITIAL_NOT_OVERRIDABLE };
40 // Constructs an empty report.
41 ErrorReport();
43 // Constructs a report for the given |hostname| using the SSL
44 // properties in |ssl_info|.
45 ErrorReport(const std::string& hostname, const net::SSLInfo& ssl_info);
47 ~ErrorReport();
49 // Initializes an empty report by parsing the given serialized
50 // report. |serialized_report| should be a serialized
51 // CertLoggerRequest protobuf. Returns true if the report could be
52 // successfully parsed and false otherwise.
53 bool InitializeFromString(const std::string& serialized_report);
55 // Serializes the report. The output will be a serialized
56 // CertLoggerRequest protobuf. Returns true if the serialization was
57 // successful and false otherwise.
58 bool Serialize(std::string* output) const;
60 void SetInterstitialInfo(const InterstitialReason& interstitial_reason,
61 const ProceedDecision& proceed_decision,
62 const Overridable& overridable);
64 // Gets the hostname to which this report corresponds.
65 const std::string& hostname() const;
67 private:
68 scoped_ptr<CertLoggerRequest> cert_report_;
71 } // namespace certificate_reporting
73 #endif // COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORT_H_