| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 19 #include "chromeos/dbus/session_manager_client.h" | 19 #include "chromeos/dbus/session_manager_client.h" |
| 20 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 21 #include "crypto/scoped_nss_types.h" | 21 #include "crypto/scoped_nss_types.h" |
| 22 #include "policy/proto/device_management_backend.pb.h" | 22 #include "policy/proto/device_management_backend.pb.h" |
| 23 | 23 |
| 24 namespace crypto { | 24 namespace crypto { |
| 25 class RSAPrivateKey; | 25 class RSAPrivateKey; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace ownership { |
| 29 class OwnerKeyUtil; |
| 30 class PublicKey; |
| 31 } |
| 32 |
| 28 namespace chromeos { | 33 namespace chromeos { |
| 29 | 34 |
| 30 class OwnerKeyUtil; | |
| 31 class PublicKey; | |
| 32 class SessionManagerOperation; | 35 class SessionManagerOperation; |
| 33 | 36 |
| 34 // Deals with the low-level interface to Chromium OS device settings. Device | 37 // Deals with the low-level interface to Chromium OS device settings. Device |
| 35 // settings are stored in a protobuf that's protected by a cryptographic | 38 // settings are stored in a protobuf that's protected by a cryptographic |
| 36 // signature generated by a key in the device owner's possession. Key and | 39 // signature generated by a key in the device owner's possession. Key and |
| 37 // settings are brokered by the session_manager daemon. | 40 // settings are brokered by the session_manager daemon. |
| 38 // | 41 // |
| 39 // The purpose of DeviceSettingsService is to keep track of the current key and | 42 // The purpose of DeviceSettingsService is to keep track of the current key and |
| 40 // settings blob. For reading and writing device settings, use CrosSettings | 43 // settings blob. For reading and writing device settings, use CrosSettings |
| 41 // instead, which provides a high-level interface that allows for manipulation | 44 // instead, which provides a high-level interface that allows for manipulation |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 static void Shutdown(); | 130 static void Shutdown(); |
| 128 static DeviceSettingsService* Get(); | 131 static DeviceSettingsService* Get(); |
| 129 | 132 |
| 130 // Creates a device settings service instance. This is meant for unit tests, | 133 // Creates a device settings service instance. This is meant for unit tests, |
| 131 // production code uses the singleton returned by Get() above. | 134 // production code uses the singleton returned by Get() above. |
| 132 DeviceSettingsService(); | 135 DeviceSettingsService(); |
| 133 virtual ~DeviceSettingsService(); | 136 virtual ~DeviceSettingsService(); |
| 134 | 137 |
| 135 // To be called on startup once threads are initialized and DBus is ready. | 138 // To be called on startup once threads are initialized and DBus is ready. |
| 136 void SetSessionManager(SessionManagerClient* session_manager_client, | 139 void SetSessionManager(SessionManagerClient* session_manager_client, |
| 137 scoped_refptr<OwnerKeyUtil> owner_key_util); | 140 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util); |
| 138 | 141 |
| 139 // Prevents the service from making further calls to session_manager_client | 142 // Prevents the service from making further calls to session_manager_client |
| 140 // and stops any pending operations. | 143 // and stops any pending operations. |
| 141 void UnsetSessionManager(); | 144 void UnsetSessionManager(); |
| 142 | 145 |
| 143 SessionManagerClient* session_manager_client() const { | 146 SessionManagerClient* session_manager_client() const { |
| 144 return session_manager_client_; | 147 return session_manager_client_; |
| 145 } | 148 } |
| 146 | 149 |
| 147 // Returns the currently active device settings. Returns NULL if the device | 150 // Returns the currently active device settings. Returns NULL if the device |
| 148 // settings have not been retrieved from session_manager yet. | 151 // settings have not been retrieved from session_manager yet. |
| 149 const enterprise_management::PolicyData* policy_data() { | 152 const enterprise_management::PolicyData* policy_data() { |
| 150 return policy_data_.get(); | 153 return policy_data_.get(); |
| 151 } | 154 } |
| 152 const enterprise_management::ChromeDeviceSettingsProto* | 155 const enterprise_management::ChromeDeviceSettingsProto* |
| 153 device_settings() const { | 156 device_settings() const { |
| 154 return device_settings_.get(); | 157 return device_settings_.get(); |
| 155 } | 158 } |
| 156 | 159 |
| 157 // Returns the currently used owner key. | 160 // Returns the currently used owner key. |
| 158 scoped_refptr<PublicKey> GetPublicKey(); | 161 scoped_refptr<ownership::PublicKey> GetPublicKey(); |
| 159 | 162 |
| 160 // Returns the status generated by the last operation. | 163 // Returns the status generated by the last operation. |
| 161 Status status() { | 164 Status status() { |
| 162 return store_status_; | 165 return store_status_; |
| 163 } | 166 } |
| 164 | 167 |
| 165 // Triggers an attempt to pull the public half of the owner key from disk and | 168 // Triggers an attempt to pull the public half of the owner key from disk and |
| 166 // load the device settings. | 169 // load the device settings. |
| 167 void Load(); | 170 void Load(); |
| 168 | 171 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 scoped_ptr<enterprise_management::PolicyData> policy_data) { | 250 scoped_ptr<enterprise_management::PolicyData> policy_data) { |
| 248 policy_data_ = policy_data.Pass(); | 251 policy_data_ = policy_data.Pass(); |
| 249 } | 252 } |
| 250 | 253 |
| 251 void set_device_settings(scoped_ptr< | 254 void set_device_settings(scoped_ptr< |
| 252 enterprise_management::ChromeDeviceSettingsProto> device_settings) { | 255 enterprise_management::ChromeDeviceSettingsProto> device_settings) { |
| 253 device_settings_ = device_settings.Pass(); | 256 device_settings_ = device_settings.Pass(); |
| 254 } | 257 } |
| 255 | 258 |
| 256 SessionManagerClient* session_manager_client_; | 259 SessionManagerClient* session_manager_client_; |
| 257 scoped_refptr<OwnerKeyUtil> owner_key_util_; | 260 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; |
| 258 | 261 |
| 259 Status store_status_; | 262 Status store_status_; |
| 260 | 263 |
| 261 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; | 264 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; |
| 262 | 265 |
| 263 std::string username_; | 266 std::string username_; |
| 264 scoped_refptr<PublicKey> public_key_; | 267 scoped_refptr<ownership::PublicKey> public_key_; |
| 265 base::WeakPtr<PrivateKeyDelegate> delegate_; | 268 base::WeakPtr<PrivateKeyDelegate> delegate_; |
| 266 | 269 |
| 267 scoped_ptr<enterprise_management::PolicyData> policy_data_; | 270 scoped_ptr<enterprise_management::PolicyData> policy_data_; |
| 268 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; | 271 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; |
| 269 | 272 |
| 270 // The queue of pending operations. The first operation on the queue is | 273 // The queue of pending operations. The first operation on the queue is |
| 271 // currently active; it gets removed and destroyed once it completes. | 274 // currently active; it gets removed and destroyed once it completes. |
| 272 std::deque<SessionManagerOperation*> pending_operations_; | 275 std::deque<SessionManagerOperation*> pending_operations_; |
| 273 | 276 |
| 274 ObserverList<Observer, true> observers_; | 277 ObserverList<Observer, true> observers_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 288 ScopedTestDeviceSettingsService(); | 291 ScopedTestDeviceSettingsService(); |
| 289 ~ScopedTestDeviceSettingsService(); | 292 ~ScopedTestDeviceSettingsService(); |
| 290 | 293 |
| 291 private: | 294 private: |
| 292 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); | 295 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); |
| 293 }; | 296 }; |
| 294 | 297 |
| 295 } // namespace chromeos | 298 } // namespace chromeos |
| 296 | 299 |
| 297 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 300 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
| OLD | NEW |