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

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

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
11 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
12 #include "base/run_loop.h" 14 #include "base/run_loop.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/safe_browsing/ping_manager.h" 18 #include "chrome/browser/safe_browsing/ping_manager.h"
(...skipping 13 matching lines...) Expand all
30 32
31 using safe_browsing::SafeBrowsingService; 33 using safe_browsing::SafeBrowsingService;
32 using safe_browsing::SafeBrowsingUIManager; 34 using safe_browsing::SafeBrowsingUIManager;
33 35
34 namespace { 36 namespace {
35 37
36 void SetMockReporter( 38 void SetMockReporter(
37 SafeBrowsingService* safe_browsing_service, 39 SafeBrowsingService* safe_browsing_service,
38 scoped_ptr<certificate_reporting::ErrorReporter> reporter) { 40 scoped_ptr<certificate_reporting::ErrorReporter> reporter) {
39 safe_browsing_service->ping_manager()->SetCertificateErrorReporterForTesting( 41 safe_browsing_service->ping_manager()->SetCertificateErrorReporterForTesting(
40 reporter.Pass()); 42 std::move(reporter));
41 } 43 }
42 44
43 // This is a test implementation of the interface that blocking pages 45 // This is a test implementation of the interface that blocking pages
44 // use to send certificate reports. It checks that the blocking page 46 // use to send certificate reports. It checks that the blocking page
45 // calls or does not call the report method when a report should or 47 // calls or does not call the report method when a report should or
46 // should not be sent, respectively. 48 // should not be sent, respectively.
47 class MockSSLCertReporter : public SSLCertReporter { 49 class MockSSLCertReporter : public SSLCertReporter {
48 public: 50 public:
49 MockSSLCertReporter( 51 MockSSLCertReporter(
50 const scoped_refptr<SafeBrowsingUIManager>& safe_browsing_ui_manager, 52 const scoped_refptr<SafeBrowsingUIManager>& safe_browsing_ui_manager,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); 163 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
162 EXPECT_TRUE(sb_service); 164 EXPECT_TRUE(sb_service);
163 if (!sb_service) 165 if (!sb_service)
164 return nullptr; 166 return nullptr;
165 167
166 scoped_ptr<MockSSLCertReporter> ssl_cert_reporter(new MockSSLCertReporter( 168 scoped_ptr<MockSSLCertReporter> ssl_cert_reporter(new MockSSLCertReporter(
167 sb_service->ui_manager(), expect_report == CERT_REPORT_EXPECTED 169 sb_service->ui_manager(), expect_report == CERT_REPORT_EXPECTED
168 ? run_loop->QuitClosure() 170 ? run_loop->QuitClosure()
169 : base::Bind(&base::DoNothing))); 171 : base::Bind(&base::DoNothing)));
170 ssl_cert_reporter->set_expect_report(expect_report == CERT_REPORT_EXPECTED); 172 ssl_cert_reporter->set_expect_report(expect_report == CERT_REPORT_EXPECTED);
171 return ssl_cert_reporter.Pass(); 173 return std::move(ssl_cert_reporter);
172 } 174 }
173 175
174 ExpectReport GetReportExpectedFromFinch() { 176 ExpectReport GetReportExpectedFromFinch() {
175 const std::string group_name = base::FieldTrialList::FindFullName( 177 const std::string group_name = base::FieldTrialList::FindFullName(
176 CertReportHelper::kFinchExperimentName); 178 CertReportHelper::kFinchExperimentName);
177 179
178 if (group_name == CertReportHelper::kFinchGroupShowPossiblySend) { 180 if (group_name == CertReportHelper::kFinchGroupShowPossiblySend) {
179 const std::string param = variations::GetVariationParamValue( 181 const std::string param = variations::GetVariationParamValue(
180 CertReportHelper::kFinchExperimentName, 182 CertReportHelper::kFinchExperimentName,
181 CertReportHelper::kFinchParamName); 183 CertReportHelper::kFinchParamName);
182 double sendingThreshold; 184 double sendingThreshold;
183 if (!base::StringToDouble(param, &sendingThreshold)) 185 if (!base::StringToDouble(param, &sendingThreshold))
184 return CERT_REPORT_NOT_EXPECTED; 186 return CERT_REPORT_NOT_EXPECTED;
185 187
186 if (sendingThreshold == 1.0) 188 if (sendingThreshold == 1.0)
187 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED; 189 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED;
188 } 190 }
189 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED; 191 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED;
190 } 192 }
191 193
192 } // namespace certificate_reporting_test_utils 194 } // namespace certificate_reporting_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698