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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_get_keys_operati
on.h" | 16 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_get_keys_operati
on.h" |
17 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_ope
ration.h" | 17 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_ope
ration.h" |
18 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" | 18 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class DictionaryValue; | 21 class DictionaryValue; |
22 class ListValue; | 22 class ListValue; |
23 } | 23 } |
24 | 24 |
| 25 namespace user_manager { |
| 26 class UserID; |
| 27 } |
| 28 |
25 namespace chromeos { | 29 namespace chromeos { |
26 | 30 |
27 class UserContext; | 31 class UserContext; |
28 | 32 |
29 // A class to manage Easy unlock cryptohome keys. | 33 // A class to manage Easy unlock cryptohome keys. |
30 class EasyUnlockKeyManager { | 34 class EasyUnlockKeyManager { |
31 public: | 35 public: |
32 typedef EasyUnlockRefreshKeysOperation::RefreshKeysCallback | 36 typedef EasyUnlockRefreshKeysOperation::RefreshKeysCallback |
33 RefreshKeysCallback; | 37 RefreshKeysCallback; |
34 typedef EasyUnlockGetKeysOperation::GetKeysCallback GetDeviceDataListCallback; | 38 typedef EasyUnlockGetKeysOperation::GetKeysCallback GetDeviceDataListCallback; |
(...skipping 12 matching lines...) Expand all Loading... |
47 // |user_context|. | 51 // |user_context|. |
48 void GetDeviceDataList(const UserContext& user_context, | 52 void GetDeviceDataList(const UserContext& user_context, |
49 const GetDeviceDataListCallback& callback); | 53 const GetDeviceDataListCallback& callback); |
50 | 54 |
51 // Helpers to convert between DeviceData and remote device dictionary. | 55 // Helpers to convert between DeviceData and remote device dictionary. |
52 // DeviceDataToRemoteDeviceDictionary fills the remote device dictionary and | 56 // DeviceDataToRemoteDeviceDictionary fills the remote device dictionary and |
53 // always succeeds. RemoteDeviceDictionaryToDeviceData returns false if the | 57 // always succeeds. RemoteDeviceDictionaryToDeviceData returns false if the |
54 // conversion fails (missing required propery). Note that | 58 // conversion fails (missing required propery). Note that |
55 // EasyUnlockDeviceKeyData contains a sub set of the remote device dictionary. | 59 // EasyUnlockDeviceKeyData contains a sub set of the remote device dictionary. |
56 static void DeviceDataToRemoteDeviceDictionary( | 60 static void DeviceDataToRemoteDeviceDictionary( |
57 const std::string& user_id, | 61 const user_manager::UserID& user_id, |
58 const EasyUnlockDeviceKeyData& data, | 62 const EasyUnlockDeviceKeyData& data, |
59 base::DictionaryValue* dict); | 63 base::DictionaryValue* dict); |
60 static bool RemoteDeviceDictionaryToDeviceData( | 64 static bool RemoteDeviceDictionaryToDeviceData( |
61 const base::DictionaryValue& dict, | 65 const base::DictionaryValue& dict, |
62 EasyUnlockDeviceKeyData* data); | 66 EasyUnlockDeviceKeyData* data); |
63 | 67 |
64 // Helpers to convert between EasyUnlockDeviceKeyDataList and remote devices | 68 // Helpers to convert between EasyUnlockDeviceKeyDataList and remote devices |
65 // ListValue. | 69 // ListValue. |
66 static void DeviceDataListToRemoteDeviceList( | 70 static void DeviceDataListToRemoteDeviceList( |
67 const std::string& user_id, | 71 const user_manager::UserID& user_id, |
68 const EasyUnlockDeviceKeyDataList& data_list, | 72 const EasyUnlockDeviceKeyDataList& data_list, |
69 base::ListValue* device_list); | 73 base::ListValue* device_list); |
70 static bool RemoteDeviceListToDeviceDataList( | 74 static bool RemoteDeviceListToDeviceDataList( |
71 const base::ListValue& device_list, | 75 const base::ListValue& device_list, |
72 EasyUnlockDeviceKeyDataList* data_list); | 76 EasyUnlockDeviceKeyDataList* data_list); |
73 | 77 |
74 // Gets key label for the given key index. | 78 // Gets key label for the given key index. |
75 static std::string GetKeyLabel(size_t key_index); | 79 static std::string GetKeyLabel(size_t key_index); |
76 | 80 |
77 private: | 81 private: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 scoped_ptr<EasyUnlockGetKeysOperation> pending_read_operation_; | 119 scoped_ptr<EasyUnlockGetKeysOperation> pending_read_operation_; |
116 | 120 |
117 base::WeakPtrFactory<EasyUnlockKeyManager> weak_ptr_factory_; | 121 base::WeakPtrFactory<EasyUnlockKeyManager> weak_ptr_factory_; |
118 | 122 |
119 DISALLOW_COPY_AND_ASSIGN(EasyUnlockKeyManager); | 123 DISALLOW_COPY_AND_ASSIGN(EasyUnlockKeyManager); |
120 }; | 124 }; |
121 | 125 |
122 } // namespace chromeos | 126 } // namespace chromeos |
123 | 127 |
124 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_ | 128 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_KEY_MANAGER_H_ |
OLD | NEW |