| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_ | 5 #ifndef CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_ |
| 6 #define CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_ | 6 #define CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 class SSLInfo; | 13 class SSLInfo; |
| 14 } // namespace net | 14 } // namespace net |
| 15 | 15 |
| 16 class CertLoggerRequest; | 16 class CertLoggerRequest; |
| 17 | 17 |
| 18 // This class builds and serializes reports for invalid SSL certificate | 18 // This class builds and serializes reports for invalid SSL certificate |
| 19 // chains, intended to be sent with | 19 // chains, intended to be sent with |
| 20 // chrome_browser_net::CertificateErrorReporter. | 20 // chrome_browser_net::CertificateErrorReporter. |
| 21 class CertificateErrorReport { | 21 class CertificateErrorReport { |
| 22 public: | 22 public: |
| 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 { |
| 27 INTERSTITIAL_SSL, |
| 28 INTERSTITIAL_CAPTIVE_PORTAL, |
| 29 INTERSTITIAL_CLOCK |
| 30 }; |
| 31 |
| 32 // Whether the user clicked through the interstitial or not. |
| 33 enum ProceedDecision { USER_PROCEEDED, USER_DID_NOT_PROCEED }; |
| 34 |
| 35 // Whether the user was shown an option to click through the |
| 36 // interstitial. |
| 37 enum Overridable { INTERSTITIAL_OVERRIDABLE, INTERSTITIAL_NOT_OVERRIDABLE }; |
| 38 |
| 23 // Constructs an empty report. | 39 // Constructs an empty report. |
| 24 CertificateErrorReport(); | 40 CertificateErrorReport(); |
| 25 | 41 |
| 26 // Constructs a report for the given |hostname| using the SSL | 42 // Constructs a report for the given |hostname| using the SSL |
| 27 // properties in |ssl_info|. | 43 // properties in |ssl_info|. |
| 28 CertificateErrorReport(const std::string& hostname, | 44 CertificateErrorReport(const std::string& hostname, |
| 29 const net::SSLInfo& ssl_info); | 45 const net::SSLInfo& ssl_info); |
| 30 | 46 |
| 31 ~CertificateErrorReport(); | 47 ~CertificateErrorReport(); |
| 32 | 48 |
| 33 // Initializes an empty report by parsing the given serialized | 49 // Initializes an empty report by parsing the given serialized |
| 34 // report. |serialized_report| should be a serialized | 50 // report. |serialized_report| should be a serialized |
| 35 // CertLoggerRequest protobuf. Returns true if the report could be | 51 // CertLoggerRequest protobuf. Returns true if the report could be |
| 36 // successfully parsed and false otherwise. | 52 // successfully parsed and false otherwise. |
| 37 bool InitializeFromString(const std::string& serialized_report); | 53 bool InitializeFromString(const std::string& serialized_report); |
| 38 | 54 |
| 39 // Serializes the report. The output will be a serialized | 55 // Serializes the report. The output will be a serialized |
| 40 // CertLoggerRequest protobuf. Returns true if the serialization was | 56 // CertLoggerRequest protobuf. Returns true if the serialization was |
| 41 // successful and false otherwise. | 57 // successful and false otherwise. |
| 42 bool Serialize(std::string* output) const; | 58 bool Serialize(std::string* output) const; |
| 43 | 59 |
| 60 void SetInterstitialInfo(const InterstitialReason& interstitial_reason, |
| 61 const ProceedDecision& proceed_decision, |
| 62 const Overridable& overridable); |
| 63 |
| 44 // Gets the hostname to which this report corresponds. | 64 // Gets the hostname to which this report corresponds. |
| 45 const std::string& hostname() const; | 65 const std::string& hostname() const; |
| 46 | 66 |
| 47 private: | 67 private: |
| 48 scoped_ptr<CertLoggerRequest> cert_report_; | 68 scoped_ptr<CertLoggerRequest> cert_report_; |
| 49 }; | 69 }; |
| 50 | 70 |
| 51 #endif // CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_ | 71 #endif // CHROME_BROWSER_SSL_CERTIFICATE_ERROR_REPORT_H_ |
| OLD | NEW |