Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / ssl / cert_report_helper.h
blob6bebaff2dd785bb8c3ab335a59cc313a4438ae53
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_
8 #include <string>
10 #include "chrome/browser/interstitials/security_interstitial_page.h"
11 #include "chrome/browser/ssl/certificate_error_report.h"
12 #include "net/ssl/ssl_info.h"
13 #include "url/gurl.h"
15 namespace base {
16 class DictionaryValue;
19 namespace content {
20 class WebContents;
23 namespace security_interstitials {
24 class MetricsHelper;
27 class SSLCertReporter;
29 // CertReportHelper helps SSL interstitials report invalid certificate
30 // chains.
31 class CertReportHelper {
32 public:
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(
40 scoped_ptr<SSLCertReporter> ssl_cert_reporter,
41 content::WebContents* web_contents,
42 const GURL& request_url,
43 const net::SSLInfo& ssl_info,
44 CertificateErrorReport::InterstitialReason interstitial_reason,
45 bool overridable,
46 security_interstitials::MetricsHelper* metrics_helper);
48 virtual ~CertReportHelper();
50 // Populates data that JavaScript code on the interstitial uses to show
51 // the checkbox.
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 CertificateErrorReport::ProceedDecision user_proceeded);
60 // Allows tests to inject a mock reporter.
61 void SetSSLCertReporterForTesting(
62 scoped_ptr<SSLCertReporter> ssl_cert_reporter);
64 private:
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 CertificateErrorReport::InterstitialReason interstitial_reason_;
87 // True if the user was given the option to proceed through the
88 // certificate chain error being reported.
89 bool overridable_;
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_