| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
api.h" | 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
api.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64url.h" | 10 #include "base/base64url.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/time/default_tick_clock.h" | 18 #include "base/time/default_tick_clock.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 22 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
connection_manager.h" | 23 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
connection_manager.h" |
| 23 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
crypto_delegate.h" | 24 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
crypto_delegate.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 crypto_delegate_ = EasyUnlockPrivateCryptoDelegate::Create(); | 131 crypto_delegate_ = EasyUnlockPrivateCryptoDelegate::Create(); |
| 131 return crypto_delegate_.get(); | 132 return crypto_delegate_.get(); |
| 132 } | 133 } |
| 133 | 134 |
| 134 EasyUnlockPrivateGetStringsFunction::EasyUnlockPrivateGetStringsFunction() { | 135 EasyUnlockPrivateGetStringsFunction::EasyUnlockPrivateGetStringsFunction() { |
| 135 } | 136 } |
| 136 EasyUnlockPrivateGetStringsFunction::~EasyUnlockPrivateGetStringsFunction() { | 137 EasyUnlockPrivateGetStringsFunction::~EasyUnlockPrivateGetStringsFunction() { |
| 137 } | 138 } |
| 138 | 139 |
| 139 bool EasyUnlockPrivateGetStringsFunction::RunSync() { | 140 bool EasyUnlockPrivateGetStringsFunction::RunSync() { |
| 140 scoped_ptr<base::DictionaryValue> strings(new base::DictionaryValue); | 141 std::unique_ptr<base::DictionaryValue> strings(new base::DictionaryValue); |
| 141 | 142 |
| 142 #if defined(OS_CHROMEOS) | 143 #if defined(OS_CHROMEOS) |
| 143 const base::string16 device_type = ash::GetChromeOSDeviceName(); | 144 const base::string16 device_type = ash::GetChromeOSDeviceName(); |
| 144 #else | 145 #else |
| 145 // TODO(isherman): Set an appropriate device name for non-ChromeOS devices. | 146 // TODO(isherman): Set an appropriate device name for non-ChromeOS devices. |
| 146 const base::string16 device_type = base::ASCIIToUTF16("Chromeschnozzle"); | 147 const base::string16 device_type = base::ASCIIToUTF16("Chromeschnozzle"); |
| 147 #endif // defined(OS_CHROMEOS) | 148 #endif // defined(OS_CHROMEOS) |
| 148 | 149 |
| 149 #if defined(OS_CHROMEOS) | 150 #if defined(OS_CHROMEOS) |
| 150 const user_manager::UserManager* manager = user_manager::UserManager::Get(); | 151 const user_manager::UserManager* manager = user_manager::UserManager::Get(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 return true; | 363 return true; |
| 363 } | 364 } |
| 364 | 365 |
| 365 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: | 366 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: |
| 366 EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} | 367 EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} |
| 367 | 368 |
| 368 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: | 369 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: |
| 369 ~EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} | 370 ~EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} |
| 370 | 371 |
| 371 bool EasyUnlockPrivatePerformECDHKeyAgreementFunction::RunAsync() { | 372 bool EasyUnlockPrivatePerformECDHKeyAgreementFunction::RunAsync() { |
| 372 scoped_ptr<easy_unlock_private::PerformECDHKeyAgreement::Params> params = | 373 std::unique_ptr<easy_unlock_private::PerformECDHKeyAgreement::Params> params = |
| 373 easy_unlock_private::PerformECDHKeyAgreement::Params::Create(*args_); | 374 easy_unlock_private::PerformECDHKeyAgreement::Params::Create(*args_); |
| 374 EXTENSION_FUNCTION_VALIDATE(params); | 375 EXTENSION_FUNCTION_VALIDATE(params); |
| 375 | 376 |
| 376 GetCryptoDelegate(browser_context())->PerformECDHKeyAgreement( | 377 GetCryptoDelegate(browser_context())->PerformECDHKeyAgreement( |
| 377 *params, | 378 *params, |
| 378 base::Bind(&EasyUnlockPrivatePerformECDHKeyAgreementFunction::OnData, | 379 base::Bind(&EasyUnlockPrivatePerformECDHKeyAgreementFunction::OnData, |
| 379 this)); | 380 this)); |
| 380 return true; | 381 return true; |
| 381 } | 382 } |
| 382 | 383 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 SendResponse(true); | 416 SendResponse(true); |
| 416 } | 417 } |
| 417 | 418 |
| 418 EasyUnlockPrivateCreateSecureMessageFunction:: | 419 EasyUnlockPrivateCreateSecureMessageFunction:: |
| 419 EasyUnlockPrivateCreateSecureMessageFunction() {} | 420 EasyUnlockPrivateCreateSecureMessageFunction() {} |
| 420 | 421 |
| 421 EasyUnlockPrivateCreateSecureMessageFunction:: | 422 EasyUnlockPrivateCreateSecureMessageFunction:: |
| 422 ~EasyUnlockPrivateCreateSecureMessageFunction() {} | 423 ~EasyUnlockPrivateCreateSecureMessageFunction() {} |
| 423 | 424 |
| 424 bool EasyUnlockPrivateCreateSecureMessageFunction::RunAsync() { | 425 bool EasyUnlockPrivateCreateSecureMessageFunction::RunAsync() { |
| 425 scoped_ptr<easy_unlock_private::CreateSecureMessage::Params> params = | 426 std::unique_ptr<easy_unlock_private::CreateSecureMessage::Params> params = |
| 426 easy_unlock_private::CreateSecureMessage::Params::Create(*args_); | 427 easy_unlock_private::CreateSecureMessage::Params::Create(*args_); |
| 427 EXTENSION_FUNCTION_VALIDATE(params); | 428 EXTENSION_FUNCTION_VALIDATE(params); |
| 428 | 429 |
| 429 GetCryptoDelegate(browser_context())->CreateSecureMessage( | 430 GetCryptoDelegate(browser_context())->CreateSecureMessage( |
| 430 *params, | 431 *params, |
| 431 base::Bind(&EasyUnlockPrivateCreateSecureMessageFunction::OnData, | 432 base::Bind(&EasyUnlockPrivateCreateSecureMessageFunction::OnData, |
| 432 this)); | 433 this)); |
| 433 return true; | 434 return true; |
| 434 } | 435 } |
| 435 | 436 |
| 436 void EasyUnlockPrivateCreateSecureMessageFunction::OnData( | 437 void EasyUnlockPrivateCreateSecureMessageFunction::OnData( |
| 437 const std::string& message) { | 438 const std::string& message) { |
| 438 // TODO(tbarzic): Improve error handling. | 439 // TODO(tbarzic): Improve error handling. |
| 439 if (!message.empty()) { | 440 if (!message.empty()) { |
| 440 results_ = easy_unlock_private::CreateSecureMessage::Results::Create( | 441 results_ = easy_unlock_private::CreateSecureMessage::Results::Create( |
| 441 std::vector<char>(message.begin(), message.end())); | 442 std::vector<char>(message.begin(), message.end())); |
| 442 } | 443 } |
| 443 SendResponse(true); | 444 SendResponse(true); |
| 444 } | 445 } |
| 445 | 446 |
| 446 EasyUnlockPrivateUnwrapSecureMessageFunction:: | 447 EasyUnlockPrivateUnwrapSecureMessageFunction:: |
| 447 EasyUnlockPrivateUnwrapSecureMessageFunction() {} | 448 EasyUnlockPrivateUnwrapSecureMessageFunction() {} |
| 448 | 449 |
| 449 EasyUnlockPrivateUnwrapSecureMessageFunction:: | 450 EasyUnlockPrivateUnwrapSecureMessageFunction:: |
| 450 ~EasyUnlockPrivateUnwrapSecureMessageFunction() {} | 451 ~EasyUnlockPrivateUnwrapSecureMessageFunction() {} |
| 451 | 452 |
| 452 bool EasyUnlockPrivateUnwrapSecureMessageFunction::RunAsync() { | 453 bool EasyUnlockPrivateUnwrapSecureMessageFunction::RunAsync() { |
| 453 scoped_ptr<easy_unlock_private::UnwrapSecureMessage::Params> params = | 454 std::unique_ptr<easy_unlock_private::UnwrapSecureMessage::Params> params = |
| 454 easy_unlock_private::UnwrapSecureMessage::Params::Create(*args_); | 455 easy_unlock_private::UnwrapSecureMessage::Params::Create(*args_); |
| 455 EXTENSION_FUNCTION_VALIDATE(params); | 456 EXTENSION_FUNCTION_VALIDATE(params); |
| 456 | 457 |
| 457 GetCryptoDelegate(browser_context())->UnwrapSecureMessage( | 458 GetCryptoDelegate(browser_context())->UnwrapSecureMessage( |
| 458 *params, | 459 *params, |
| 459 base::Bind(&EasyUnlockPrivateUnwrapSecureMessageFunction::OnData, | 460 base::Bind(&EasyUnlockPrivateUnwrapSecureMessageFunction::OnData, |
| 460 this)); | 461 this)); |
| 461 return true; | 462 return true; |
| 462 } | 463 } |
| 463 | 464 |
| 464 void EasyUnlockPrivateUnwrapSecureMessageFunction::OnData( | 465 void EasyUnlockPrivateUnwrapSecureMessageFunction::OnData( |
| 465 const std::string& data) { | 466 const std::string& data) { |
| 466 // TODO(tbarzic): Improve error handling. | 467 // TODO(tbarzic): Improve error handling. |
| 467 if (!data.empty()) { | 468 if (!data.empty()) { |
| 468 results_ = easy_unlock_private::UnwrapSecureMessage::Results::Create( | 469 results_ = easy_unlock_private::UnwrapSecureMessage::Results::Create( |
| 469 std::vector<char>(data.begin(), data.end())); | 470 std::vector<char>(data.begin(), data.end())); |
| 470 } | 471 } |
| 471 SendResponse(true); | 472 SendResponse(true); |
| 472 } | 473 } |
| 473 | 474 |
| 474 EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction:: | 475 EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction:: |
| 475 EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction() {} | 476 EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction() {} |
| 476 | 477 |
| 477 EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction:: | 478 EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction:: |
| 478 ~EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction() {} | 479 ~EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction() {} |
| 479 | 480 |
| 480 bool EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::RunAsync() { | 481 bool EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::RunAsync() { |
| 481 scoped_ptr<easy_unlock_private::SeekBluetoothDeviceByAddress::Params> params( | 482 std::unique_ptr<easy_unlock_private::SeekBluetoothDeviceByAddress::Params> |
| 482 easy_unlock_private::SeekBluetoothDeviceByAddress::Params::Create( | 483 params(easy_unlock_private::SeekBluetoothDeviceByAddress::Params::Create( |
| 483 *args_)); | 484 *args_)); |
| 484 EXTENSION_FUNCTION_VALIDATE(params.get()); | 485 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 485 | 486 |
| 486 proximity_auth::bluetooth_util::SeekDeviceByAddress( | 487 proximity_auth::bluetooth_util::SeekDeviceByAddress( |
| 487 params->device_address, | 488 params->device_address, |
| 488 base::Bind( | 489 base::Bind( |
| 489 &EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::OnSeekSuccess, | 490 &EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::OnSeekSuccess, |
| 490 this), | 491 this), |
| 491 base::Bind( | 492 base::Bind( |
| 492 &EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::OnSeekFailure, | 493 &EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::OnSeekFailure, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 this)); | 528 this)); |
| 528 } | 529 } |
| 529 | 530 |
| 530 EasyUnlockPrivateUpdateScreenlockStateFunction:: | 531 EasyUnlockPrivateUpdateScreenlockStateFunction:: |
| 531 EasyUnlockPrivateUpdateScreenlockStateFunction() {} | 532 EasyUnlockPrivateUpdateScreenlockStateFunction() {} |
| 532 | 533 |
| 533 EasyUnlockPrivateUpdateScreenlockStateFunction:: | 534 EasyUnlockPrivateUpdateScreenlockStateFunction:: |
| 534 ~EasyUnlockPrivateUpdateScreenlockStateFunction() {} | 535 ~EasyUnlockPrivateUpdateScreenlockStateFunction() {} |
| 535 | 536 |
| 536 bool EasyUnlockPrivateUpdateScreenlockStateFunction::RunSync() { | 537 bool EasyUnlockPrivateUpdateScreenlockStateFunction::RunSync() { |
| 537 scoped_ptr<easy_unlock_private::UpdateScreenlockState::Params> params( | 538 std::unique_ptr<easy_unlock_private::UpdateScreenlockState::Params> params( |
| 538 easy_unlock_private::UpdateScreenlockState::Params::Create(*args_)); | 539 easy_unlock_private::UpdateScreenlockState::Params::Create(*args_)); |
| 539 EXTENSION_FUNCTION_VALIDATE(params.get()); | 540 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 540 | 541 |
| 541 Profile* profile = Profile::FromBrowserContext(browser_context()); | 542 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 542 if (EasyUnlockService::Get(profile)->UpdateScreenlockState( | 543 if (EasyUnlockService::Get(profile)->UpdateScreenlockState( |
| 543 ToScreenlockState(params->state))) | 544 ToScreenlockState(params->state))) |
| 544 return true; | 545 return true; |
| 545 | 546 |
| 546 SetError("Not allowed"); | 547 SetError("Not allowed"); |
| 547 return false; | 548 return false; |
| 548 } | 549 } |
| 549 | 550 |
| 550 EasyUnlockPrivateSetPermitAccessFunction:: | 551 EasyUnlockPrivateSetPermitAccessFunction:: |
| 551 EasyUnlockPrivateSetPermitAccessFunction() { | 552 EasyUnlockPrivateSetPermitAccessFunction() { |
| 552 } | 553 } |
| 553 | 554 |
| 554 EasyUnlockPrivateSetPermitAccessFunction:: | 555 EasyUnlockPrivateSetPermitAccessFunction:: |
| 555 ~EasyUnlockPrivateSetPermitAccessFunction() { | 556 ~EasyUnlockPrivateSetPermitAccessFunction() { |
| 556 } | 557 } |
| 557 | 558 |
| 558 bool EasyUnlockPrivateSetPermitAccessFunction::RunSync() { | 559 bool EasyUnlockPrivateSetPermitAccessFunction::RunSync() { |
| 559 scoped_ptr<easy_unlock_private::SetPermitAccess::Params> params( | 560 std::unique_ptr<easy_unlock_private::SetPermitAccess::Params> params( |
| 560 easy_unlock_private::SetPermitAccess::Params::Create(*args_)); | 561 easy_unlock_private::SetPermitAccess::Params::Create(*args_)); |
| 561 EXTENSION_FUNCTION_VALIDATE(params.get()); | 562 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 562 | 563 |
| 563 Profile* profile = Profile::FromBrowserContext(browser_context()); | 564 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 564 EasyUnlockService::Get(profile) | 565 EasyUnlockService::Get(profile) |
| 565 ->SetPermitAccess(*params->permit_access.ToValue()); | 566 ->SetPermitAccess(*params->permit_access.ToValue()); |
| 566 | 567 |
| 567 return true; | 568 return true; |
| 568 } | 569 } |
| 569 | 570 |
| 570 EasyUnlockPrivateGetPermitAccessFunction:: | 571 EasyUnlockPrivateGetPermitAccessFunction:: |
| 571 EasyUnlockPrivateGetPermitAccessFunction() { | 572 EasyUnlockPrivateGetPermitAccessFunction() { |
| 572 } | 573 } |
| 573 | 574 |
| 574 EasyUnlockPrivateGetPermitAccessFunction:: | 575 EasyUnlockPrivateGetPermitAccessFunction:: |
| 575 ~EasyUnlockPrivateGetPermitAccessFunction() { | 576 ~EasyUnlockPrivateGetPermitAccessFunction() { |
| 576 } | 577 } |
| 577 | 578 |
| 578 bool EasyUnlockPrivateGetPermitAccessFunction::RunSync() { | 579 bool EasyUnlockPrivateGetPermitAccessFunction::RunSync() { |
| 579 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 580 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 580 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { | 581 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { |
| 581 ReturnPermitAccessForExperiment(); | 582 ReturnPermitAccessForExperiment(); |
| 582 return true; | 583 return true; |
| 583 } | 584 } |
| 584 | 585 |
| 585 Profile* profile = Profile::FromBrowserContext(browser_context()); | 586 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 586 const base::DictionaryValue* permit_value = | 587 const base::DictionaryValue* permit_value = |
| 587 EasyUnlockService::Get(profile)->GetPermitAccess(); | 588 EasyUnlockService::Get(profile)->GetPermitAccess(); |
| 588 if (permit_value) { | 589 if (permit_value) { |
| 589 scoped_ptr<easy_unlock_private::PermitRecord> permit = | 590 std::unique_ptr<easy_unlock_private::PermitRecord> permit = |
| 590 easy_unlock_private::PermitRecord::FromValue(*permit_value); | 591 easy_unlock_private::PermitRecord::FromValue(*permit_value); |
| 591 results_ = easy_unlock_private::GetPermitAccess::Results::Create(*permit); | 592 results_ = easy_unlock_private::GetPermitAccess::Results::Create(*permit); |
| 592 } | 593 } |
| 593 | 594 |
| 594 return true; | 595 return true; |
| 595 } | 596 } |
| 596 | 597 |
| 597 void EasyUnlockPrivateGetPermitAccessFunction::GetKeyPairForExperiment( | 598 void EasyUnlockPrivateGetPermitAccessFunction::GetKeyPairForExperiment( |
| 598 std::string* user_public_key, | 599 std::string* user_public_key, |
| 599 std::string* user_private_key) { | 600 std::string* user_private_key) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 620 SendResponse(true); | 621 SendResponse(true); |
| 621 return; | 622 return; |
| 622 } | 623 } |
| 623 | 624 |
| 624 std::string b64_public_key, b64_private_key; | 625 std::string b64_public_key, b64_private_key; |
| 625 GetKeyPairForExperiment(&b64_public_key, &b64_private_key); | 626 GetKeyPairForExperiment(&b64_public_key, &b64_private_key); |
| 626 | 627 |
| 627 // Fill in the permit access JSON dictionary. | 628 // Fill in the permit access JSON dictionary. |
| 628 proximity_auth::ProximityAuthClient* client = | 629 proximity_auth::ProximityAuthClient* client = |
| 629 easy_unlock_service->proximity_auth_client(); | 630 easy_unlock_service->proximity_auth_client(); |
| 630 scoped_ptr<base::DictionaryValue> permit_access(new base::DictionaryValue()); | 631 std::unique_ptr<base::DictionaryValue> permit_access( |
| 632 new base::DictionaryValue()); |
| 631 permit_access->SetString("permitId", | 633 permit_access->SetString("permitId", |
| 632 "permit://google.com/" + client->GetAccountId()); | 634 "permit://google.com/" + client->GetAccountId()); |
| 633 permit_access->SetString("id", b64_public_key); | 635 permit_access->SetString("id", b64_public_key); |
| 634 permit_access->SetString("type", "access"); | 636 permit_access->SetString("type", "access"); |
| 635 permit_access->SetString("data", b64_private_key); | 637 permit_access->SetString("data", b64_private_key); |
| 636 | 638 |
| 637 PA_LOG(INFO) << "Returning permit access for " | 639 PA_LOG(INFO) << "Returning permit access for " |
| 638 << "chrome.easyUnlockPrivate.getPermitAccess:\n" | 640 << "chrome.easyUnlockPrivate.getPermitAccess:\n" |
| 639 << " id: " << b64_public_key; | 641 << " id: " << b64_public_key; |
| 640 | 642 |
| 641 scoped_ptr<easy_unlock_private::PermitRecord> result = | 643 std::unique_ptr<easy_unlock_private::PermitRecord> result = |
| 642 easy_unlock_private::PermitRecord::FromValue(*permit_access); | 644 easy_unlock_private::PermitRecord::FromValue(*permit_access); |
| 643 results_ = easy_unlock_private::GetPermitAccess::Results::Create(*result); | 645 results_ = easy_unlock_private::GetPermitAccess::Results::Create(*result); |
| 644 } | 646 } |
| 645 | 647 |
| 646 EasyUnlockPrivateClearPermitAccessFunction:: | 648 EasyUnlockPrivateClearPermitAccessFunction:: |
| 647 EasyUnlockPrivateClearPermitAccessFunction() { | 649 EasyUnlockPrivateClearPermitAccessFunction() { |
| 648 } | 650 } |
| 649 | 651 |
| 650 EasyUnlockPrivateClearPermitAccessFunction:: | 652 EasyUnlockPrivateClearPermitAccessFunction:: |
| 651 ~EasyUnlockPrivateClearPermitAccessFunction() { | 653 ~EasyUnlockPrivateClearPermitAccessFunction() { |
| 652 } | 654 } |
| 653 | 655 |
| 654 bool EasyUnlockPrivateClearPermitAccessFunction::RunSync() { | 656 bool EasyUnlockPrivateClearPermitAccessFunction::RunSync() { |
| 655 Profile* profile = Profile::FromBrowserContext(browser_context()); | 657 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 656 EasyUnlockService::Get(profile)->ClearPermitAccess(); | 658 EasyUnlockService::Get(profile)->ClearPermitAccess(); |
| 657 return true; | 659 return true; |
| 658 } | 660 } |
| 659 | 661 |
| 660 EasyUnlockPrivateSetRemoteDevicesFunction:: | 662 EasyUnlockPrivateSetRemoteDevicesFunction:: |
| 661 EasyUnlockPrivateSetRemoteDevicesFunction() { | 663 EasyUnlockPrivateSetRemoteDevicesFunction() { |
| 662 } | 664 } |
| 663 | 665 |
| 664 EasyUnlockPrivateSetRemoteDevicesFunction:: | 666 EasyUnlockPrivateSetRemoteDevicesFunction:: |
| 665 ~EasyUnlockPrivateSetRemoteDevicesFunction() { | 667 ~EasyUnlockPrivateSetRemoteDevicesFunction() { |
| 666 } | 668 } |
| 667 | 669 |
| 668 bool EasyUnlockPrivateSetRemoteDevicesFunction::RunSync() { | 670 bool EasyUnlockPrivateSetRemoteDevicesFunction::RunSync() { |
| 669 scoped_ptr<easy_unlock_private::SetRemoteDevices::Params> params( | 671 std::unique_ptr<easy_unlock_private::SetRemoteDevices::Params> params( |
| 670 easy_unlock_private::SetRemoteDevices::Params::Create(*args_)); | 672 easy_unlock_private::SetRemoteDevices::Params::Create(*args_)); |
| 671 EXTENSION_FUNCTION_VALIDATE(params.get()); | 673 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 672 | 674 |
| 673 Profile* profile = Profile::FromBrowserContext(browser_context()); | 675 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 674 base::ListValue devices; | 676 base::ListValue devices; |
| 675 for (const easy_unlock_private::Device& device : params->devices) | 677 for (const easy_unlock_private::Device& device : params->devices) |
| 676 devices.Append(device.ToValue()); | 678 devices.Append(device.ToValue()); |
| 677 | 679 |
| 678 // Store the BLE device if we are trying out the BLE experiment. | 680 // Store the BLE device if we are trying out the BLE experiment. |
| 679 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 681 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 const std::string& persistent_symmetric_key) { | 786 const std::string& persistent_symmetric_key) { |
| 785 std::string b64_public_key, b64_psk; | 787 std::string b64_public_key, b64_psk; |
| 786 base::Base64UrlEncode(device.public_key(), | 788 base::Base64UrlEncode(device.public_key(), |
| 787 base::Base64UrlEncodePolicy::INCLUDE_PADDING, | 789 base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
| 788 &b64_public_key); | 790 &b64_public_key); |
| 789 base::Base64UrlEncode(persistent_symmetric_key, | 791 base::Base64UrlEncode(persistent_symmetric_key, |
| 790 base::Base64UrlEncodePolicy::INCLUDE_PADDING, | 792 base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
| 791 &b64_psk); | 793 &b64_psk); |
| 792 | 794 |
| 793 // Fill in the JSON dictionary containing a single unlock key's data. | 795 // Fill in the JSON dictionary containing a single unlock key's data. |
| 794 scoped_ptr<base::DictionaryValue> device_dictionary( | 796 std::unique_ptr<base::DictionaryValue> device_dictionary( |
| 795 new base::DictionaryValue()); | 797 new base::DictionaryValue()); |
| 796 device_dictionary->SetString("name", device.friendly_device_name()); | 798 device_dictionary->SetString("name", device.friendly_device_name()); |
| 797 device_dictionary->SetString("bluetoothAddress", device.bluetooth_address()); | 799 device_dictionary->SetString("bluetoothAddress", device.bluetooth_address()); |
| 798 device_dictionary->SetString("psk", b64_psk); | 800 device_dictionary->SetString("psk", b64_psk); |
| 799 | 801 |
| 800 // Fill in the permit license for the unlock key. | 802 // Fill in the permit license for the unlock key. |
| 801 scoped_ptr<base::DictionaryValue> permit_license(new base::DictionaryValue()); | 803 std::unique_ptr<base::DictionaryValue> permit_license( |
| 804 new base::DictionaryValue()); |
| 802 permit_license->SetString("permitId", permit_id_); | 805 permit_license->SetString("permitId", permit_id_); |
| 803 permit_license->SetString("id", b64_public_key); | 806 permit_license->SetString("id", b64_public_key); |
| 804 permit_license->SetString("type", "license"); | 807 permit_license->SetString("type", "license"); |
| 805 permit_license->SetString("data", b64_public_key); | 808 permit_license->SetString("data", b64_public_key); |
| 806 device_dictionary->Set("permitRecord", std::move(permit_license)); | 809 device_dictionary->Set("permitRecord", std::move(permit_license)); |
| 807 | 810 |
| 808 remote_devices_->Append(std::move(device_dictionary)); | 811 remote_devices_->Append(std::move(device_dictionary)); |
| 809 | 812 |
| 810 // If all PSKs are derived, then return from the API call. | 813 // If all PSKs are derived, then return from the API call. |
| 811 PA_LOG(INFO) << "Derived PSK for " << b64_public_key << ": " | 814 PA_LOG(INFO) << "Derived PSK for " << b64_public_key << ": " |
| 812 << remote_devices_->GetSize() << "/" << expected_devices_count_; | 815 << remote_devices_->GetSize() << "/" << expected_devices_count_; |
| 813 if (remote_devices_->GetSize() == expected_devices_count_) { | 816 if (remote_devices_->GetSize() == expected_devices_count_) { |
| 814 SetResult(std::move(remote_devices_)); | 817 SetResult(std::move(remote_devices_)); |
| 815 SendResponse(true); | 818 SendResponse(true); |
| 816 } | 819 } |
| 817 } | 820 } |
| 818 | 821 |
| 819 EasyUnlockPrivateGetSignInChallengeFunction:: | 822 EasyUnlockPrivateGetSignInChallengeFunction:: |
| 820 EasyUnlockPrivateGetSignInChallengeFunction() { | 823 EasyUnlockPrivateGetSignInChallengeFunction() { |
| 821 } | 824 } |
| 822 | 825 |
| 823 EasyUnlockPrivateGetSignInChallengeFunction:: | 826 EasyUnlockPrivateGetSignInChallengeFunction:: |
| 824 ~EasyUnlockPrivateGetSignInChallengeFunction() { | 827 ~EasyUnlockPrivateGetSignInChallengeFunction() { |
| 825 } | 828 } |
| 826 | 829 |
| 827 bool EasyUnlockPrivateGetSignInChallengeFunction::RunAsync() { | 830 bool EasyUnlockPrivateGetSignInChallengeFunction::RunAsync() { |
| 828 scoped_ptr<easy_unlock_private::GetSignInChallenge::Params> params( | 831 std::unique_ptr<easy_unlock_private::GetSignInChallenge::Params> params( |
| 829 easy_unlock_private::GetSignInChallenge::Params::Create(*args_)); | 832 easy_unlock_private::GetSignInChallenge::Params::Create(*args_)); |
| 830 EXTENSION_FUNCTION_VALIDATE(params.get()); | 833 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 831 | 834 |
| 832 #if defined(OS_CHROMEOS) | 835 #if defined(OS_CHROMEOS) |
| 833 Profile* profile = Profile::FromBrowserContext(browser_context()); | 836 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 834 const std::string challenge = | 837 const std::string challenge = |
| 835 EasyUnlockService::Get(profile)->GetChallenge(); | 838 EasyUnlockService::Get(profile)->GetChallenge(); |
| 836 if (!challenge.empty() && !params->nonce.empty()) { | 839 if (!challenge.empty() && !params->nonce.empty()) { |
| 837 EasyUnlockTpmKeyManager* key_manager = | 840 EasyUnlockTpmKeyManager* key_manager = |
| 838 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile); | 841 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 866 | 869 |
| 867 EasyUnlockPrivateTrySignInSecretFunction:: | 870 EasyUnlockPrivateTrySignInSecretFunction:: |
| 868 EasyUnlockPrivateTrySignInSecretFunction() { | 871 EasyUnlockPrivateTrySignInSecretFunction() { |
| 869 } | 872 } |
| 870 | 873 |
| 871 EasyUnlockPrivateTrySignInSecretFunction:: | 874 EasyUnlockPrivateTrySignInSecretFunction:: |
| 872 ~EasyUnlockPrivateTrySignInSecretFunction() { | 875 ~EasyUnlockPrivateTrySignInSecretFunction() { |
| 873 } | 876 } |
| 874 | 877 |
| 875 bool EasyUnlockPrivateTrySignInSecretFunction::RunSync() { | 878 bool EasyUnlockPrivateTrySignInSecretFunction::RunSync() { |
| 876 scoped_ptr<easy_unlock_private::TrySignInSecret::Params> params( | 879 std::unique_ptr<easy_unlock_private::TrySignInSecret::Params> params( |
| 877 easy_unlock_private::TrySignInSecret::Params::Create(*args_)); | 880 easy_unlock_private::TrySignInSecret::Params::Create(*args_)); |
| 878 EXTENSION_FUNCTION_VALIDATE(params.get()); | 881 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 879 | 882 |
| 880 Profile* profile = Profile::FromBrowserContext(browser_context()); | 883 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 881 EasyUnlockService::Get(profile)->FinalizeSignin(std::string( | 884 EasyUnlockService::Get(profile)->FinalizeSignin(std::string( |
| 882 params->sign_in_secret.begin(), params->sign_in_secret.end())); | 885 params->sign_in_secret.begin(), params->sign_in_secret.end())); |
| 883 return true; | 886 return true; |
| 884 } | 887 } |
| 885 | 888 |
| 886 EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() { | 889 EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 EasyUnlockPrivateGetConnectionInfoFunction:: | 922 EasyUnlockPrivateGetConnectionInfoFunction:: |
| 920 EasyUnlockPrivateGetConnectionInfoFunction() { | 923 EasyUnlockPrivateGetConnectionInfoFunction() { |
| 921 } | 924 } |
| 922 | 925 |
| 923 EasyUnlockPrivateGetConnectionInfoFunction:: | 926 EasyUnlockPrivateGetConnectionInfoFunction:: |
| 924 ~EasyUnlockPrivateGetConnectionInfoFunction() { | 927 ~EasyUnlockPrivateGetConnectionInfoFunction() { |
| 925 } | 928 } |
| 926 | 929 |
| 927 bool EasyUnlockPrivateGetConnectionInfoFunction::DoWork( | 930 bool EasyUnlockPrivateGetConnectionInfoFunction::DoWork( |
| 928 scoped_refptr<device::BluetoothAdapter> adapter) { | 931 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 929 scoped_ptr<easy_unlock_private::GetConnectionInfo::Params> params = | 932 std::unique_ptr<easy_unlock_private::GetConnectionInfo::Params> params = |
| 930 easy_unlock_private::GetConnectionInfo::Params::Create(*args_); | 933 easy_unlock_private::GetConnectionInfo::Params::Create(*args_); |
| 931 EXTENSION_FUNCTION_VALIDATE(params); | 934 EXTENSION_FUNCTION_VALIDATE(params); |
| 932 | 935 |
| 933 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); | 936 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); |
| 934 | 937 |
| 935 std::string error; | 938 std::string error; |
| 936 if (!device) | 939 if (!device) |
| 937 error = "Invalid Bluetooth device."; | 940 error = "Invalid Bluetooth device."; |
| 938 else if (!device->IsConnected()) | 941 else if (!device->IsConnected()) |
| 939 error = "Bluetooth device not connected."; | 942 error = "Bluetooth device not connected."; |
| 940 | 943 |
| 941 if (!error.empty()) { | 944 if (!error.empty()) { |
| 942 SetError(error); | 945 SetError(error); |
| 943 SendResponse(false); | 946 SendResponse(false); |
| 944 return true; | 947 return true; |
| 945 } | 948 } |
| 946 | 949 |
| 947 device->GetConnectionInfo(base::Bind( | 950 device->GetConnectionInfo(base::Bind( |
| 948 &EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo, this)); | 951 &EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo, this)); |
| 949 return false; | 952 return false; |
| 950 } | 953 } |
| 951 | 954 |
| 952 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( | 955 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( |
| 953 const device::BluetoothDevice::ConnectionInfo& connection_info) { | 956 const device::BluetoothDevice::ConnectionInfo& connection_info) { |
| 954 scoped_ptr<base::ListValue> results(new base::ListValue()); | 957 std::unique_ptr<base::ListValue> results(new base::ListValue()); |
| 955 results->AppendInteger(connection_info.rssi); | 958 results->AppendInteger(connection_info.rssi); |
| 956 results->AppendInteger(connection_info.transmit_power); | 959 results->AppendInteger(connection_info.transmit_power); |
| 957 results->AppendInteger(connection_info.max_transmit_power); | 960 results->AppendInteger(connection_info.max_transmit_power); |
| 958 SetResultList(std::move(results)); | 961 SetResultList(std::move(results)); |
| 959 SendResponse(true); | 962 SendResponse(true); |
| 960 } | 963 } |
| 961 | 964 |
| 962 EasyUnlockPrivateShowErrorBubbleFunction:: | 965 EasyUnlockPrivateShowErrorBubbleFunction:: |
| 963 EasyUnlockPrivateShowErrorBubbleFunction() { | 966 EasyUnlockPrivateShowErrorBubbleFunction() { |
| 964 } | 967 } |
| 965 | 968 |
| 966 EasyUnlockPrivateShowErrorBubbleFunction:: | 969 EasyUnlockPrivateShowErrorBubbleFunction:: |
| 967 ~EasyUnlockPrivateShowErrorBubbleFunction() { | 970 ~EasyUnlockPrivateShowErrorBubbleFunction() { |
| 968 } | 971 } |
| 969 | 972 |
| 970 bool EasyUnlockPrivateShowErrorBubbleFunction::RunSync() { | 973 bool EasyUnlockPrivateShowErrorBubbleFunction::RunSync() { |
| 971 content::WebContents* web_contents = GetAssociatedWebContents(); | 974 content::WebContents* web_contents = GetAssociatedWebContents(); |
| 972 if (!web_contents) { | 975 if (!web_contents) { |
| 973 SetError("A foreground app window is required."); | 976 SetError("A foreground app window is required."); |
| 974 return true; | 977 return true; |
| 975 } | 978 } |
| 976 | 979 |
| 977 scoped_ptr<easy_unlock_private::ShowErrorBubble::Params> params( | 980 std::unique_ptr<easy_unlock_private::ShowErrorBubble::Params> params( |
| 978 easy_unlock_private::ShowErrorBubble::Params::Create(*args_)); | 981 easy_unlock_private::ShowErrorBubble::Params::Create(*args_)); |
| 979 EXTENSION_FUNCTION_VALIDATE(params.get()); | 982 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 980 | 983 |
| 981 if (params->link_range.start < 0 || | 984 if (params->link_range.start < 0 || |
| 982 params->link_range.end < 0 || | 985 params->link_range.end < 0 || |
| 983 base::saturated_cast<size_t>(params->link_range.end) > | 986 base::saturated_cast<size_t>(params->link_range.end) > |
| 984 params->message.size()) { | 987 params->message.size()) { |
| 985 SetError("Invalid link range."); | 988 SetError("Invalid link range."); |
| 986 return true; | 989 return true; |
| 987 } | 990 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 | 1024 |
| 1022 EasyUnlockPrivateSetAutoPairingResultFunction:: | 1025 EasyUnlockPrivateSetAutoPairingResultFunction:: |
| 1023 EasyUnlockPrivateSetAutoPairingResultFunction() { | 1026 EasyUnlockPrivateSetAutoPairingResultFunction() { |
| 1024 } | 1027 } |
| 1025 | 1028 |
| 1026 EasyUnlockPrivateSetAutoPairingResultFunction:: | 1029 EasyUnlockPrivateSetAutoPairingResultFunction:: |
| 1027 ~EasyUnlockPrivateSetAutoPairingResultFunction() { | 1030 ~EasyUnlockPrivateSetAutoPairingResultFunction() { |
| 1028 } | 1031 } |
| 1029 | 1032 |
| 1030 bool EasyUnlockPrivateSetAutoPairingResultFunction::RunSync() { | 1033 bool EasyUnlockPrivateSetAutoPairingResultFunction::RunSync() { |
| 1031 scoped_ptr<easy_unlock_private::SetAutoPairingResult::Params> params = | 1034 std::unique_ptr<easy_unlock_private::SetAutoPairingResult::Params> params = |
| 1032 easy_unlock_private::SetAutoPairingResult::Params::Create(*args_); | 1035 easy_unlock_private::SetAutoPairingResult::Params::Create(*args_); |
| 1033 EXTENSION_FUNCTION_VALIDATE(params); | 1036 EXTENSION_FUNCTION_VALIDATE(params); |
| 1034 | 1037 |
| 1035 std::string error_message; | 1038 std::string error_message; |
| 1036 if (params->result.error_message) | 1039 if (params->result.error_message) |
| 1037 error_message = *params->result.error_message; | 1040 error_message = *params->result.error_message; |
| 1038 | 1041 |
| 1039 Profile* profile = Profile::FromBrowserContext(browser_context()); | 1042 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 1040 EasyUnlockService::Get(profile) | 1043 EasyUnlockService::Get(profile) |
| 1041 ->SetAutoPairingResult(params->result.success, error_message); | 1044 ->SetAutoPairingResult(params->result.success, error_message); |
| 1042 | 1045 |
| 1043 return true; | 1046 return true; |
| 1044 } | 1047 } |
| 1045 | 1048 |
| 1046 EasyUnlockPrivateFindSetupConnectionFunction:: | 1049 EasyUnlockPrivateFindSetupConnectionFunction:: |
| 1047 EasyUnlockPrivateFindSetupConnectionFunction() | 1050 EasyUnlockPrivateFindSetupConnectionFunction() |
| 1048 : bluetooth_throttler_(new proximity_auth::BluetoothThrottlerImpl( | 1051 : bluetooth_throttler_(new proximity_auth::BluetoothThrottlerImpl( |
| 1049 make_scoped_ptr(new base::DefaultTickClock()))) {} | 1052 base::WrapUnique(new base::DefaultTickClock()))) {} |
| 1050 | 1053 |
| 1051 EasyUnlockPrivateFindSetupConnectionFunction:: | 1054 EasyUnlockPrivateFindSetupConnectionFunction:: |
| 1052 ~EasyUnlockPrivateFindSetupConnectionFunction() { | 1055 ~EasyUnlockPrivateFindSetupConnectionFunction() { |
| 1053 // |connection_finder_| has a raw pointer to |bluetooth_throttler_|, so it | 1056 // |connection_finder_| has a raw pointer to |bluetooth_throttler_|, so it |
| 1054 // should be destroyed first. | 1057 // should be destroyed first. |
| 1055 connection_finder_.reset(); | 1058 connection_finder_.reset(); |
| 1056 bluetooth_throttler_.reset(); | 1059 bluetooth_throttler_.reset(); |
| 1057 } | 1060 } |
| 1058 | 1061 |
| 1059 void EasyUnlockPrivateFindSetupConnectionFunction:: | 1062 void EasyUnlockPrivateFindSetupConnectionFunction:: |
| 1060 OnConnectionFinderTimedOut() { | 1063 OnConnectionFinderTimedOut() { |
| 1061 SetError("No connection found."); | 1064 SetError("No connection found."); |
| 1062 connection_finder_.reset(); | 1065 connection_finder_.reset(); |
| 1063 SendResponse(false); | 1066 SendResponse(false); |
| 1064 } | 1067 } |
| 1065 | 1068 |
| 1066 void EasyUnlockPrivateFindSetupConnectionFunction::OnConnectionFound( | 1069 void EasyUnlockPrivateFindSetupConnectionFunction::OnConnectionFound( |
| 1067 scoped_ptr<proximity_auth::Connection> connection) { | 1070 std::unique_ptr<proximity_auth::Connection> connection) { |
| 1068 // Connection are not persistent by default. | 1071 // Connection are not persistent by default. |
| 1069 std::string device_address = connection->remote_device().bluetooth_address; | 1072 std::string device_address = connection->remote_device().bluetooth_address; |
| 1070 bool persistent = false; | 1073 bool persistent = false; |
| 1071 int connection_id = | 1074 int connection_id = |
| 1072 GetConnectionManager(browser_context()) | 1075 GetConnectionManager(browser_context()) |
| 1073 ->AddConnection(extension(), std::move(connection), persistent); | 1076 ->AddConnection(extension(), std::move(connection), persistent); |
| 1074 results_ = easy_unlock_private::FindSetupConnection::Results::Create( | 1077 results_ = easy_unlock_private::FindSetupConnection::Results::Create( |
| 1075 connection_id, device_address); | 1078 connection_id, device_address); |
| 1076 SendResponse(true); | 1079 SendResponse(true); |
| 1077 } | 1080 } |
| 1078 | 1081 |
| 1079 bool EasyUnlockPrivateFindSetupConnectionFunction::RunAsync() { | 1082 bool EasyUnlockPrivateFindSetupConnectionFunction::RunAsync() { |
| 1080 scoped_ptr<easy_unlock_private::FindSetupConnection::Params> params = | 1083 std::unique_ptr<easy_unlock_private::FindSetupConnection::Params> params = |
| 1081 easy_unlock_private::FindSetupConnection::Params::Create(*args_); | 1084 easy_unlock_private::FindSetupConnection::Params::Create(*args_); |
| 1082 EXTENSION_FUNCTION_VALIDATE(params); | 1085 EXTENSION_FUNCTION_VALIDATE(params); |
| 1083 | 1086 |
| 1084 // Creates a BLE connection finder to look for any device advertising | 1087 // Creates a BLE connection finder to look for any device advertising |
| 1085 // |params->setup_service_uuid|. | 1088 // |params->setup_service_uuid|. |
| 1086 connection_finder_.reset( | 1089 connection_finder_.reset( |
| 1087 new proximity_auth::BluetoothLowEnergyConnectionFinder( | 1090 new proximity_auth::BluetoothLowEnergyConnectionFinder( |
| 1088 proximity_auth::RemoteDevice(), params->setup_service_uuid, | 1091 proximity_auth::RemoteDevice(), params->setup_service_uuid, |
| 1089 proximity_auth::BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE, | 1092 proximity_auth::BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE, |
| 1090 nullptr, bluetooth_throttler_.get(), 3)); | 1093 nullptr, bluetooth_throttler_.get(), 3)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1101 return true; | 1104 return true; |
| 1102 } | 1105 } |
| 1103 | 1106 |
| 1104 EasyUnlockPrivateSetupConnectionStatusFunction:: | 1107 EasyUnlockPrivateSetupConnectionStatusFunction:: |
| 1105 EasyUnlockPrivateSetupConnectionStatusFunction() {} | 1108 EasyUnlockPrivateSetupConnectionStatusFunction() {} |
| 1106 | 1109 |
| 1107 EasyUnlockPrivateSetupConnectionStatusFunction:: | 1110 EasyUnlockPrivateSetupConnectionStatusFunction:: |
| 1108 ~EasyUnlockPrivateSetupConnectionStatusFunction() {} | 1111 ~EasyUnlockPrivateSetupConnectionStatusFunction() {} |
| 1109 | 1112 |
| 1110 bool EasyUnlockPrivateSetupConnectionStatusFunction::RunSync() { | 1113 bool EasyUnlockPrivateSetupConnectionStatusFunction::RunSync() { |
| 1111 scoped_ptr<easy_unlock_private::SetupConnectionStatus::Params> params = | 1114 std::unique_ptr<easy_unlock_private::SetupConnectionStatus::Params> params = |
| 1112 easy_unlock_private::SetupConnectionStatus::Params::Create(*args_); | 1115 easy_unlock_private::SetupConnectionStatus::Params::Create(*args_); |
| 1113 EXTENSION_FUNCTION_VALIDATE(params); | 1116 EXTENSION_FUNCTION_VALIDATE(params); |
| 1114 api::easy_unlock_private::ConnectionStatus status = | 1117 api::easy_unlock_private::ConnectionStatus status = |
| 1115 GetConnectionManager(browser_context()) | 1118 GetConnectionManager(browser_context()) |
| 1116 ->ConnectionStatus(extension(), params->connection_id); | 1119 ->ConnectionStatus(extension(), params->connection_id); |
| 1117 results_ = | 1120 results_ = |
| 1118 easy_unlock_private::SetupConnectionStatus::Results::Create(status); | 1121 easy_unlock_private::SetupConnectionStatus::Results::Create(status); |
| 1119 if (status == api::easy_unlock_private::CONNECTION_STATUS_NONE) | 1122 if (status == api::easy_unlock_private::CONNECTION_STATUS_NONE) |
| 1120 SetError("Invalid connectionId"); | 1123 SetError("Invalid connectionId"); |
| 1121 return true; | 1124 return true; |
| 1122 } | 1125 } |
| 1123 | 1126 |
| 1124 EasyUnlockPrivateSetupConnectionDisconnectFunction:: | 1127 EasyUnlockPrivateSetupConnectionDisconnectFunction:: |
| 1125 EasyUnlockPrivateSetupConnectionDisconnectFunction() {} | 1128 EasyUnlockPrivateSetupConnectionDisconnectFunction() {} |
| 1126 | 1129 |
| 1127 EasyUnlockPrivateSetupConnectionDisconnectFunction:: | 1130 EasyUnlockPrivateSetupConnectionDisconnectFunction:: |
| 1128 ~EasyUnlockPrivateSetupConnectionDisconnectFunction() {} | 1131 ~EasyUnlockPrivateSetupConnectionDisconnectFunction() {} |
| 1129 | 1132 |
| 1130 bool EasyUnlockPrivateSetupConnectionDisconnectFunction::RunSync() { | 1133 bool EasyUnlockPrivateSetupConnectionDisconnectFunction::RunSync() { |
| 1131 scoped_ptr<easy_unlock_private::SetupConnectionDisconnect::Params> params = | 1134 std::unique_ptr<easy_unlock_private::SetupConnectionDisconnect::Params> |
| 1132 easy_unlock_private::SetupConnectionDisconnect::Params::Create(*args_); | 1135 params = easy_unlock_private::SetupConnectionDisconnect::Params::Create( |
| 1136 *args_); |
| 1133 EXTENSION_FUNCTION_VALIDATE(params); | 1137 EXTENSION_FUNCTION_VALIDATE(params); |
| 1134 bool success = GetConnectionManager(browser_context()) | 1138 bool success = GetConnectionManager(browser_context()) |
| 1135 ->Disconnect(extension(), params->connection_id); | 1139 ->Disconnect(extension(), params->connection_id); |
| 1136 if (!success) | 1140 if (!success) |
| 1137 SetError("Invalid connectionId."); | 1141 SetError("Invalid connectionId."); |
| 1138 return true; | 1142 return true; |
| 1139 } | 1143 } |
| 1140 | 1144 |
| 1141 EasyUnlockPrivateSetupConnectionSendFunction:: | 1145 EasyUnlockPrivateSetupConnectionSendFunction:: |
| 1142 EasyUnlockPrivateSetupConnectionSendFunction() {} | 1146 EasyUnlockPrivateSetupConnectionSendFunction() {} |
| 1143 | 1147 |
| 1144 EasyUnlockPrivateSetupConnectionSendFunction:: | 1148 EasyUnlockPrivateSetupConnectionSendFunction:: |
| 1145 ~EasyUnlockPrivateSetupConnectionSendFunction() {} | 1149 ~EasyUnlockPrivateSetupConnectionSendFunction() {} |
| 1146 | 1150 |
| 1147 bool EasyUnlockPrivateSetupConnectionSendFunction::RunSync() { | 1151 bool EasyUnlockPrivateSetupConnectionSendFunction::RunSync() { |
| 1148 scoped_ptr<easy_unlock_private::SetupConnectionSend::Params> params = | 1152 std::unique_ptr<easy_unlock_private::SetupConnectionSend::Params> params = |
| 1149 easy_unlock_private::SetupConnectionSend::Params::Create(*args_); | 1153 easy_unlock_private::SetupConnectionSend::Params::Create(*args_); |
| 1150 EXTENSION_FUNCTION_VALIDATE(params); | 1154 EXTENSION_FUNCTION_VALIDATE(params); |
| 1151 std::string payload(params->data.begin(), params->data.end()); | 1155 std::string payload(params->data.begin(), params->data.end()); |
| 1152 bool success = GetConnectionManager(browser_context()) | 1156 bool success = GetConnectionManager(browser_context()) |
| 1153 ->SendMessage(extension(), params->connection_id, payload); | 1157 ->SendMessage(extension(), params->connection_id, payload); |
| 1154 if (!success) | 1158 if (!success) |
| 1155 SetError("Invalid connectionId."); | 1159 SetError("Invalid connectionId."); |
| 1156 return true; | 1160 return true; |
| 1157 } | 1161 } |
| 1158 | 1162 |
| 1159 EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction:: | 1163 EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction:: |
| 1160 EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction() {} | 1164 EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction() {} |
| 1161 | 1165 |
| 1162 EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction:: | 1166 EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction:: |
| 1163 ~EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction() {} | 1167 ~EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction() {} |
| 1164 | 1168 |
| 1165 bool EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction::RunSync() { | 1169 bool EasyUnlockPrivateSetupConnectionGetDeviceAddressFunction::RunSync() { |
| 1166 scoped_ptr<easy_unlock_private::SetupConnectionGetDeviceAddress::Params> | 1170 std::unique_ptr<easy_unlock_private::SetupConnectionGetDeviceAddress::Params> |
| 1167 params = | 1171 params = |
| 1168 easy_unlock_private::SetupConnectionGetDeviceAddress::Params::Create( | 1172 easy_unlock_private::SetupConnectionGetDeviceAddress::Params::Create( |
| 1169 *args_); | 1173 *args_); |
| 1170 EXTENSION_FUNCTION_VALIDATE(params); | 1174 EXTENSION_FUNCTION_VALIDATE(params); |
| 1171 std::string device_address = | 1175 std::string device_address = |
| 1172 GetConnectionManager(browser_context()) | 1176 GetConnectionManager(browser_context()) |
| 1173 ->GetDeviceAddress(extension(), params->connection_id); | 1177 ->GetDeviceAddress(extension(), params->connection_id); |
| 1174 results_ = | 1178 results_ = |
| 1175 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( | 1179 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( |
| 1176 device_address); | 1180 device_address); |
| 1177 if (device_address.empty()) | 1181 if (device_address.empty()) |
| 1178 SetError("Invalid connectionId."); | 1182 SetError("Invalid connectionId."); |
| 1179 return true; | 1183 return true; |
| 1180 } | 1184 } |
| 1181 | 1185 |
| 1182 } // namespace extensions | 1186 } // namespace extensions |
| OLD | NEW |