// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_ #define CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_ #include #include "chrome/browser/net/certificate_error_reporter.h" #include "chrome/test/base/in_process_browser_test.h" class Browser; class GURL; class SSLCertReporter; namespace net { class URLRequestContext; } namespace CertificateReportingTestUtils { class MockReporter; enum OptIn { EXTENDED_REPORTING_OPT_IN, EXTENDED_REPORTING_DO_NOT_OPT_IN }; enum Proceed { SSL_INTERSTITIAL_PROCEED, SSL_INTERSTITIAL_DO_NOT_PROCEED }; enum ExpectReport { CERT_REPORT_EXPECTED, CERT_REPORT_NOT_EXPECTED }; // A test class that tracks the latest hostname for which a certificate // report would have been sent over the network. class CertificateReportingTest : public InProcessBrowserTest { public: // Set up the mock reporter that keeps track of certificate reports // that the safe browsing service sends. void SetUpMockReporter(); protected: // Get the latest hostname for which a certificate report was sent. const std::string& GetLatestHostnameReported(); private: MockReporter* reporter_; }; // Sets the browser preference to enable or disable extended reporting. void SetCertReportingOptIn(Browser* browser, OptIn opt_in); // Sets up a mock SSLCertReporter and return a pointer to it, which will // be owned by the caller. The mock SSLCertReporter will call // |run_loop|'s QuitClosure when a report is sent. It also checks that a // report is sent or not sent according to |expect_report|. scoped_ptr SetUpMockSSLCertReporter( base::RunLoop* run_loop, ExpectReport expect_report); // Forces a Finch config for the cert reporting experiment. void SetCertReportingFinchConfig(const std::string& group_name, const std::string& param_value); void SetCertReportingFinchConfig(const std::string& group_name); } // namespace CertificateReportingTestUtils #endif // CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_