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 1244783006: Add Finch testing configs for ReportCertificateErrors study (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/string_number_conversions.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/safe_browsing/ping_manager.h" 15 #include "chrome/browser/safe_browsing/ping_manager.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
16 #include "chrome/browser/safe_browsing/ui_manager.h" 17 #include "chrome/browser/safe_browsing/ui_manager.h"
17 #include "chrome/browser/ssl/cert_report_helper.h" 18 #include "chrome/browser/ssl/cert_report_helper.h"
18 #include "chrome/browser/ssl/certificate_error_report.h" 19 #include "chrome/browser/ssl/certificate_error_report.h"
19 #include "chrome/browser/ssl/ssl_cert_reporter.h" 20 #include "chrome/browser/ssl/ssl_cert_reporter.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return nullptr; 157 return nullptr;
157 158
158 scoped_ptr<MockSSLCertReporter> ssl_cert_reporter(new MockSSLCertReporter( 159 scoped_ptr<MockSSLCertReporter> ssl_cert_reporter(new MockSSLCertReporter(
159 sb_service->ui_manager(), expect_report == CERT_REPORT_EXPECTED 160 sb_service->ui_manager(), expect_report == CERT_REPORT_EXPECTED
160 ? run_loop->QuitClosure() 161 ? run_loop->QuitClosure()
161 : base::Bind(&base::DoNothing))); 162 : base::Bind(&base::DoNothing)));
162 ssl_cert_reporter->set_expect_report(expect_report == CERT_REPORT_EXPECTED); 163 ssl_cert_reporter->set_expect_report(expect_report == CERT_REPORT_EXPECTED);
163 return ssl_cert_reporter.Pass(); 164 return ssl_cert_reporter.Pass();
164 } 165 }
165 166
166 // Helper function to set the Finch options. 167 ExpectReport GetReportExpectedFromFinch() {
167 void SetCertReportingFinchConfig(const std::string& group_name, 168 const std::string group_name = base::FieldTrialList::FindFullName(
168 const std::string& param_value) { 169 CertReportHelper::kFinchExperimentName);
169 base::FieldTrialList::CreateFieldTrial(CertReportHelper::kFinchExperimentName, 170
170 group_name); 171 if (group_name == CertReportHelper::kFinchGroupShowPossiblySend) {
171 if (!param_value.empty()) { 172 const std::string param = variations::GetVariationParamValue(
172 std::map<std::string, std::string> params; 173 CertReportHelper::kFinchExperimentName,
173 params[CertReportHelper::kFinchParamName] = param_value; 174 CertReportHelper::kFinchParamName);
174 variations::AssociateVariationParams(CertReportHelper::kFinchExperimentName, 175 double sendingThreshold;
175 group_name, params); 176 if (!base::StringToDouble(param, &sendingThreshold))
177 return CERT_REPORT_NOT_EXPECTED;
178
179 if (sendingThreshold == 1.0)
meacer 2015/07/21 06:04:31 You might want to compare sendingThreshold against
estark 2015/07/21 14:50:09 I was actually hoping to try to discourage Finch c
meacer 2015/07/21 17:36:25 Not sure if that check would be reliable either, b
180 return CertificateReportingTestUtils::CERT_REPORT_EXPECTED;
176 } 181 }
177 } 182 return CertificateReportingTestUtils::CERT_REPORT_NOT_EXPECTED;
178
179 // Helper function to set the Finch options in case we have no parameter.
180 void SetCertReportingFinchConfig(const std::string& group_name) {
181 SetCertReportingFinchConfig(group_name, std::string());
182 } 183 }
183 184
184 } // namespace CertificateReportingTestUtils 185 } // namespace CertificateReportingTestUtils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698