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

Unified Diff: components/proximity_auth/webui/proximity_auth_webui_handler.cc

Issue 1356943004: Add RemoteDeviceLoader to create RemoteDevice from CryptAuth data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webui
Patch Set: move RemoteDevice creation in tests to util function Created 5 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
« no previous file with comments | « components/proximity_auth/webui/proximity_auth_webui_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/webui/proximity_auth_webui_handler.cc
diff --git a/components/proximity_auth/webui/proximity_auth_webui_handler.cc b/components/proximity_auth/webui/proximity_auth_webui_handler.cc
index d5dc18b81fcf741930ae9ec88654d1c55f100c42..14f817c94b08eb94e2275686373e4cdc06b96636 100644
--- a/components/proximity_auth/webui/proximity_auth_webui_handler.cc
+++ b/components/proximity_auth/webui/proximity_auth_webui_handler.cc
@@ -22,6 +22,7 @@
#include "components/proximity_auth/logging/logging.h"
#include "components/proximity_auth/messenger.h"
#include "components/proximity_auth/remote_device_life_cycle_impl.h"
+#include "components/proximity_auth/remote_device_loader.h"
#include "components/proximity_auth/remote_status_update.h"
#include "components/proximity_auth/secure_context.h"
#include "components/proximity_auth/webui/reachable_phone_flow.h"
@@ -344,16 +345,14 @@ void ProximityAuthWebUIHandler::ToggleConnection(const base::ListValue* args) {
return;
}
- // Derive the PSK before connecting to the device.
- PA_LOG(INFO) << "Deriving PSK before connecting to "
- << unlock_key.friendly_device_name();
- secure_message_delegate_ =
- proximity_auth_client_->CreateSecureMessageDelegate();
- secure_message_delegate_->DeriveKey(
- enrollment_manager->GetUserPrivateKey(), unlock_key.public_key(),
- base::Bind(&ProximityAuthWebUIHandler::OnPSKDerived,
- weak_ptr_factory_.GetWeakPtr(), unlock_key));
-
+ remote_device_loader_.reset(new RemoteDeviceLoader(
+ std::vector<cryptauth::ExternalDeviceInfo>(1, unlock_key),
+ proximity_auth_client_->GetAccountId(),
+ enrollment_manager->GetUserPrivateKey(),
+ proximity_auth_client_->CreateSecureMessageDelegate()));
+ remote_device_loader_->Load(
+ base::Bind(&ProximityAuthWebUIHandler::OnRemoteDevicesLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
return;
}
}
@@ -462,18 +461,14 @@ scoped_ptr<base::ListValue> ProximityAuthWebUIHandler::GetUnlockKeysList() {
return unlock_keys;
}
-void ProximityAuthWebUIHandler::OnPSKDerived(
- const cryptauth::ExternalDeviceInfo& unlock_key,
- const std::string& persistent_symmetric_key) {
- if (persistent_symmetric_key.empty()) {
+void ProximityAuthWebUIHandler::OnRemoteDevicesLoaded(
+ const std::vector<RemoteDevice>& remote_devices) {
+ if (remote_devices[0].persistent_symmetric_key.empty()) {
PA_LOG(ERROR) << "Failed to derive PSK.";
return;
}
- selected_remote_device_ =
- RemoteDevice(unlock_key.friendly_device_name(), unlock_key.public_key(),
- unlock_key.bluetooth_address(), persistent_symmetric_key);
-
+ selected_remote_device_ = remote_devices[0];
life_cycle_.reset(new RemoteDeviceLifeCycleImpl(selected_remote_device_,
proximity_auth_client_));
life_cycle_->AddObserver(this);
« no previous file with comments | « components/proximity_auth/webui/proximity_auth_webui_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698