easy_unlock_remove_keys_operation.h revision 34680572440d7894ef8dafce81d8039ed80726a2
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#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_REMOVE_KEYS_OPERATION_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_REMOVE_KEYS_OPERATION_H_
7
8#include "base/callback.h"
9#include "base/macros.h"
10#include "base/memory/weak_ptr.h"
11#include "chromeos/login/auth/user_context.h"
12#include "third_party/cros_system_api/dbus/service_constants.h"
13
14namespace chromeos {
15
16class UserContext;
17
18// A class to remove existing Easy unlock cryptohome keys starting at given
19// index.
20class EasyUnlockRemoveKeysOperation {
21 public:
22  typedef base::Callback<void (bool success)> RemoveKeysCallback;
23  EasyUnlockRemoveKeysOperation(
24      const UserContext& user_context,
25      size_t start_index,
26      const RemoveKeysCallback& callback);
27  ~EasyUnlockRemoveKeysOperation();
28
29  void Start();
30
31 private:
32  void OnGetSystemSalt(const std::string& system_salt);
33
34  void RemoveKey();
35  void OnKeyRemoved(bool success, cryptohome::MountError return_code);
36
37  UserContext user_context_;
38  RemoveKeysCallback callback_;
39  size_t key_index_;
40  base::WeakPtrFactory<EasyUnlockRemoveKeysOperation> weak_ptr_factory_;
41
42  DISALLOW_COPY_AND_ASSIGN(EasyUnlockRemoveKeysOperation);
43};
44
45}  // namespace chromeos
46
47#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_REMOVE_KEYS_OPERATION_H_
48