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

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

Issue 2953863002: [CrOS Tether] ProximityAuth WebUI improvement: show the local device's ID. (Closed)
Patch Set: Rebased. Created 3 years, 6 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 unified diff | Download patch
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 reachable_phone_flow_.reset(); 408 reachable_phone_flow_.reset();
409 base::ListValue device_list; 409 base::ListValue device_list;
410 for (const auto& external_device : reachable_phones) { 410 for (const auto& external_device : reachable_phones) {
411 device_list.Append(ExternalDeviceInfoToDictionary(external_device)); 411 device_list.Append(ExternalDeviceInfoToDictionary(external_device));
412 } 412 }
413 web_ui()->CallJavascriptFunctionUnsafe( 413 web_ui()->CallJavascriptFunctionUnsafe(
414 "CryptAuthInterface.onGotReachableDevices", device_list); 414 "CryptAuthInterface.onGotReachableDevices", device_list);
415 } 415 }
416 416
417 void ProximityAuthWebUIHandler::GetLocalState(const base::ListValue* args) { 417 void ProximityAuthWebUIHandler::GetLocalState(const base::ListValue* args) {
418 std::unique_ptr<base::Value> truncated_local_device_id =
419 GetTruncatedLocalDeviceId();
418 std::unique_ptr<base::DictionaryValue> enrollment_state = 420 std::unique_ptr<base::DictionaryValue> enrollment_state =
419 GetEnrollmentStateDictionary(); 421 GetEnrollmentStateDictionary();
420 std::unique_ptr<base::DictionaryValue> device_sync_state = 422 std::unique_ptr<base::DictionaryValue> device_sync_state =
421 GetDeviceSyncStateDictionary(); 423 GetDeviceSyncStateDictionary();
422 std::unique_ptr<base::ListValue> synced_devices = GetRemoteDevicesList(); 424 std::unique_ptr<base::ListValue> synced_devices = GetRemoteDevicesList();
423 425
424 PA_LOG(INFO) << "==== Got Local State ====\n" 426 PA_LOG(INFO) << "==== Got Local State ====\n"
425 << "Enrollment State: \n" 427 << "Device ID (truncated): " << *truncated_local_device_id
428 << "\nEnrollment State: \n"
426 << *enrollment_state << "Device Sync State: \n" 429 << *enrollment_state << "Device Sync State: \n"
427 << *device_sync_state << "Unlock Keys: \n" 430 << *device_sync_state << "Unlock Keys: \n"
428 << *synced_devices; 431 << *synced_devices;
429 web_ui()->CallJavascriptFunctionUnsafe("LocalStateInterface.onGotLocalState", 432 web_ui()->CallJavascriptFunctionUnsafe(
430 *enrollment_state, *device_sync_state, 433 "LocalStateInterface.onGotLocalState", *truncated_local_device_id,
431 *synced_devices); 434 *enrollment_state, *device_sync_state, *synced_devices);
435 }
436
437 std::unique_ptr<base::Value>
438 ProximityAuthWebUIHandler::GetTruncatedLocalDeviceId() {
439 std::string local_public_key =
440 proximity_auth_client_->GetLocalDevicePublicKey();
441
442 std::string device_id;
443 base::Base64UrlEncode(local_public_key,
444 base::Base64UrlEncodePolicy::INCLUDE_PADDING,
445 &device_id);
446
447 return base::MakeUnique<base::Value>(
448 cryptauth::RemoteDevice::TruncateDeviceIdForLogs(device_id));
432 } 449 }
433 450
434 std::unique_ptr<base::DictionaryValue> 451 std::unique_ptr<base::DictionaryValue>
435 ProximityAuthWebUIHandler::GetEnrollmentStateDictionary() { 452 ProximityAuthWebUIHandler::GetEnrollmentStateDictionary() {
436 cryptauth::CryptAuthEnrollmentManager* enrollment_manager = 453 cryptauth::CryptAuthEnrollmentManager* enrollment_manager =
437 proximity_auth_client_->GetCryptAuthEnrollmentManager(); 454 proximity_auth_client_->GetCryptAuthEnrollmentManager();
438 if (!enrollment_manager) 455 if (!enrollment_manager)
439 return base::MakeUnique<base::DictionaryValue>(); 456 return base::MakeUnique<base::DictionaryValue>();
440 457
441 return CreateSyncStateDictionary( 458 return CreateSyncStateDictionary(
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 << "\n trust_agent_state: " 636 << "\n trust_agent_state: "
620 << static_cast<int>(status_update.trust_agent_state); 637 << static_cast<int>(status_update.trust_agent_state);
621 638
622 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update)); 639 last_remote_status_update_.reset(new RemoteStatusUpdate(status_update));
623 std::unique_ptr<base::ListValue> synced_devices = GetRemoteDevicesList(); 640 std::unique_ptr<base::ListValue> synced_devices = GetRemoteDevicesList();
624 web_ui()->CallJavascriptFunctionUnsafe( 641 web_ui()->CallJavascriptFunctionUnsafe(
625 "LocalStateInterface.onRemoteDevicesChanged", *synced_devices); 642 "LocalStateInterface.onRemoteDevicesChanged", *synced_devices);
626 } 643 }
627 644
628 } // namespace proximity_auth 645 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698