OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/easy_unlock/easy_unlock_create_keys_oper
ation.h" | 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_oper
ation.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 cryptohome::Identification id(canonicalized); | 337 cryptohome::Identification id(canonicalized); |
338 const Key* const auth_key = user_context_.GetKey(); | 338 const Key* const auth_key = user_context_.GetKey(); |
339 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); | 339 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); |
340 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( | 340 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( |
341 id, | 341 id, |
342 auth, | 342 auth, |
343 key_def, | 343 key_def, |
344 true, // clobber | 344 true, // clobber |
345 base::Bind(&EasyUnlockCreateKeysOperation::OnKeyCreated, | 345 base::Bind(&EasyUnlockCreateKeysOperation::OnKeyCreated, |
346 weak_ptr_factory_.GetWeakPtr(), | 346 weak_ptr_factory_.GetWeakPtr(), |
347 index)); | 347 index, |
| 348 user_key)); |
348 } | 349 } |
349 | 350 |
350 void EasyUnlockCreateKeysOperation::OnKeyCreated( | 351 void EasyUnlockCreateKeysOperation::OnKeyCreated( |
351 size_t index, | 352 size_t index, |
| 353 const Key& user_key, |
352 bool success, | 354 bool success, |
353 cryptohome::MountError return_code) { | 355 cryptohome::MountError return_code) { |
354 DCHECK_EQ(key_creation_index_, index); | 356 DCHECK_EQ(key_creation_index_, index); |
355 | 357 |
356 if (!success) { | 358 if (!success) { |
357 LOG(ERROR) << "Easy unlock failed to create key, code=" << return_code; | 359 LOG(ERROR) << "Easy unlock failed to create key, code=" << return_code; |
358 callback_.Run(false); | 360 callback_.Run(false); |
359 return; | 361 return; |
360 } | 362 } |
361 | 363 |
| 364 // Update user context when the key used for signing in is changed. |
| 365 if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_EASY_UNLOCK && |
| 366 user_context_.GetKey()->GetLabel() == |
| 367 EasyUnlockKeyManager::GetKeyLabel(key_creation_index_)) { |
| 368 user_context_.SetKey(user_key); |
| 369 } |
| 370 |
362 ++key_creation_index_; | 371 ++key_creation_index_; |
363 CreateKeyForDeviceAtIndex(key_creation_index_); | 372 CreateKeyForDeviceAtIndex(key_creation_index_); |
364 } | 373 } |
365 | 374 |
366 } // namespace chromeos | 375 } // namespace chromeos |
OLD | NEW |