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 CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_
6 #define CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_
10 #include "base/memory/scoped_ptr.h"
16 class CertLoggerRequest
;
18 // This class builds and serializes reports for invalid SSL certificate
19 // chains, intended to be sent with
20 // chrome_browser_net::CertificateErrorReporter.
21 class CertificateErrorReport
{
23 // Describes the type of interstitial that the user was shown for the
24 // error that this report represents. Gets mapped to
25 // |CertLoggerInterstitialInfo::InterstitialReason|.
26 enum InterstitialReason
{
28 INTERSTITIAL_CAPTIVE_PORTAL
,
32 // Whether the user clicked through the interstitial or not.
33 enum ProceedDecision
{ USER_PROCEEDED
, USER_DID_NOT_PROCEED
};
35 // Whether the user was shown an option to click through the
37 enum Overridable
{ INTERSTITIAL_OVERRIDABLE
, INTERSTITIAL_NOT_OVERRIDABLE
};
39 // Constructs an empty report.
40 CertificateErrorReport();
42 // Constructs a report for the given |hostname| using the SSL
43 // properties in |ssl_info|.
44 CertificateErrorReport(const std::string
& hostname
,
45 const net::SSLInfo
& ssl_info
);
47 ~CertificateErrorReport();
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;
68 scoped_ptr
<CertLoggerRequest
> cert_report_
;
71 #endif // CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_