| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MANAGER_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 15 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 16 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 16 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 17 #include "components/policy/core/common/cloud/cloud_policy_manager.h" | 17 #include "components/policy/core/common/cloud/cloud_policy_manager.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace chromeos { | 23 namespace chromeos { |
| 24 namespace attestation { | 24 namespace attestation { |
| 25 class AttestationPolicyObserver; | 25 class AttestationPolicyObserver; |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 class PrefRegistrySimple; | |
| 30 class PrefService; | 29 class PrefService; |
| 31 | 30 |
| 32 namespace policy { | 31 namespace policy { |
| 33 | 32 |
| 34 class DeviceCloudPolicyStoreChromeOS; | 33 class DeviceCloudPolicyStoreChromeOS; |
| 35 | 34 |
| 36 // CloudPolicyManager specialization for device policy on Chrome OS. | 35 // CloudPolicyManager specialization for device policy on Chrome OS. |
| 37 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager { | 36 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager { |
| 38 public: | 37 public: |
| 39 // |task_runner| is the runner for policy refresh tasks. | 38 // |task_runner| is the runner for policy refresh tasks. |
| 40 DeviceCloudPolicyManagerChromeOS( | 39 DeviceCloudPolicyManagerChromeOS( |
| 41 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, | 40 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, |
| 42 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 41 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 43 ServerBackedStateKeysBroker* state_keys_broker); | 42 ServerBackedStateKeysBroker* state_keys_broker); |
| 44 virtual ~DeviceCloudPolicyManagerChromeOS(); | 43 virtual ~DeviceCloudPolicyManagerChromeOS(); |
| 45 | 44 |
| 46 // Initializes state keys and requisition information. | |
| 47 void Initialize(PrefService* local_state); | |
| 48 | |
| 49 // TODO(davidyu): Move these two functions to a more appropriate place. See | |
| 50 // http://crbug.com/383695. | |
| 51 // Gets/Sets the device requisition. | |
| 52 std::string GetDeviceRequisition() const; | |
| 53 void SetDeviceRequisition(const std::string& requisition); | |
| 54 bool IsRemoraRequisition() const; | |
| 55 bool IsSharkRequisition() const; | |
| 56 | |
| 57 // CloudPolicyManager: | 45 // CloudPolicyManager: |
| 58 virtual void Shutdown() OVERRIDE; | 46 virtual void Shutdown() OVERRIDE; |
| 59 | 47 |
| 60 // Pref registration helper. | |
| 61 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 62 | |
| 63 // Returns the device serial number, or an empty string if not available. | 48 // Returns the device serial number, or an empty string if not available. |
| 64 static std::string GetMachineID(); | 49 static std::string GetMachineID(); |
| 65 | 50 |
| 66 // Returns the machine model, or an empty string if not available. | 51 // Returns the machine model, or an empty string if not available. |
| 67 static std::string GetMachineModel(); | 52 static std::string GetMachineModel(); |
| 68 | 53 |
| 69 // Returns the robot 'email address' associated with the device robot | 54 // Returns the robot 'email address' associated with the device robot |
| 70 // account (sometimes called a service account) associated with this device | 55 // account (sometimes called a service account) associated with this device |
| 71 // during enterprise enrollment. | 56 // during enterprise enrollment. |
| 72 std::string GetRobotAccountId(); | 57 std::string GetRobotAccountId(); |
| 73 | 58 |
| 74 // Starts the connection via |client_to_connect|. | 59 // Starts the connection via |client_to_connect|. |
| 75 void StartConnection(scoped_ptr<CloudPolicyClient> client_to_connect, | 60 void StartConnection(scoped_ptr<CloudPolicyClient> client_to_connect, |
| 76 scoped_ptr<CloudPolicyClient::StatusProvider> | 61 scoped_ptr<CloudPolicyClient::StatusProvider> |
| 77 device_status_provider); | 62 device_status_provider, |
| 63 PrefService* local_state); |
| 78 | 64 |
| 79 DeviceCloudPolicyStoreChromeOS* device_store() { | 65 DeviceCloudPolicyStoreChromeOS* device_store() { |
| 80 return device_store_.get(); | 66 return device_store_.get(); |
| 81 } | 67 } |
| 82 | 68 |
| 83 private: | 69 private: |
| 84 // Saves the state keys received from |session_manager_client_|. | 70 // Saves the state keys received from |session_manager_client_|. |
| 85 void OnStateKeysUpdated(); | 71 void OnStateKeysUpdated(); |
| 86 | 72 |
| 87 // Initializes requisition settings at OOBE with values from VPD. | |
| 88 void InitializeRequisition(); | |
| 89 | |
| 90 // Points to the same object as the base CloudPolicyManager::store(), but with | 73 // Points to the same object as the base CloudPolicyManager::store(), but with |
| 91 // actual device policy specific type. | 74 // actual device policy specific type. |
| 92 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_store_; | 75 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_store_; |
| 93 ServerBackedStateKeysBroker* state_keys_broker_; | 76 ServerBackedStateKeysBroker* state_keys_broker_; |
| 94 | 77 |
| 95 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_; | 78 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_; |
| 96 | 79 |
| 97 // PrefService instance to read the policy refresh rate from. | |
| 98 PrefService* local_state_; | |
| 99 | |
| 100 scoped_ptr<chromeos::attestation::AttestationPolicyObserver> | 80 scoped_ptr<chromeos::attestation::AttestationPolicyObserver> |
| 101 attestation_policy_observer_; | 81 attestation_policy_observer_; |
| 102 | 82 |
| 103 // TODO(davidyu): Currently we need to keep this object alive while | 83 // TODO(davidyu): Currently we need to keep this object alive while |
| 104 // CloudPolicyClient is in use. We should have CPC take over the | 84 // CloudPolicyClient is in use. We should have CPC take over the |
| 105 // ownership of this object instead. See http://crbug.com/383696. | 85 // ownership of this object instead. See http://crbug.com/383696. |
| 106 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider_; | 86 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider_; |
| 107 | 87 |
| 108 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS); | 88 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS); |
| 109 }; | 89 }; |
| 110 | 90 |
| 111 } // namespace policy | 91 } // namespace policy |
| 112 | 92 |
| 113 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H
_ | 93 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H
_ |
| OLD | NEW |