Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/ssl/certificate_reporting_test_utils.cc

Issue 2418813002: [Reland] Refactoring of SBER preference usage (Closed)
Patch Set: Sync Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ssl/cert_report_helper.cc ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
25 #include "components/safe_browsing_db/safe_browsing_prefs.h"
26 #include "components/variations/variations_associated_data.h" 26 #include "components/variations/variations_associated_data.h"
27 #include "net/url_request/report_sender.h" 27 #include "net/url_request/report_sender.h"
28 #include "net/url_request/url_request_context.h" 28 #include "net/url_request/url_request_context.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "url/gurl.h" 30 #include "url/gurl.h"
31 31
32 using safe_browsing::SafeBrowsingService; 32 using safe_browsing::SafeBrowsingService;
33 using safe_browsing::SafeBrowsingUIManager; 33 using safe_browsing::SafeBrowsingUIManager;
34 34
35 namespace { 35 namespace {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 base::Passed(std::unique_ptr<certificate_reporting::ErrorReporter>( 115 base::Passed(std::unique_ptr<certificate_reporting::ErrorReporter>(
116 reporter_)))); 116 reporter_))));
117 } 117 }
118 118
119 const std::string& CertificateReportingTest::GetLatestHostnameReported() const { 119 const std::string& CertificateReportingTest::GetLatestHostnameReported() const {
120 return reporter_->latest_hostname_reported(); 120 return reporter_->latest_hostname_reported();
121 } 121 }
122 122
123 void SetCertReportingOptIn(Browser* browser, OptIn opt_in) { 123 void SetCertReportingOptIn(Browser* browser, OptIn opt_in) {
124 browser->profile()->GetPrefs()->SetBoolean( 124 browser->profile()->GetPrefs()->SetBoolean(
125 prefs::kSafeBrowsingExtendedReportingEnabled, 125 safe_browsing::GetExtendedReportingPrefName(),
126 opt_in == EXTENDED_REPORTING_OPT_IN); 126 opt_in == EXTENDED_REPORTING_OPT_IN);
127 } 127 }
128 128
129 std::unique_ptr<SSLCertReporter> SetUpMockSSLCertReporter( 129 std::unique_ptr<SSLCertReporter> SetUpMockSSLCertReporter(
130 base::RunLoop* run_loop, 130 base::RunLoop* run_loop,
131 ExpectReport expect_report) { 131 ExpectReport expect_report) {
132 // Set up a MockSSLCertReporter to keep track of when the blocking 132 // Set up a MockSSLCertReporter to keep track of when the blocking
133 // page invokes the cert reporter. 133 // page invokes the cert reporter.
134 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); 134 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
135 EXPECT_TRUE(sb_service); 135 EXPECT_TRUE(sb_service);
(...skipping 21 matching lines...) Expand all
157 if (!base::StringToDouble(param, &sendingThreshold)) 157 if (!base::StringToDouble(param, &sendingThreshold))
158 return CERT_REPORT_NOT_EXPECTED; 158 return CERT_REPORT_NOT_EXPECTED;
159 159
160 if (sendingThreshold == 1.0) 160 if (sendingThreshold == 1.0)
161 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED; 161 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED;
162 } 162 }
163 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED; 163 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED;
164 } 164 }
165 165
166 } // namespace certificate_reporting_test_utils 166 } // namespace certificate_reporting_test_utils
OLDNEW
« no previous file with comments | « chrome/browser/ssl/cert_report_helper.cc ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698