| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H | 5 #ifndef COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H |
| 6 #define COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H | 6 #define COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "components/cryptauth/proto/cryptauth_api.pb.h" | 14 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| 15 #include "components/proximity_auth/remote_device.h" | 15 #include "components/cryptauth/remote_device.h" |
| 16 | 16 |
| 17 namespace cryptauth { | 17 namespace cryptauth { |
| 18 class SecureMessageDelegate; | 18 class SecureMessageDelegate; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace proximity_auth { | 21 namespace proximity_auth { |
| 22 | 22 |
| 23 class ProximityAuthPrefManager; | 23 class ProximityAuthPrefManager; |
| 24 | 24 |
| 25 // Loads a collection of RemoteDevice objects from the given ExternalDeviceInfo | 25 // Loads a collection of RemoteDevice objects from the given ExternalDeviceInfo |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 RemoteDeviceLoader( | 36 RemoteDeviceLoader( |
| 37 const std::vector<cryptauth::ExternalDeviceInfo>& unlock_keys, | 37 const std::vector<cryptauth::ExternalDeviceInfo>& unlock_keys, |
| 38 const std::string& user_id, | 38 const std::string& user_id, |
| 39 const std::string& user_private_key, | 39 const std::string& user_private_key, |
| 40 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate, | 40 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate, |
| 41 ProximityAuthPrefManager* pref_manager); | 41 ProximityAuthPrefManager* pref_manager); |
| 42 | 42 |
| 43 ~RemoteDeviceLoader(); | 43 ~RemoteDeviceLoader(); |
| 44 | 44 |
| 45 // Loads the RemoteDevice objects. |callback| will be invoked upon completion. | 45 // Loads the RemoteDevice objects. |callback| will be invoked upon completion. |
| 46 typedef base::Callback<void(const RemoteDeviceList&)> RemoteDeviceCallback; | 46 typedef base::Callback<void(const cryptauth::RemoteDeviceList&)> |
| 47 RemoteDeviceCallback; |
| 47 void Load(const RemoteDeviceCallback& callback); | 48 void Load(const RemoteDeviceCallback& callback); |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 // Called when the PSK is derived for each unlock key. If the PSK for all | 51 // Called when the PSK is derived for each unlock key. If the PSK for all |
| 51 // unlock have been derived, then we can invoke |callback_|. | 52 // unlock have been derived, then we can invoke |callback_|. |
| 52 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key, | 53 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key, |
| 53 const std::string& psk); | 54 const std::string& psk); |
| 54 | 55 |
| 55 // The remaining unlock keys whose PSK we're waiting on. | 56 // The remaining unlock keys whose PSK we're waiting on. |
| 56 std::vector<cryptauth::ExternalDeviceInfo> remaining_unlock_keys_; | 57 std::vector<cryptauth::ExternalDeviceInfo> remaining_unlock_keys_; |
| 57 | 58 |
| 58 // The id of the user who the remote devices belong to. | 59 // The id of the user who the remote devices belong to. |
| 59 const std::string user_id_; | 60 const std::string user_id_; |
| 60 | 61 |
| 61 // The private key of the user's local device. | 62 // The private key of the user's local device. |
| 62 const std::string user_private_key_; | 63 const std::string user_private_key_; |
| 63 | 64 |
| 64 // Performs the PSK key derivation. | 65 // Performs the PSK key derivation. |
| 65 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate_; | 66 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate_; |
| 66 | 67 |
| 67 // Used to retrieve the address for BLE devices. Not owned. | 68 // Used to retrieve the address for BLE devices. Not owned. |
| 68 ProximityAuthPrefManager* pref_manager_; | 69 ProximityAuthPrefManager* pref_manager_; |
| 69 | 70 |
| 70 // Invoked when the RemoteDevices are loaded. | 71 // Invoked when the RemoteDevices are loaded. |
| 71 RemoteDeviceCallback callback_; | 72 RemoteDeviceCallback callback_; |
| 72 | 73 |
| 73 // The collection of RemoteDevices to return. | 74 // The collection of RemoteDevices to return. |
| 74 RemoteDeviceList remote_devices_; | 75 cryptauth::RemoteDeviceList remote_devices_; |
| 75 | 76 |
| 76 base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_; | 77 base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_; |
| 77 | 78 |
| 78 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader); | 79 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace proximity_auth | 82 } // namespace proximity_auth |
| 82 | 83 |
| 83 #endif // COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H | 84 #endif // COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H |
| OLD | NEW |