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

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.cc

Issue 808563004: Clean up Smart Lock cryptohome keys logic: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use UserContext after create keys operation Created 6 years 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
OLDNEW
(Empty)
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.
4
5 #include "base/bind.h"
6 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_oper ation.h"
7 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_ope ration.h"
8 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_remove_keys_oper ation.h"
9
10 namespace chromeos {
11
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),
19 devices_(devices),
20 callback_(callback),
21 weak_ptr_factory_(this) {
22 }
23
24 EasyUnlockRefreshKeysOperation::~EasyUnlockRefreshKeysOperation() {
25 }
26
27 void EasyUnlockRefreshKeysOperation::Start() {
28 if (devices_.empty()) {
29 OnKeysCreated(true);
30 return;
31 }
32
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();
38 }
39
40 void EasyUnlockRefreshKeysOperation::OnKeysCreated(bool success) {
41 if (!success) {
42 callback_.Run(false);
43 return;
44 }
45
46 // Update the user context to have the new authorization keys after the create
47 // keys operation.
48 if (create_keys_operation_)
49 user_context_ = create_keys_operation_->user_context();
50
51 remove_keys_operation_.reset(new EasyUnlockRemoveKeysOperation(
52 user_context_, devices_.size(),
53 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysRemoved,
54 weak_ptr_factory_.GetWeakPtr())));
55 remove_keys_operation_->Start();
56 }
57
58 void EasyUnlockRefreshKeysOperation::OnKeysRemoved(bool success) {
59 callback_.Run(success);
60 }
61
62 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698