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_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 public CertLoader::Observer { | 76 public CertLoader::Observer { |
77 public: | 77 public: |
78 // Indicates ownership status of the device. | 78 // Indicates ownership status of the device. |
79 enum OwnershipStatus { | 79 enum OwnershipStatus { |
80 // Listed in upgrade order. | 80 // Listed in upgrade order. |
81 OWNERSHIP_UNKNOWN = 0, | 81 OWNERSHIP_UNKNOWN = 0, |
82 OWNERSHIP_NONE, | 82 OWNERSHIP_NONE, |
83 OWNERSHIP_TAKEN | 83 OWNERSHIP_TAKEN |
84 }; | 84 }; |
85 | 85 |
86 typedef base::Callback<void(OwnershipStatus, bool)> OwnershipStatusCallback; | 86 typedef base::Callback<void(OwnershipStatus)> OwnershipStatusCallback; |
| 87 typedef base::Callback<void(bool)> IsCurrentUserOwnerCallback; |
87 | 88 |
88 // Status codes for Store(). | 89 // Status codes for Store(). |
89 enum Status { | 90 enum Status { |
90 STORE_SUCCESS, | 91 STORE_SUCCESS, |
91 STORE_KEY_UNAVAILABLE, // Owner key not yet configured. | 92 STORE_KEY_UNAVAILABLE, // Owner key not yet configured. |
92 STORE_POLICY_ERROR, // Failure constructing the settings blob. | 93 STORE_POLICY_ERROR, // Failure constructing the settings blob. |
93 STORE_OPERATION_FAILED, // IPC to session_manager daemon failed. | 94 STORE_OPERATION_FAILED, // IPC to session_manager daemon failed. |
94 STORE_NO_POLICY, // No settings blob present. | 95 STORE_NO_POLICY, // No settings blob present. |
95 STORE_INVALID_POLICY, // Invalid settings blob. | 96 STORE_INVALID_POLICY, // Invalid settings blob. |
96 STORE_VALIDATION_ERROR, // Unrecoverable policy validation failure. | 97 STORE_VALIDATION_ERROR, // Unrecoverable policy validation failure. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // hasn't been checked yet. | 170 // hasn't been checked yet. |
170 OwnershipStatus GetOwnershipStatus(); | 171 OwnershipStatus GetOwnershipStatus(); |
171 | 172 |
172 // Determines the ownership status and reports the result to |callback|. This | 173 // Determines the ownership status and reports the result to |callback|. This |
173 // is guaranteed to never return OWNERSHIP_UNKNOWN. | 174 // is guaranteed to never return OWNERSHIP_UNKNOWN. |
174 void GetOwnershipStatusAsync(const OwnershipStatusCallback& callback); | 175 void GetOwnershipStatusAsync(const OwnershipStatusCallback& callback); |
175 | 176 |
176 // Checks whether we have the private owner key. | 177 // Checks whether we have the private owner key. |
177 bool HasPrivateOwnerKey(); | 178 bool HasPrivateOwnerKey(); |
178 | 179 |
| 180 // Determines whether the current user is the owner. The callback is |
| 181 // guaranteed not to be called before it is possible to determine if the |
| 182 // current user is the owner (by testing existence of the private owner key). |
| 183 void IsCurrentUserOwnerAsync(const IsCurrentUserOwnerCallback& callback); |
| 184 |
179 // Sets the identity of the user that's interacting with the service. This is | 185 // Sets the identity of the user that's interacting with the service. This is |
180 // relevant only for writing settings through SignAndStore(). | 186 // relevant only for writing settings through SignAndStore(). |
181 void SetUsername(const std::string& username); | 187 void SetUsername(const std::string& username); |
182 const std::string& GetUsername() const; | 188 const std::string& GetUsername() const; |
183 | 189 |
184 // Adds an observer. | 190 // Adds an observer. |
185 void AddObserver(Observer* observer); | 191 void AddObserver(Observer* observer); |
186 // Removes an observer. | 192 // Removes an observer. |
187 void RemoveObserver(Observer* observer); | 193 void RemoveObserver(Observer* observer); |
188 | 194 |
(...skipping 27 matching lines...) Expand all Loading... |
216 Status status); | 222 Status status); |
217 | 223 |
218 SessionManagerClient* session_manager_client_; | 224 SessionManagerClient* session_manager_client_; |
219 scoped_refptr<OwnerKeyUtil> owner_key_util_; | 225 scoped_refptr<OwnerKeyUtil> owner_key_util_; |
220 | 226 |
221 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; | 227 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; |
222 | 228 |
223 Status store_status_; | 229 Status store_status_; |
224 | 230 |
225 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; | 231 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; |
| 232 std::vector<IsCurrentUserOwnerCallback> |
| 233 pending_is_current_user_owner_callbacks_; |
226 | 234 |
227 std::string username_; | 235 std::string username_; |
228 scoped_refptr<OwnerKey> owner_key_; | 236 scoped_refptr<OwnerKey> owner_key_; |
| 237 // Whether certificates have been loaded by CertLoader. |
| 238 bool certificates_loaded_; |
| 239 // Whether certificates were loaded when the current owner key was set. |
| 240 // Implies that the current user is owner iff the private owner key is set. |
| 241 bool owner_key_loaded_with_certificates_; |
229 | 242 |
230 scoped_ptr<enterprise_management::PolicyData> policy_data_; | 243 scoped_ptr<enterprise_management::PolicyData> policy_data_; |
231 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; | 244 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; |
232 | 245 |
233 // The queue of pending operations. The first operation on the queue is | 246 // The queue of pending operations. The first operation on the queue is |
234 // currently active; it gets removed and destroyed once it completes. | 247 // currently active; it gets removed and destroyed once it completes. |
235 std::deque<SessionManagerOperation*> pending_operations_; | 248 std::deque<SessionManagerOperation*> pending_operations_; |
236 | 249 |
237 ObserverList<Observer, true> observers_; | 250 ObserverList<Observer, true> observers_; |
238 | 251 |
(...skipping 10 matching lines...) Expand all Loading... |
249 ScopedTestDeviceSettingsService(); | 262 ScopedTestDeviceSettingsService(); |
250 ~ScopedTestDeviceSettingsService(); | 263 ~ScopedTestDeviceSettingsService(); |
251 | 264 |
252 private: | 265 private: |
253 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); | 266 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); |
254 }; | 267 }; |
255 | 268 |
256 } // namespace chromeos | 269 } // namespace chromeos |
257 | 270 |
258 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 271 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
OLD | NEW |