Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / ssl / certificate_reporting_test_utils.h
bloba397e7049be12efda57b7e18468f8e27787cb5f1
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_REPORTING_TEST_UTILS_H_
6 #define CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_
8 #include <string>
10 #include "chrome/browser/net/certificate_error_reporter.h"
11 #include "chrome/test/base/in_process_browser_test.h"
13 class Browser;
14 class GURL;
15 class SSLCertReporter;
17 namespace net {
18 class URLRequestContext;
21 namespace CertificateReportingTestUtils {
23 class MockReporter;
25 enum OptIn { EXTENDED_REPORTING_OPT_IN, EXTENDED_REPORTING_DO_NOT_OPT_IN };
27 enum Proceed { SSL_INTERSTITIAL_PROCEED, SSL_INTERSTITIAL_DO_NOT_PROCEED };
29 enum ExpectReport { CERT_REPORT_EXPECTED, CERT_REPORT_NOT_EXPECTED };
31 // A test class that tracks the latest hostname for which a certificate
32 // report would have been sent over the network.
33 class CertificateReportingTest : public InProcessBrowserTest {
34 public:
35 // Set up the mock reporter that keeps track of certificate reports
36 // that the safe browsing service sends.
37 void SetUpMockReporter();
39 protected:
40 // Get the latest hostname for which a certificate report was sent.
41 const std::string& GetLatestHostnameReported() const;
43 private:
44 MockReporter* reporter_;
47 // Sets the browser preference to enable or disable extended reporting.
48 void SetCertReportingOptIn(Browser* browser, OptIn opt_in);
50 // Sets up a mock SSLCertReporter and return a pointer to it, which will
51 // be owned by the caller. The mock SSLCertReporter will call
52 // |run_loop|'s QuitClosure when a report is sent. It also checks that a
53 // report is sent or not sent according to |expect_report|.
54 scoped_ptr<SSLCertReporter> SetUpMockSSLCertReporter(
55 base::RunLoop* run_loop,
56 ExpectReport expect_report);
58 // Returns whether a report should be expected (due to the Finch config)
59 // if the user opts in.
60 ExpectReport GetReportExpectedFromFinch();
62 } // namespace CertificateReportingTestUtils
64 #endif // CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_