| 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 #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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 cryptauth::CryptAuthDeviceManager* device_manager = | 533 cryptauth::CryptAuthDeviceManager* device_manager = |
| 534 proximity_auth_client_->GetCryptAuthDeviceManager(); | 534 proximity_auth_client_->GetCryptAuthDeviceManager(); |
| 535 if (!device_manager) | 535 if (!device_manager) |
| 536 return dictionary; | 536 return dictionary; |
| 537 | 537 |
| 538 // If |device_info| is a known unlock key, then combine the proto data with | 538 // If |device_info| is a known unlock key, then combine the proto data with |
| 539 // the corresponding local device data (e.g. connection status and remote | 539 // the corresponding local device data (e.g. connection status and remote |
| 540 // status updates). | 540 // status updates). |
| 541 std::string public_key = device_info.public_key(); | 541 std::string public_key = device_info.public_key(); |
| 542 std::vector<cryptauth::ExternalDeviceInfo> unlock_keys = |
| 543 device_manager->GetUnlockKeys(); |
| 542 auto iterator = std::find_if( | 544 auto iterator = std::find_if( |
| 543 device_manager->GetUnlockKeys().begin(), | 545 unlock_keys.begin(), unlock_keys.end(), |
| 544 device_manager->GetUnlockKeys().end(), | |
| 545 [&public_key](const cryptauth::ExternalDeviceInfo& unlock_key) { | 546 [&public_key](const cryptauth::ExternalDeviceInfo& unlock_key) { |
| 546 return unlock_key.public_key() == public_key; | 547 return unlock_key.public_key() == public_key; |
| 547 }); | 548 }); |
| 548 | 549 |
| 549 if (iterator == device_manager->GetUnlockKeys().end() || | 550 if (iterator == unlock_keys.end() || |
| 550 selected_remote_device_.public_key != device_info.public_key()) | 551 selected_remote_device_.public_key != device_info.public_key()) |
| 551 return dictionary; | 552 return dictionary; |
| 552 | 553 |
| 553 // Fill in the current Bluetooth connection status. | 554 // Fill in the current Bluetooth connection status. |
| 554 std::string connection_status = kExternalDeviceDisconnected; | 555 std::string connection_status = kExternalDeviceDisconnected; |
| 555 if (life_cycle_ && | 556 if (life_cycle_ && |
| 556 life_cycle_->GetState() == | 557 life_cycle_->GetState() == |
| 557 RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { | 558 RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { |
| 558 connection_status = kExternalDeviceConnected; | 559 connection_status = kExternalDeviceConnected; |
| 559 } else if (life_cycle_) { | 560 } else if (life_cycle_) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 << "\n trust_agent_state: " | 637 << "\n trust_agent_state: " |
| 637 << static_cast<int>(status_update.trust_agent_state); | 638 << static_cast<int>(status_update.trust_agent_state); |
| 638 | 639 |
| 639 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update)); | 640 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update)); |
| 640 std::unique_ptr<base::ListValue> synced_devices = GetRemoteDevicesList(); | 641 std::unique_ptr<base::ListValue> synced_devices = GetRemoteDevicesList(); |
| 641 web_ui()->CallJavascriptFunctionUnsafe( | 642 web_ui()->CallJavascriptFunctionUnsafe( |
| 642 "LocalStateInterface.onRemoteDevicesChanged", *synced_devices); | 643 "LocalStateInterface.onRemoteDevicesChanged", *synced_devices); |
| 643 } | 644 } |
| 644 | 645 |
| 645 } // namespace proximity_auth | 646 } // namespace proximity_auth |
| OLD | NEW |