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 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 5 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } else { | 225 } else { |
226 // If the key hasn't been loaded with the known certificates, enqueue the | 226 // If the key hasn't been loaded with the known certificates, enqueue the |
227 // callback to be fired when the next SessionManagerOperation completes in | 227 // callback to be fired when the next SessionManagerOperation completes in |
228 // an environment where the certificates are loaded. There is no need to | 228 // an environment where the certificates are loaded. There is no need to |
229 // start a new operation, as the reload operation will be started when the | 229 // start a new operation, as the reload operation will be started when the |
230 // certificates are loaded. | 230 // certificates are loaded. |
231 pending_is_current_user_owner_callbacks_.push_back(callback); | 231 pending_is_current_user_owner_callbacks_.push_back(callback); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 void DeviceSettingsService::SetUsername(const std::string& username) { | 235 void DeviceSettingsService::InitOwner(const std::string& username, |
| 236 crypto::ScopedPK11Slot slot) { |
| 237 if (!username_.empty()) |
| 238 return; |
| 239 |
236 username_ = username; | 240 username_ = username; |
| 241 slot_ = slot.Pass(); |
237 | 242 |
238 // The private key may have become available, so force a key reload. | 243 // The private key may have become available, so force a key reload. |
239 owner_key_ = NULL; | 244 owner_key_ = NULL; |
240 EnsureReload(true); | 245 EnsureReload(true); |
241 } | 246 } |
242 | 247 |
243 const std::string& DeviceSettingsService::GetUsername() const { | 248 const std::string& DeviceSettingsService::GetUsername() const { |
244 return username_; | 249 return username_; |
245 } | 250 } |
246 | 251 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 StartNextOperation(); | 290 StartNextOperation(); |
286 } | 291 } |
287 | 292 |
288 void DeviceSettingsService::EnqueueLoad(bool force_key_load) { | 293 void DeviceSettingsService::EnqueueLoad(bool force_key_load) { |
289 SessionManagerOperation* operation = | 294 SessionManagerOperation* operation = |
290 new LoadSettingsOperation( | 295 new LoadSettingsOperation( |
291 base::Bind(&DeviceSettingsService::HandleCompletedOperation, | 296 base::Bind(&DeviceSettingsService::HandleCompletedOperation, |
292 weak_factory_.GetWeakPtr(), | 297 weak_factory_.GetWeakPtr(), |
293 base::Closure())); | 298 base::Closure())); |
294 operation->set_force_key_load(force_key_load); | 299 operation->set_force_key_load(force_key_load); |
| 300 operation->set_username(username_); |
| 301 operation->set_slot(slot_.get()); |
295 Enqueue(operation); | 302 Enqueue(operation); |
296 } | 303 } |
297 | 304 |
298 void DeviceSettingsService::EnsureReload(bool force_key_load) { | 305 void DeviceSettingsService::EnsureReload(bool force_key_load) { |
299 if (!pending_operations_.empty()) | 306 if (!pending_operations_.empty()) { |
| 307 pending_operations_.front()->set_username(username_); |
| 308 pending_operations_.front()->set_slot(slot_.get()); |
300 pending_operations_.front()->RestartLoad(force_key_load); | 309 pending_operations_.front()->RestartLoad(force_key_load); |
301 else | 310 } else { |
302 EnqueueLoad(force_key_load); | 311 EnqueueLoad(force_key_load); |
| 312 } |
303 } | 313 } |
304 | 314 |
305 void DeviceSettingsService::StartNextOperation() { | 315 void DeviceSettingsService::StartNextOperation() { |
306 if (!pending_operations_.empty() && | 316 if (!pending_operations_.empty() && |
307 session_manager_client_ && | 317 session_manager_client_ && |
308 owner_key_util_.get()) { | 318 owner_key_util_.get()) { |
309 pending_operations_.front()->Start(session_manager_client_, | 319 pending_operations_.front()->Start(session_manager_client_, |
310 owner_key_util_, owner_key_); | 320 owner_key_util_, owner_key_); |
311 } | 321 } |
312 } | 322 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 DeviceSettingsService::Initialize(); | 484 DeviceSettingsService::Initialize(); |
475 } | 485 } |
476 | 486 |
477 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { | 487 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { |
478 // Clean pending operations. | 488 // Clean pending operations. |
479 DeviceSettingsService::Get()->UnsetSessionManager(); | 489 DeviceSettingsService::Get()->UnsetSessionManager(); |
480 DeviceSettingsService::Shutdown(); | 490 DeviceSettingsService::Shutdown(); |
481 } | 491 } |
482 | 492 |
483 } // namespace chromeos | 493 } // namespace chromeos |
OLD | NEW |