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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <memory> | 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 17 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
17 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class DeviceCloudPolicyStoreChromeOS; | 50 class DeviceCloudPolicyStoreChromeOS; |
50 class DeviceManagementService; | 51 class DeviceManagementService; |
51 struct EnrollmentConfig; | 52 struct EnrollmentConfig; |
52 class EnrollmentHandlerChromeOS; | 53 class EnrollmentHandlerChromeOS; |
53 class EnrollmentStatus; | 54 class EnrollmentStatus; |
54 | 55 |
55 // This class connects DCPM to the correct device management service, and | 56 // This class connects DCPM to the correct device management service, and |
56 // handles the enrollment process. | 57 // handles the enrollment process. |
57 class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { | 58 class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { |
58 public: | 59 public: |
59 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; | 60 using EnrollmentLicenseMap = std::map<LicenseType, int>; |
| 61 using EnrollmentCallback = base::Callback<void(EnrollmentStatus)>; |
| 62 using AvailableLicensesCallback = |
| 63 base::Callback<void(const EnrollmentLicenseMap&)>; |
60 | 64 |
61 // |background_task_runner| is used to execute long-running background tasks | 65 // |background_task_runner| is used to execute long-running background tasks |
62 // that may involve file I/O. | 66 // that may involve file I/O. |
63 DeviceCloudPolicyInitializer( | 67 DeviceCloudPolicyInitializer( |
64 PrefService* local_state, | 68 PrefService* local_state, |
65 DeviceManagementService* enterprise_service, | 69 DeviceManagementService* enterprise_service, |
66 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 70 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
67 chromeos::InstallAttributes* install_attributes, | 71 chromeos::InstallAttributes* install_attributes, |
68 ServerBackedStateKeysBroker* state_keys_broker, | 72 ServerBackedStateKeysBroker* state_keys_broker, |
69 DeviceCloudPolicyStoreChromeOS* device_store, | 73 DeviceCloudPolicyStoreChromeOS* device_store, |
70 DeviceCloudPolicyManagerChromeOS* manager, | 74 DeviceCloudPolicyManagerChromeOS* manager, |
71 cryptohome::AsyncMethodCaller* async_method_caller, | 75 cryptohome::AsyncMethodCaller* async_method_caller, |
72 std::unique_ptr<chromeos::attestation::AttestationFlow> attestation_flow, | 76 std::unique_ptr<chromeos::attestation::AttestationFlow> attestation_flow, |
73 chromeos::system::StatisticsProvider* statistics_provider); | 77 chromeos::system::StatisticsProvider* statistics_provider); |
74 | 78 |
75 ~DeviceCloudPolicyInitializer() override; | 79 ~DeviceCloudPolicyInitializer() override; |
76 | 80 |
77 virtual void Init(); | 81 virtual void Init(); |
78 virtual void Shutdown(); | 82 virtual void Shutdown(); |
79 | 83 |
80 // Starts enrollment or re-enrollment. Once the enrollment process completes, | 84 // Prepares enrollment or re-enrollment. Enrollment should be started by |
81 // |enrollment_callback| is invoked and gets passed the status of the | 85 // either calling StartEnrollment or CheckAvailableLicenses / |
82 // operation. | 86 // StartEnrollmentWithLicense. Once the enrollment process |
83 virtual void StartEnrollment( | 87 // completes, |enrollment_callback| is invoked and gets passed the status of |
| 88 // the operation. |
| 89 virtual void PrepareEnrollment( |
84 DeviceManagementService* device_management_service, | 90 DeviceManagementService* device_management_service, |
85 chromeos::ActiveDirectoryJoinDelegate* ad_join_delegate, | 91 chromeos::ActiveDirectoryJoinDelegate* ad_join_delegate, |
86 const EnrollmentConfig& enrollment_config, | 92 const EnrollmentConfig& enrollment_config, |
87 const std::string& auth_token, | 93 const std::string& auth_token, |
88 const EnrollmentCallback& enrollment_callback); | 94 const EnrollmentCallback& enrollment_callback); |
89 | 95 |
| 96 // Starts enrollment using server-based license type selection. |
| 97 virtual void StartEnrollment(); |
| 98 |
| 99 // Queries server about available license types and their count. |
| 100 virtual void CheckAvailableLicenses( |
| 101 const AvailableLicensesCallback& callback); |
| 102 |
| 103 // Starts enrollment using user-selected license type. |
| 104 virtual void StartEnrollmentWithLicense(policy::LicenseType license_type); |
| 105 |
90 // Get the enrollment configuration that has been set up via signals such as | 106 // Get the enrollment configuration that has been set up via signals such as |
91 // device requisition, OEM manifest, pre-existing installation-time attributes | 107 // device requisition, OEM manifest, pre-existing installation-time attributes |
92 // or server-backed state retrieval. The configuration is stored in |config|, | 108 // or server-backed state retrieval. The configuration is stored in |config|, |
93 // |config.mode| will be MODE_NONE if there is no prescribed configuration. | 109 // |config.mode| will be MODE_NONE if there is no prescribed configuration. |
94 // |config.management_domain| will contain the domain the device is supposed | 110 // |config.management_domain| will contain the domain the device is supposed |
95 // to be enrolled to as decided by factors such as forced re-enrollment, | 111 // to be enrolled to as decided by factors such as forced re-enrollment, |
96 // enrollment recovery, or already-present install attributes. Note that | 112 // enrollment recovery, or already-present install attributes. Note that |
97 // |config.management_domain| may be non-empty even if |config.mode| is | 113 // |config.management_domain| may be non-empty even if |config.mode| is |
98 // MODE_NONE. | 114 // MODE_NONE. |
99 EnrollmentConfig GetPrescribedEnrollmentConfig() const; | 115 EnrollmentConfig GetPrescribedEnrollmentConfig() const; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 179 |
164 // Our signing service. | 180 // Our signing service. |
165 std::unique_ptr<SigningService> signing_service_; | 181 std::unique_ptr<SigningService> signing_service_; |
166 | 182 |
167 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyInitializer); | 183 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyInitializer); |
168 }; | 184 }; |
169 | 185 |
170 } // namespace policy | 186 } // namespace policy |
171 | 187 |
172 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ | 188 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ |
OLD | NEW |