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
3 // found in the LICENSE file.
6 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_operation.h"
7 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.h"
8 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_remove_keys_operation.h"
12 EasyUnlockRefreshKeysOperation::EasyUnlockRefreshKeysOperation(
13 const UserContext
& user_context
,
14 const std::string
& tpm_public_key
,
15 const EasyUnlockDeviceKeyDataList
& devices
,
16 const RefreshKeysCallback
& callback
)
17 : user_context_(user_context
),
18 tpm_public_key_(tpm_public_key
),
21 weak_ptr_factory_(this) {
24 EasyUnlockRefreshKeysOperation::~EasyUnlockRefreshKeysOperation() {
27 void EasyUnlockRefreshKeysOperation::Start() {
28 if (devices_
.empty()) {
33 create_keys_operation_
.reset(new EasyUnlockCreateKeysOperation(
34 user_context_
, tpm_public_key_
, devices_
,
35 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysCreated
,
36 weak_ptr_factory_
.GetWeakPtr())));
37 create_keys_operation_
->Start();
40 void EasyUnlockRefreshKeysOperation::OnKeysCreated(bool success
) {
46 // Update the user context to have the new authorization key after the create
47 // keys operation. This is necessary because the old authorization key
48 // associated with the user context will be invalidated after the create keys
50 if (create_keys_operation_
)
51 user_context_
= create_keys_operation_
->user_context();
53 remove_keys_operation_
.reset(new EasyUnlockRemoveKeysOperation(
54 user_context_
, devices_
.size(),
55 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysRemoved
,
56 weak_ptr_factory_
.GetWeakPtr())));
57 remove_keys_operation_
->Start();
60 void EasyUnlockRefreshKeysOperation::OnKeysRemoved(bool success
) {
61 callback_
.Run(success
);
64 } // namespace chromeos