| 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 <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 16 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 17 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| 17 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 18 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 20 #include "policy/proto/device_management_backend.pb.h" | 21 #include "policy/proto/device_management_backend.pb.h" |
| 21 | 22 |
| 22 class PrefService; | 23 class PrefService; |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| 25 class SequencedTaskRunner; | 26 class SequencedTaskRunner; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace chromeos { | 29 namespace chromeos { |
| 29 class DeviceSettingsService; | 30 class DeviceSettingsService; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace policy { | 33 namespace policy { |
| 33 | 34 |
| 34 class DeviceCloudPolicyManagerChromeOS; | 35 class DeviceCloudPolicyManagerChromeOS; |
| 35 class DeviceCloudPolicyStoreChromeOS; | 36 class DeviceCloudPolicyStoreChromeOS; |
| 36 class DeviceManagementService; | 37 class DeviceManagementService; |
| 37 class EnrollmentHandlerChromeOS; | 38 class EnrollmentHandlerChromeOS; |
| 38 class EnterpriseInstallAttributes; | 39 class EnterpriseInstallAttributes; |
| 39 | 40 |
| 40 // This class connects DCPM to the correct device management service, and | 41 // This class connects DCPM to the correct device management service, and |
| 41 // handles the enrollment process. | 42 // handles the enrollment process. |
| 42 class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { | 43 class DeviceCloudPolicyInitializer |
| 44 : public CloudPolicyStore::Observer, |
| 45 public ConsumerManagementService::Observer { |
| 43 public: | 46 public: |
| 44 typedef std::bitset<32> AllowedDeviceModes; | 47 typedef std::bitset<32> AllowedDeviceModes; |
| 45 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; | 48 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; |
| 46 | 49 |
| 47 // |background_task_runner| is used to execute long-running background tasks | 50 // |background_task_runner| is used to execute long-running background tasks |
| 48 // that may involve file I/O. | 51 // that may involve file I/O. |
| 49 DeviceCloudPolicyInitializer( | 52 DeviceCloudPolicyInitializer( |
| 50 PrefService* local_state, | 53 PrefService* local_state, |
| 51 DeviceManagementService* enterprise_service, | 54 DeviceManagementService* enterprise_service, |
| 52 DeviceManagementService* consumer_service, | 55 DeviceManagementService* consumer_service, |
| 53 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 56 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 54 EnterpriseInstallAttributes* install_attributes, | 57 EnterpriseInstallAttributes* install_attributes, |
| 55 ServerBackedStateKeysBroker* state_keys_broker, | 58 ServerBackedStateKeysBroker* state_keys_broker, |
| 56 DeviceCloudPolicyStoreChromeOS* device_store, | 59 DeviceCloudPolicyStoreChromeOS* device_store, |
| 57 DeviceCloudPolicyManagerChromeOS* manager, | 60 DeviceCloudPolicyManagerChromeOS* manager, |
| 58 chromeos::DeviceSettingsService* device_settings_service); | 61 chromeos::DeviceSettingsService* device_settings_service, |
| 62 ConsumerManagementService* consumer_management_service); |
| 59 | 63 |
| 60 virtual ~DeviceCloudPolicyInitializer(); | 64 virtual ~DeviceCloudPolicyInitializer(); |
| 61 | 65 |
| 62 virtual void Init(); | 66 virtual void Init(); |
| 63 virtual void Shutdown(); | 67 virtual void Shutdown(); |
| 64 | 68 |
| 65 // Starts enrollment or re-enrollment. Once the enrollment process completes, | 69 // Starts enrollment or re-enrollment. Once the enrollment process completes, |
| 66 // |enrollment_callback| is invoked and gets passed the status of the | 70 // |enrollment_callback| is invoked and gets passed the status of the |
| 67 // operation. | 71 // operation. |
| 68 // |allowed_modes| specifies acceptable DEVICE_MODE_* constants for | 72 // |allowed_modes| specifies acceptable DEVICE_MODE_* constants for |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 // Looks up the domain from |install_attributes_|. | 89 // Looks up the domain from |install_attributes_|. |
| 86 std::string GetEnrollmentRecoveryDomain() const; | 90 std::string GetEnrollmentRecoveryDomain() const; |
| 87 | 91 |
| 88 // Checks whether the user can cancel enrollment. | 92 // Checks whether the user can cancel enrollment. |
| 89 bool CanExitEnrollment() const; | 93 bool CanExitEnrollment() const; |
| 90 | 94 |
| 91 // Gets the domain this device is supposed to be enrolled to. | 95 // Gets the domain this device is supposed to be enrolled to. |
| 92 std::string GetForcedEnrollmentDomain() const; | 96 std::string GetForcedEnrollmentDomain() const; |
| 93 | 97 |
| 94 // CloudPolicyStore::Observer: | 98 // CloudPolicyStore::Observer: |
| 95 virtual void OnStoreLoaded(CloudPolicyStore* store) override; | 99 void OnStoreLoaded(CloudPolicyStore* store) override; |
| 96 virtual void OnStoreError(CloudPolicyStore* store) override; | 100 void OnStoreError(CloudPolicyStore* store) override; |
| 101 |
| 102 // ConsumerManagementService::Observer: |
| 103 void OnConsumerManagementStatusChanged() override; |
| 97 | 104 |
| 98 private: | 105 private: |
| 99 // Handles completion signaled by |enrollment_handler_|. | 106 // Handles completion signaled by |enrollment_handler_|. |
| 100 void EnrollmentCompleted(const EnrollmentCallback& enrollment_callback, | 107 void EnrollmentCompleted(const EnrollmentCallback& enrollment_callback, |
| 101 EnrollmentStatus status); | 108 EnrollmentStatus status); |
| 102 | 109 |
| 103 // Creates a new CloudPolicyClient. | 110 // Creates a new CloudPolicyClient. |
| 104 scoped_ptr<CloudPolicyClient> CreateClient( | 111 scoped_ptr<CloudPolicyClient> CreateClient( |
| 105 DeviceManagementService* device_management_service); | 112 DeviceManagementService* device_management_service); |
| 106 | 113 |
| 107 void TryToCreateClient(); | 114 void TryToCreateClient(); |
| 108 void StartConnection(scoped_ptr<CloudPolicyClient> client); | 115 void StartConnection(scoped_ptr<CloudPolicyClient> client); |
| 109 | 116 |
| 110 PrefService* local_state_; | 117 PrefService* local_state_; |
| 111 DeviceManagementService* enterprise_service_; | 118 DeviceManagementService* enterprise_service_; |
| 112 DeviceManagementService* consumer_service_; | 119 DeviceManagementService* consumer_service_; |
| 113 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; | 120 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; |
| 114 EnterpriseInstallAttributes* install_attributes_; | 121 EnterpriseInstallAttributes* install_attributes_; |
| 115 ServerBackedStateKeysBroker* state_keys_broker_; | 122 ServerBackedStateKeysBroker* state_keys_broker_; |
| 116 DeviceCloudPolicyStoreChromeOS* device_store_; | 123 DeviceCloudPolicyStoreChromeOS* device_store_; |
| 117 DeviceCloudPolicyManagerChromeOS* manager_; | 124 DeviceCloudPolicyManagerChromeOS* manager_; |
| 118 chromeos::DeviceSettingsService* device_settings_service_; | 125 chromeos::DeviceSettingsService* device_settings_service_; |
| 126 ConsumerManagementService* consumer_management_service_; |
| 119 bool is_initialized_; | 127 bool is_initialized_; |
| 120 | 128 |
| 121 // Non-NULL if there is an enrollment operation pending. | 129 // Non-NULL if there is an enrollment operation pending. |
| 122 scoped_ptr<EnrollmentHandlerChromeOS> enrollment_handler_; | 130 scoped_ptr<EnrollmentHandlerChromeOS> enrollment_handler_; |
| 123 | 131 |
| 124 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_; | 132 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_; |
| 125 | 133 |
| 126 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider_; | 134 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider_; |
| 127 | 135 |
| 128 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyInitializer); | 136 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyInitializer); |
| 129 }; | 137 }; |
| 130 | 138 |
| 131 } // namespace policy | 139 } // namespace policy |
| 132 | 140 |
| 133 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ | 141 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ |
| OLD | NEW |