| 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 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" | 5 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/safe_browsing/ping_manager.h" | 17 #include "chrome/browser/safe_browsing/ping_manager.h" |
| 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 19 #include "chrome/browser/safe_browsing/ui_manager.h" | 19 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 20 #include "chrome/browser/ssl/cert_report_helper.h" | 20 #include "chrome/browser/ssl/cert_report_helper.h" |
| 21 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 21 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/common/pref_names.h" | |
| 24 #include "components/certificate_reporting/error_report.h" | 23 #include "components/certificate_reporting/error_report.h" |
| 25 #include "components/certificate_reporting/error_reporter.h" | 24 #include "components/certificate_reporting/error_reporter.h" |
| 26 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 26 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 27 #include "components/variations/variations_associated_data.h" | 27 #include "components/variations/variations_associated_data.h" |
| 28 #include "net/url_request/report_sender.h" | 28 #include "net/url_request/report_sender.h" |
| 29 #include "net/url_request/url_request_context.h" | 29 #include "net/url_request/url_request_context.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 32 | 32 |
| 33 using safe_browsing::SafeBrowsingService; | 33 using safe_browsing::SafeBrowsingService; |
| 34 using safe_browsing::SafeBrowsingUIManager; | 34 using safe_browsing::SafeBrowsingUIManager; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 base::Passed(std::unique_ptr<certificate_reporting::ErrorReporter>( | 144 base::Passed(std::unique_ptr<certificate_reporting::ErrorReporter>( |
| 145 reporter_)))); | 145 reporter_)))); |
| 146 } | 146 } |
| 147 | 147 |
| 148 const std::string& CertificateReportingTest::GetLatestHostnameReported() const { | 148 const std::string& CertificateReportingTest::GetLatestHostnameReported() const { |
| 149 return reporter_->latest_hostname_reported(); | 149 return reporter_->latest_hostname_reported(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void SetCertReportingOptIn(Browser* browser, OptIn opt_in) { | 152 void SetCertReportingOptIn(Browser* browser, OptIn opt_in) { |
| 153 browser->profile()->GetPrefs()->SetBoolean( | 153 browser->profile()->GetPrefs()->SetBoolean( |
| 154 prefs::kSafeBrowsingExtendedReportingEnabled, | 154 safe_browsing::GetExtendedReportingPrefName(), |
| 155 opt_in == EXTENDED_REPORTING_OPT_IN); | 155 opt_in == EXTENDED_REPORTING_OPT_IN); |
| 156 } | 156 } |
| 157 | 157 |
| 158 std::unique_ptr<SSLCertReporter> SetUpMockSSLCertReporter( | 158 std::unique_ptr<SSLCertReporter> SetUpMockSSLCertReporter( |
| 159 base::RunLoop* run_loop, | 159 base::RunLoop* run_loop, |
| 160 ExpectReport expect_report) { | 160 ExpectReport expect_report) { |
| 161 // Set up a MockSSLCertReporter to keep track of when the blocking | 161 // Set up a MockSSLCertReporter to keep track of when the blocking |
| 162 // page invokes the cert reporter. | 162 // page invokes the cert reporter. |
| 163 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); | 163 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); |
| 164 EXPECT_TRUE(sb_service); | 164 EXPECT_TRUE(sb_service); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 186 if (!base::StringToDouble(param, &sendingThreshold)) | 186 if (!base::StringToDouble(param, &sendingThreshold)) |
| 187 return CERT_REPORT_NOT_EXPECTED; | 187 return CERT_REPORT_NOT_EXPECTED; |
| 188 | 188 |
| 189 if (sendingThreshold == 1.0) | 189 if (sendingThreshold == 1.0) |
| 190 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED; | 190 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED; |
| 191 } | 191 } |
| 192 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED; | 192 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED; |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace certificate_reporting_test_utils | 195 } // namespace certificate_reporting_test_utils |
| OLD | NEW |