| 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 <bitset> | 8 #include <bitset> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 16 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 17 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 17 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 20 | 20 |
| 21 class PrefService; | 21 class PrefService; |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace chromeos { | |
| 28 class OwnerSettingsServiceChromeOS; | |
| 29 } | |
| 30 | |
| 31 namespace policy { | 27 namespace policy { |
| 32 | 28 |
| 33 class DeviceCloudPolicyManagerChromeOS; | 29 class DeviceCloudPolicyManagerChromeOS; |
| 34 class DeviceCloudPolicyStoreChromeOS; | 30 class DeviceCloudPolicyStoreChromeOS; |
| 35 class DeviceManagementService; | 31 class DeviceManagementService; |
| 36 struct EnrollmentConfig; | 32 struct EnrollmentConfig; |
| 37 class EnrollmentHandlerChromeOS; | 33 class EnrollmentHandlerChromeOS; |
| 38 class EnrollmentStatus; | 34 class EnrollmentStatus; |
| 39 class EnterpriseInstallAttributes; | 35 class EnterpriseInstallAttributes; |
| 40 | 36 |
| 41 // This class connects DCPM to the correct device management service, and | 37 // This class connects DCPM to the correct device management service, and |
| 42 // handles the enrollment process. | 38 // handles the enrollment process. |
| 43 class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { | 39 class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { |
| 44 public: | 40 public: |
| 45 typedef std::bitset<32> AllowedDeviceModes; | 41 typedef std::bitset<32> AllowedDeviceModes; |
| 46 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; | 42 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; |
| 47 | 43 |
| 48 // |background_task_runner| is used to execute long-running background tasks | 44 // |background_task_runner| is used to execute long-running background tasks |
| 49 // that may involve file I/O. | 45 // that may involve file I/O. |
| 50 DeviceCloudPolicyInitializer( | 46 DeviceCloudPolicyInitializer( |
| 51 PrefService* local_state, | 47 PrefService* local_state, |
| 52 DeviceManagementService* enterprise_service, | 48 DeviceManagementService* enterprise_service, |
| 53 DeviceManagementService* consumer_service, | |
| 54 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 49 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 55 EnterpriseInstallAttributes* install_attributes, | 50 EnterpriseInstallAttributes* install_attributes, |
| 56 ServerBackedStateKeysBroker* state_keys_broker, | 51 ServerBackedStateKeysBroker* state_keys_broker, |
| 57 DeviceCloudPolicyStoreChromeOS* device_store, | 52 DeviceCloudPolicyStoreChromeOS* device_store, |
| 58 DeviceCloudPolicyManagerChromeOS* manager); | 53 DeviceCloudPolicyManagerChromeOS* manager); |
| 59 | 54 |
| 60 ~DeviceCloudPolicyInitializer() override; | 55 ~DeviceCloudPolicyInitializer() override; |
| 61 | 56 |
| 62 virtual void Init(); | 57 virtual void Init(); |
| 63 virtual void Shutdown(); | 58 virtual void Shutdown(); |
| 64 | 59 |
| 65 // Starts enrollment or re-enrollment. Once the enrollment process completes, | 60 // Starts enrollment or re-enrollment. Once the enrollment process completes, |
| 66 // |enrollment_callback| is invoked and gets passed the status of the | 61 // |enrollment_callback| is invoked and gets passed the status of the |
| 67 // operation. | 62 // operation. |
| 68 // |allowed_modes| specifies acceptable DEVICE_MODE_* constants for | 63 // |allowed_modes| specifies acceptable DEVICE_MODE_* constants for |
| 69 // enrollment. | 64 // enrollment. |
| 70 // |management_mode| should be either MANAGEMENT_MODE_ENTERPRISE or | |
| 71 // MANAGEMENT_MODE_CONSUMER. | |
| 72 virtual void StartEnrollment( | 65 virtual void StartEnrollment( |
| 73 ManagementMode management_mode, | |
| 74 DeviceManagementService* device_management_service, | 66 DeviceManagementService* device_management_service, |
| 75 chromeos::OwnerSettingsServiceChromeOS* owner_settings_service, | |
| 76 const EnrollmentConfig& enrollment_config, | 67 const EnrollmentConfig& enrollment_config, |
| 77 const std::string& auth_token, | 68 const std::string& auth_token, |
| 78 const AllowedDeviceModes& allowed_modes, | 69 const AllowedDeviceModes& allowed_modes, |
| 79 const EnrollmentCallback& enrollment_callback); | 70 const EnrollmentCallback& enrollment_callback); |
| 80 | 71 |
| 81 // Get the enrollment configuration that has been set up via signals such as | 72 // Get the enrollment configuration that has been set up via signals such as |
| 82 // device requisition, OEM manifest, pre-existing installation-time attributes | 73 // device requisition, OEM manifest, pre-existing installation-time attributes |
| 83 // or server-backed state retrieval. The configuration is stored in |config|, | 74 // or server-backed state retrieval. The configuration is stored in |config|, |
| 84 // |config.mode| will be MODE_NONE if there is no prescribed configuration. | 75 // |config.mode| will be MODE_NONE if there is no prescribed configuration. |
| 85 // |config.management_domain| will contain the domain the device is supposed | 76 // |config.management_domain| will contain the domain the device is supposed |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 | 91 |
| 101 // Creates a new CloudPolicyClient. | 92 // Creates a new CloudPolicyClient. |
| 102 std::unique_ptr<CloudPolicyClient> CreateClient( | 93 std::unique_ptr<CloudPolicyClient> CreateClient( |
| 103 DeviceManagementService* device_management_service); | 94 DeviceManagementService* device_management_service); |
| 104 | 95 |
| 105 void TryToCreateClient(); | 96 void TryToCreateClient(); |
| 106 void StartConnection(std::unique_ptr<CloudPolicyClient> client); | 97 void StartConnection(std::unique_ptr<CloudPolicyClient> client); |
| 107 | 98 |
| 108 PrefService* local_state_; | 99 PrefService* local_state_; |
| 109 DeviceManagementService* enterprise_service_; | 100 DeviceManagementService* enterprise_service_; |
| 110 DeviceManagementService* consumer_service_; | |
| 111 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; | 101 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; |
| 112 EnterpriseInstallAttributes* install_attributes_; | 102 EnterpriseInstallAttributes* install_attributes_; |
| 113 ServerBackedStateKeysBroker* state_keys_broker_; | 103 ServerBackedStateKeysBroker* state_keys_broker_; |
| 114 DeviceCloudPolicyStoreChromeOS* device_store_; | 104 DeviceCloudPolicyStoreChromeOS* device_store_; |
| 115 DeviceCloudPolicyManagerChromeOS* manager_; | 105 DeviceCloudPolicyManagerChromeOS* manager_; |
| 116 bool is_initialized_; | 106 bool is_initialized_; |
| 117 | 107 |
| 118 // Non-NULL if there is an enrollment operation pending. | 108 // Non-NULL if there is an enrollment operation pending. |
| 119 std::unique_ptr<EnrollmentHandlerChromeOS> enrollment_handler_; | 109 std::unique_ptr<EnrollmentHandlerChromeOS> enrollment_handler_; |
| 120 | 110 |
| 121 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_; | 111 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_; |
| 122 | 112 |
| 123 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyInitializer); | 113 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyInitializer); |
| 124 }; | 114 }; |
| 125 | 115 |
| 126 } // namespace policy | 116 } // namespace policy |
| 127 | 117 |
| 128 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ | 118 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ |
| OLD | NEW |