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

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: Small fix: removed redundant check. 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) {
237 if (username_ == username)
238 return;
239
240 if (owner_key_.get() && owner_key_->public_key() && owner_key_->private_key())
241 return;
Mattias Nissler (ping if slow) 2014/05/15 11:21:29 I think we should replaces these two checks with t
ygorshenin1 2014/05/15 11:58:37 Done.
242
236 username_ = username; 243 username_ = username;
244 slot_ = slot.Pass();
237 245
238 // The private key may have become available, so force a key reload. 246 // The private key may have become available, so force a key reload.
239 owner_key_ = NULL; 247 owner_key_ = NULL;
240 EnsureReload(true); 248 EnsureReload(true);
241 } 249 }
242 250
243 const std::string& DeviceSettingsService::GetUsername() const { 251 const std::string& DeviceSettingsService::GetUsername() const {
244 return username_; 252 return username_;
245 } 253 }
246 254
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 StartNextOperation(); 293 StartNextOperation();
286 } 294 }
287 295
288 void DeviceSettingsService::EnqueueLoad(bool force_key_load) { 296 void DeviceSettingsService::EnqueueLoad(bool force_key_load) {
289 SessionManagerOperation* operation = 297 SessionManagerOperation* operation =
290 new LoadSettingsOperation( 298 new LoadSettingsOperation(
291 base::Bind(&DeviceSettingsService::HandleCompletedOperation, 299 base::Bind(&DeviceSettingsService::HandleCompletedOperation,
292 weak_factory_.GetWeakPtr(), 300 weak_factory_.GetWeakPtr(),
293 base::Closure())); 301 base::Closure()));
294 operation->set_force_key_load(force_key_load); 302 operation->set_force_key_load(force_key_load);
303 operation->set_username(username_);
304 operation->set_slot(slot_.get());
295 Enqueue(operation); 305 Enqueue(operation);
296 } 306 }
297 307
298 void DeviceSettingsService::EnsureReload(bool force_key_load) { 308 void DeviceSettingsService::EnsureReload(bool force_key_load) {
299 if (!pending_operations_.empty()) 309 if (!pending_operations_.empty()) {
310 pending_operations_.front()->set_username(username_);
311 pending_operations_.front()->set_slot(slot_.get());
300 pending_operations_.front()->RestartLoad(force_key_load); 312 pending_operations_.front()->RestartLoad(force_key_load);
301 else 313 } else {
302 EnqueueLoad(force_key_load); 314 EnqueueLoad(force_key_load);
315 }
303 } 316 }
304 317
305 void DeviceSettingsService::StartNextOperation() { 318 void DeviceSettingsService::StartNextOperation() {
306 if (!pending_operations_.empty() && 319 if (!pending_operations_.empty() &&
307 session_manager_client_ && 320 session_manager_client_ &&
308 owner_key_util_.get()) { 321 owner_key_util_.get()) {
309 pending_operations_.front()->Start(session_manager_client_, 322 pending_operations_.front()->Start(session_manager_client_,
310 owner_key_util_, owner_key_); 323 owner_key_util_, owner_key_);
311 } 324 }
312 } 325 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 DeviceSettingsService::Initialize(); 487 DeviceSettingsService::Initialize();
475 } 488 }
476 489
477 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { 490 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() {
478 // Clean pending operations. 491 // Clean pending operations.
479 DeviceSettingsService::Get()->UnsetSessionManager(); 492 DeviceSettingsService::Get()->UnsetSessionManager();
480 DeviceSettingsService::Shutdown(); 493 DeviceSettingsService::Shutdown();
481 } 494 }
482 495
483 } // namespace chromeos 496 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698