Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_service.cc

Issue 270663002: Implemented profile-aware owner key loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) {
236 username_ = username; 237 username_ = username;
238 slot_.reset(slot.release());
Mattias Nissler (ping if slow) 2014/05/13 11:55:53 nit: slot_ = slot.Pass();
ygorshenin1 2014/05/14 09:10:58 Done.
237 239
238 // The private key may have become available, so force a key reload. 240 // The private key may have become available, so force a key reload.
239 owner_key_ = NULL; 241 owner_key_ = NULL;
240 EnsureReload(true); 242 EnsureReload(true);
241 } 243 }
242 244
243 const std::string& DeviceSettingsService::GetUsername() const { 245 const std::string& DeviceSettingsService::GetUsername() const {
244 return username_; 246 return username_;
245 } 247 }
246 248
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 StartNextOperation(); 287 StartNextOperation();
286 } 288 }
287 289
288 void DeviceSettingsService::EnqueueLoad(bool force_key_load) { 290 void DeviceSettingsService::EnqueueLoad(bool force_key_load) {
289 SessionManagerOperation* operation = 291 SessionManagerOperation* operation =
290 new LoadSettingsOperation( 292 new LoadSettingsOperation(
291 base::Bind(&DeviceSettingsService::HandleCompletedOperation, 293 base::Bind(&DeviceSettingsService::HandleCompletedOperation,
292 weak_factory_.GetWeakPtr(), 294 weak_factory_.GetWeakPtr(),
293 base::Closure())); 295 base::Closure()));
294 operation->set_force_key_load(force_key_load); 296 operation->set_force_key_load(force_key_load);
297 operation->set_username(username_);
298 operation->set_slot(slot_.get());
295 Enqueue(operation); 299 Enqueue(operation);
296 } 300 }
297 301
298 void DeviceSettingsService::EnsureReload(bool force_key_load) { 302 void DeviceSettingsService::EnsureReload(bool force_key_load) {
299 if (!pending_operations_.empty()) 303 if (!pending_operations_.empty()) {
304 pending_operations_.front()->set_username(username_);
305 pending_operations_.front()->set_slot(slot_.get());
300 pending_operations_.front()->RestartLoad(force_key_load); 306 pending_operations_.front()->RestartLoad(force_key_load);
301 else 307 } else {
302 EnqueueLoad(force_key_load); 308 EnqueueLoad(force_key_load);
309 }
303 } 310 }
304 311
305 void DeviceSettingsService::StartNextOperation() { 312 void DeviceSettingsService::StartNextOperation() {
306 if (!pending_operations_.empty() && 313 if (!pending_operations_.empty() &&
307 session_manager_client_ && 314 session_manager_client_ &&
308 owner_key_util_.get()) { 315 owner_key_util_.get()) {
309 pending_operations_.front()->Start(session_manager_client_, 316 pending_operations_.front()->Start(session_manager_client_,
310 owner_key_util_, owner_key_); 317 owner_key_util_, owner_key_);
311 } 318 }
312 } 319 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 DeviceSettingsService::Initialize(); 481 DeviceSettingsService::Initialize();
475 } 482 }
476 483
477 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { 484 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() {
478 // Clean pending operations. 485 // Clean pending operations.
479 DeviceSettingsService::Get()->UnsetSessionManager(); 486 DeviceSettingsService::Get()->UnsetSessionManager();
480 DeviceSettingsService::Shutdown(); 487 DeviceSettingsService::Shutdown();
481 } 488 }
482 489
483 } // namespace chromeos 490 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698