OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/enrollment/enterprise_enrollment_helper.
h" | 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.
h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_
impl.h" | 9 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_
impl.h" |
9 | 10 |
10 namespace chromeos { | 11 namespace chromeos { |
11 | 12 |
12 EnterpriseEnrollmentHelper::CreateMockEnrollmentHelper | 13 EnterpriseEnrollmentHelper::CreateMockEnrollmentHelper |
13 EnterpriseEnrollmentHelper::create_mock_enrollment_helper_ = nullptr; | 14 EnterpriseEnrollmentHelper::create_mock_enrollment_helper_ = nullptr; |
14 | 15 |
15 EnterpriseEnrollmentHelper::~EnterpriseEnrollmentHelper() { | 16 EnterpriseEnrollmentHelper::~EnterpriseEnrollmentHelper() { |
16 } | 17 } |
17 | 18 |
18 // static | 19 // static |
19 void EnterpriseEnrollmentHelper::SetupEnrollmentHelperMock( | 20 void EnterpriseEnrollmentHelper::SetupEnrollmentHelperMock( |
20 CreateMockEnrollmentHelper creator) { | 21 CreateMockEnrollmentHelper creator) { |
21 create_mock_enrollment_helper_ = creator; | 22 create_mock_enrollment_helper_ = creator; |
22 } | 23 } |
23 | 24 |
24 // static | 25 // static |
25 scoped_ptr<EnterpriseEnrollmentHelper> EnterpriseEnrollmentHelper::Create( | 26 std::unique_ptr<EnterpriseEnrollmentHelper> EnterpriseEnrollmentHelper::Create( |
26 EnrollmentStatusConsumer* status_consumer, | 27 EnrollmentStatusConsumer* status_consumer, |
27 const policy::EnrollmentConfig& enrollment_config, | 28 const policy::EnrollmentConfig& enrollment_config, |
28 const std::string& enrolling_user_domain) { | 29 const std::string& enrolling_user_domain) { |
29 // Create a mock instance. | 30 // Create a mock instance. |
30 if (create_mock_enrollment_helper_) { | 31 if (create_mock_enrollment_helper_) { |
31 // The evaluated code might call |SetupEnrollmentHelperMock| to setup a new | 32 // The evaluated code might call |SetupEnrollmentHelperMock| to setup a new |
32 // allocator, so we reset the enrollment helper to null before that. | 33 // allocator, so we reset the enrollment helper to null before that. |
33 auto enrollment_helper_allocator = create_mock_enrollment_helper_; | 34 auto enrollment_helper_allocator = create_mock_enrollment_helper_; |
34 create_mock_enrollment_helper_ = nullptr; | 35 create_mock_enrollment_helper_ = nullptr; |
35 EnterpriseEnrollmentHelper* helper = enrollment_helper_allocator( | 36 EnterpriseEnrollmentHelper* helper = enrollment_helper_allocator( |
36 status_consumer, enrollment_config, enrolling_user_domain); | 37 status_consumer, enrollment_config, enrolling_user_domain); |
37 return make_scoped_ptr(helper); | 38 return base::WrapUnique(helper); |
38 } | 39 } |
39 | 40 |
40 return make_scoped_ptr(new EnterpriseEnrollmentHelperImpl( | 41 return base::WrapUnique(new EnterpriseEnrollmentHelperImpl( |
41 status_consumer, enrollment_config, enrolling_user_domain)); | 42 status_consumer, enrollment_config, enrolling_user_domain)); |
42 } | 43 } |
43 | 44 |
44 EnterpriseEnrollmentHelper::EnterpriseEnrollmentHelper( | 45 EnterpriseEnrollmentHelper::EnterpriseEnrollmentHelper( |
45 EnrollmentStatusConsumer* status_consumer) | 46 EnrollmentStatusConsumer* status_consumer) |
46 : status_consumer_(status_consumer) { | 47 : status_consumer_(status_consumer) { |
47 DCHECK(status_consumer_); | 48 DCHECK(status_consumer_); |
48 } | 49 } |
49 | 50 |
50 } // namespace chromeos | 51 } // namespace chromeos |
OLD | NEW |