Chromium Code Reviews| 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 <bitset> | 8 #include <bitset> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 17 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| 17 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_manager.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_manager.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 38 class EnrollmentHandlerChromeOS; | 39 class EnrollmentHandlerChromeOS; |
| 39 class EnterpriseInstallAttributes; | 40 class EnterpriseInstallAttributes; |
| 40 | 41 |
| 41 // CloudPolicyManager specialization for device policy on Chrome OS. The most | 42 // CloudPolicyManager specialization for device policy on Chrome OS. The most |
| 42 // significant addition is support for device enrollment. | 43 // significant addition is support for device enrollment. |
| 43 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager { | 44 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager { |
| 44 public: | 45 public: |
| 45 typedef std::bitset<32> AllowedDeviceModes; | 46 typedef std::bitset<32> AllowedDeviceModes; |
| 46 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; | 47 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; |
| 47 | 48 |
| 49 // The power of two determining the size of the time quanta for device state | |
| 50 // keys, i.e. the quanta will be of size 2^kDeviceStateKeyTimeQuantumPower | |
| 51 // seconds. 2^23 seconds corresponds to 97.09 days. | |
| 52 static const int kDeviceStateKeyTimeQuantumPower = 23; | |
| 53 | |
| 54 // The number of future time quanta to generate device state identifiers for. | |
| 55 // This determines the interval after which a device will no longer receive | |
| 56 // server-backed state information and thus corresponds to the delay until a | |
| 57 // device becomes anonymous to the server again. | |
|
Joao da Silva
2014/03/27 15:45:40
If I understood the implementation correctly then
Mattias Nissler (ping if slow)
2014/03/27 16:12:41
5 * 97 is closer to 16 months :) The goal was one
| |
| 58 static const int kDeviceStateKeyFutureQuanta = 5; | |
| 59 | |
| 48 // |task_runner| is the runner for policy refresh tasks. | 60 // |task_runner| is the runner for policy refresh tasks. |
| 49 // |background_task_runner| is used to execute long-running background tasks | 61 // |background_task_runner| is used to execute long-running background tasks |
| 50 // that may involve file I/O. | 62 // that may involve file I/O. |
| 51 DeviceCloudPolicyManagerChromeOS( | 63 DeviceCloudPolicyManagerChromeOS( |
| 52 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, | 64 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, |
| 53 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 65 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 54 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 66 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 55 EnterpriseInstallAttributes* install_attributes); | 67 EnterpriseInstallAttributes* install_attributes); |
| 56 virtual ~DeviceCloudPolicyManagerChromeOS(); | 68 virtual ~DeviceCloudPolicyManagerChromeOS(); |
| 57 | 69 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 106 |
| 95 // Pref registration helper. | 107 // Pref registration helper. |
| 96 static void RegisterPrefs(PrefRegistrySimple* registry); | 108 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 97 | 109 |
| 98 // Returns the device serial number, or an empty string if not available. | 110 // Returns the device serial number, or an empty string if not available. |
| 99 static std::string GetMachineID(); | 111 static std::string GetMachineID(); |
| 100 | 112 |
| 101 // Returns the machine model, or an empty string if not available. | 113 // Returns the machine model, or an empty string if not available. |
| 102 static std::string GetMachineModel(); | 114 static std::string GetMachineModel(); |
| 103 | 115 |
| 104 // Returns the stable device state key. | 116 // Gets the device state keys for |timestamp|. These will cover a time frame |
| 105 static std::string GetDeviceStateKey(); | 117 // including |timestamp| and extending into the future as configured by the |
| 118 // constants declared above. | |
| 119 static bool GetDeviceStateKeys(const base::Time& timestamp, | |
| 120 std::vector<std::string>* state_keys); | |
| 121 | |
| 122 // Returns the currently valid device state key. | |
| 123 static std::string GetCurrentDeviceStateKey(); | |
| 106 | 124 |
| 107 // Returns the robot 'email address' associated with the device robot | 125 // Returns the robot 'email address' associated with the device robot |
| 108 // account (sometimes called a service account) associated with this device | 126 // account (sometimes called a service account) associated with this device |
| 109 // during enterprise enrollment. | 127 // during enterprise enrollment. |
| 110 std::string GetRobotAccountId(); | 128 std::string GetRobotAccountId(); |
| 111 | 129 |
| 112 private: | 130 private: |
| 113 // Creates a new CloudPolicyClient. | 131 // Creates a new CloudPolicyClient. |
| 114 scoped_ptr<CloudPolicyClient> CreateClient(); | 132 scoped_ptr<CloudPolicyClient> CreateClient(); |
| 115 | 133 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 | 165 |
| 148 scoped_ptr<chromeos::attestation::AttestationPolicyObserver> | 166 scoped_ptr<chromeos::attestation::AttestationPolicyObserver> |
| 149 attestation_policy_observer_; | 167 attestation_policy_observer_; |
| 150 | 168 |
| 151 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS); | 169 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS); |
| 152 }; | 170 }; |
| 153 | 171 |
| 154 } // namespace policy | 172 } // namespace policy |
| 155 | 173 |
| 156 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H _ | 174 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H _ |
| OLD | NEW |