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

Unified Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h

Issue 554043003: cros: Create cryptohome keys for Easy sign-in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comments in #2 Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..7cc34bbadcab4350be9c5ae8732458a2c3ce6eea
--- /dev/null
+++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
@@ -0,0 +1,101 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_operation.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_get_keys_operation.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_remove_keys_operation.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h"
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+}
+
+namespace chromeos {
+
+class UserContext;
+
+// A class to manage Easy unlock cryptohome keys.
+class EasyUnlockKeyManager {
+ public:
+ typedef EasyUnlockCreateKeysOperation::CreateKeysCallback CreateKeysCallback;
+ typedef EasyUnlockRemoveKeysOperation::RemoveKeysCallback RemoveKeysCallback;
+ typedef EasyUnlockGetKeysOperation::GetKeysCallback GetDeviceDataListCallback;
+
+ EasyUnlockKeyManager();
+ ~EasyUnlockKeyManager();
+
+ // Nukes existing Easy unlock keys and creates new ones for the given
+ // |remote_devices| and the given |user_context|. |user_context| must have
+ // secret to allow keys to be created.
+ void RefreshKeys(const UserContext& user_context,
+ const base::ListValue& remote_devices,
+ const CreateKeysCallback& callback);
+
+ // Remove all Easy unlock keys for the given |user_context|.
+ void RemoveKeys(const UserContext& user_context,
+ const RemoveKeysCallback& callback);
+
+ // Retrieves the remote device data from cryptohome keys for the given
+ // |user_context|.
+ void GetDeviceDataList(const UserContext& user_context,
+ const GetDeviceDataListCallback& callback);
+
+ // Helpers to convert between DeivceData and remote device dictionary. Returns
+ // false if the conversion fails. Note that EasyUnlockDeviceKeyData contains a
tbarzic 2014/09/09 20:52:24 nit: Comment says the method returns false in case
xiyuan 2014/09/09 21:13:53 Comments updated.
+ // sub set of the remote device dictionary.
+ static void DeviceDataToRemoteDeviceDictionary(
+ const EasyUnlockDeviceKeyData& data,
+ base::DictionaryValue* dict);
+ static bool RemoteDeviceDictionaryToDeviceData(
tbarzic 2014/09/09 20:52:24 nit: can you add a comment that in case of an erro
xiyuan 2014/09/09 21:13:54 Updated so that the output |data| is only updated
+ const base::DictionaryValue& dict,
+ EasyUnlockDeviceKeyData* data);
+
+ // Helpers to convert between EasyUnlockDeviceKeyDataList and remote devices
+ // ListValue.
+ static void DeviceDataListToRemoteDeviceList(
+ const EasyUnlockDeviceKeyDataList& data_list,
+ base::ListValue* device_list);
+ static bool RemoteDeviceListToDeviceDataList(
+ const base::ListValue& device_list,
+ EasyUnlockDeviceKeyDataList* data_list);
+
+ // Gets key label for the given key index.
+ static std::string GetKeyLabel(size_t key_index);
+
+ private:
+ void OnKeysRemovedForCreateKeys(const UserContext& user_context,
+ const EasyUnlockDeviceKeyDataList& devices,
+ const CreateKeysCallback& callback,
+ bool remove_success);
+ void OnKeysCreated(const CreateKeysCallback& callback, bool create_success);
+
+ void OnKeysRemoved(const RemoveKeysCallback& callback, bool remove_success);
+
+ void OnKeysFetched(const GetDeviceDataListCallback& callback,
+ bool fetch_success,
+ const EasyUnlockDeviceKeyDataList& fetched_data);
+
+ scoped_ptr<EasyUnlockCreateKeysOperation> create_keys_op_;
+ scoped_ptr<EasyUnlockRemoveKeysOperation> remove_keys_op_;
+ scoped_ptr<EasyUnlockGetKeysOperation> get_keys_op_;
+
+ base::WeakPtrFactory<EasyUnlockKeyManager> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(EasyUnlockKeyManager);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698