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_CERT_REPORT_HELPER_H_
6 #define CHROME_BROWSER_SSL_CERT_REPORT_HELPER_H_
10 #include "chrome/browser/interstitials/security_interstitial_page.h"
11 #include "components/certificate_reporting/error_report.h"
12 #include "net/ssl/ssl_info.h"
16 class DictionaryValue
;
23 namespace security_interstitials
{
27 class SSLCertReporter
;
29 // CertReportHelper helps SSL interstitials report invalid certificate
31 class CertReportHelper
{
33 // Constants for the HTTPSErrorReporter Finch experiment
34 static const char kFinchExperimentName
[];
35 static const char kFinchGroupShowPossiblySend
[];
36 static const char kFinchGroupDontShowDontSend
[];
37 static const char kFinchParamName
[];
39 CertReportHelper(scoped_ptr
<SSLCertReporter
> ssl_cert_reporter
,
40 content::WebContents
* web_contents
,
41 const GURL
& request_url
,
42 const net::SSLInfo
& ssl_info
,
43 certificate_reporting::ErrorReport::InterstitialReason
46 security_interstitials::MetricsHelper
* metrics_helper
);
48 virtual ~CertReportHelper();
50 // Populates data that JavaScript code on the interstitial uses to show
52 void PopulateExtendedReportingOption(base::DictionaryValue
* load_time_data
);
54 // Sends a report about an invalid certificate to the
55 // server. |user_proceeded| indicates whether the user clicked through
56 // the interstitial or not, and will be included in the report.
57 void FinishCertCollection(
58 certificate_reporting::ErrorReport::ProceedDecision user_proceeded
);
60 // Allows tests to inject a mock reporter.
61 void SetSSLCertReporterForTesting(
62 scoped_ptr
<SSLCertReporter
> ssl_cert_reporter
);
65 // Checks whether a checkbox should be shown on the page that allows
66 // the user to opt in to Safe Browsing extended reporting.
67 bool ShouldShowCertificateReporterCheckbox();
69 // Returns true if a certificate report should be sent for the SSL
70 // error for this page.
71 bool ShouldReportCertificateError();
73 // Returns the boolean value of the given |pref| from the PrefService of the
74 // Profile associated with |web_contents_|.
75 bool IsPrefEnabled(const char* pref
);
77 // Handles reports of invalid SSL certificates.
78 scoped_ptr
<SSLCertReporter
> ssl_cert_reporter_
;
79 // The WebContents for which this helper sends reports.
80 content::WebContents
* web_contents_
;
81 // The URL for which this helper sends reports.
82 const GURL request_url_
;
83 // The SSLInfo used in this helper's report.
84 const net::SSLInfo ssl_info_
;
85 // The reason for the interstitial, included in this helper's report.
86 certificate_reporting::ErrorReport::InterstitialReason interstitial_reason_
;
87 // True if the user was given the option to proceed through the
88 // certificate chain error being reported.
90 // Helpful for recording metrics about cert reports.
91 security_interstitials::MetricsHelper
* metrics_helper_
;
93 DISALLOW_COPY_AND_ASSIGN(CertReportHelper
);
96 #endif // CHROME_BROWSER_SSL_CERT_REPORT_HELPER_H_