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

Side by Side Diff: components/proximity_auth/webui/proximity_auth_webui_handler.cc

Issue 2561683002: Update CryptAuthDeviceManager to store all synced devices instead of only unlock keys. (Closed)
Patch Set: tengs@ comments. Created 4 years 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 unified diff | Download patch
« no previous file with comments | « components/cryptauth/cryptauth_device_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/proximity_auth/webui/proximity_auth_webui_handler.h" 5 #include "components/proximity_auth/webui/proximity_auth_webui_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64url.h" 10 #include "base/base64url.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 std::string b64_public_key; 334 std::string b64_public_key;
335 std::string public_key; 335 std::string public_key;
336 if (!enrollment_manager || !device_manager || !args->GetSize() || 336 if (!enrollment_manager || !device_manager || !args->GetSize() ||
337 !args->GetString(0, &b64_public_key) || 337 !args->GetString(0, &b64_public_key) ||
338 !base::Base64UrlDecode(b64_public_key, 338 !base::Base64UrlDecode(b64_public_key,
339 base::Base64UrlDecodePolicy::REQUIRE_PADDING, 339 base::Base64UrlDecodePolicy::REQUIRE_PADDING,
340 &public_key)) { 340 &public_key)) {
341 return; 341 return;
342 } 342 }
343 343
344 for (const auto& unlock_key : device_manager->unlock_keys()) { 344 for (const auto& unlock_key : device_manager->GetUnlockKeys()) {
345 if (unlock_key.public_key() == public_key) { 345 if (unlock_key.public_key() == public_key) {
346 if (life_cycle_ && selected_remote_device_.public_key == public_key) { 346 if (life_cycle_ && selected_remote_device_.public_key == public_key) {
347 CleanUpRemoteDeviceLifeCycle(); 347 CleanUpRemoteDeviceLifeCycle();
348 return; 348 return;
349 } 349 }
350 350
351 // TODO(sacomoto): Pass an instance of ProximityAuthPrefManager. This is 351 // TODO(sacomoto): Pass an instance of ProximityAuthPrefManager. This is
352 // used to get the address of BLE devices. 352 // used to get the address of BLE devices.
353 remote_device_loader_.reset(new RemoteDeviceLoader( 353 remote_device_loader_.reset(new RemoteDeviceLoader(
354 std::vector<cryptauth::ExternalDeviceInfo>(1, unlock_key), 354 std::vector<cryptauth::ExternalDeviceInfo>(1, unlock_key),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 std::unique_ptr<base::ListValue> 458 std::unique_ptr<base::ListValue>
459 ProximityAuthWebUIHandler::GetUnlockKeysList() { 459 ProximityAuthWebUIHandler::GetUnlockKeysList() {
460 std::unique_ptr<base::ListValue> unlock_keys(new base::ListValue()); 460 std::unique_ptr<base::ListValue> unlock_keys(new base::ListValue());
461 cryptauth::CryptAuthDeviceManager* device_manager = 461 cryptauth::CryptAuthDeviceManager* device_manager =
462 proximity_auth_client_->GetCryptAuthDeviceManager(); 462 proximity_auth_client_->GetCryptAuthDeviceManager();
463 if (!device_manager) 463 if (!device_manager)
464 return unlock_keys; 464 return unlock_keys;
465 465
466 for (const auto& unlock_key : device_manager->unlock_keys()) { 466 for (const auto& unlock_key : device_manager->GetUnlockKeys()) {
467 unlock_keys->Append(ExternalDeviceInfoToDictionary(unlock_key)); 467 unlock_keys->Append(ExternalDeviceInfoToDictionary(unlock_key));
468 } 468 }
469 469
470 return unlock_keys; 470 return unlock_keys;
471 } 471 }
472 472
473 void ProximityAuthWebUIHandler::OnRemoteDevicesLoaded( 473 void ProximityAuthWebUIHandler::OnRemoteDevicesLoaded(
474 const std::vector<cryptauth::RemoteDevice>& remote_devices) { 474 const std::vector<cryptauth::RemoteDevice>& remote_devices) {
475 if (remote_devices[0].persistent_symmetric_key.empty()) { 475 if (remote_devices[0].persistent_symmetric_key.empty()) {
476 PA_LOG(ERROR) << "Failed to derive PSK."; 476 PA_LOG(ERROR) << "Failed to derive PSK.";
(...skipping 30 matching lines...) Expand all
507 cryptauth::CryptAuthDeviceManager* device_manager = 507 cryptauth::CryptAuthDeviceManager* device_manager =
508 proximity_auth_client_->GetCryptAuthDeviceManager(); 508 proximity_auth_client_->GetCryptAuthDeviceManager();
509 if (!device_manager) 509 if (!device_manager)
510 return dictionary; 510 return dictionary;
511 511
512 // If |device_info| is a known unlock key, then combine the proto data with 512 // If |device_info| is a known unlock key, then combine the proto data with
513 // the corresponding local device data (e.g. connection status and remote 513 // the corresponding local device data (e.g. connection status and remote
514 // status updates). 514 // status updates).
515 std::string public_key = device_info.public_key(); 515 std::string public_key = device_info.public_key();
516 auto iterator = std::find_if( 516 auto iterator = std::find_if(
517 device_manager->unlock_keys().begin(), 517 device_manager->GetUnlockKeys().begin(),
518 device_manager->unlock_keys().end(), 518 device_manager->GetUnlockKeys().end(),
519 [&public_key](const cryptauth::ExternalDeviceInfo& unlock_key) { 519 [&public_key](const cryptauth::ExternalDeviceInfo& unlock_key) {
520 return unlock_key.public_key() == public_key; 520 return unlock_key.public_key() == public_key;
521 }); 521 });
522 522
523 if (iterator == device_manager->unlock_keys().end() || 523 if (iterator == device_manager->GetUnlockKeys().end() ||
524 selected_remote_device_.public_key != device_info.public_key()) 524 selected_remote_device_.public_key != device_info.public_key())
525 return dictionary; 525 return dictionary;
526 526
527 // Fill in the current Bluetooth connection status. 527 // Fill in the current Bluetooth connection status.
528 std::string connection_status = kExternalDeviceDisconnected; 528 std::string connection_status = kExternalDeviceDisconnected;
529 if (life_cycle_ && 529 if (life_cycle_ &&
530 life_cycle_->GetState() == 530 life_cycle_->GetState() ==
531 RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { 531 RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) {
532 connection_status = kExternalDeviceConnected; 532 connection_status = kExternalDeviceConnected;
533 } else if (life_cycle_) { 533 } else if (life_cycle_) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 << "\n trust_agent_state: " 610 << "\n trust_agent_state: "
611 << static_cast<int>(status_update.trust_agent_state); 611 << static_cast<int>(status_update.trust_agent_state);
612 612
613 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update)); 613 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update));
614 std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList(); 614 std::unique_ptr<base::ListValue> unlock_keys = GetUnlockKeysList();
615 web_ui()->CallJavascriptFunctionUnsafe( 615 web_ui()->CallJavascriptFunctionUnsafe(
616 "LocalStateInterface.onUnlockKeysChanged", *unlock_keys); 616 "LocalStateInterface.onUnlockKeysChanged", *unlock_keys);
617 } 617 }
618 618
619 } // namespace proximity_auth 619 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/cryptauth/cryptauth_device_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698