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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "build/build_config.h" | 22 #include "build/build_config.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_
connection_manager.h" |
24 #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" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" | 26 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
27 #include "chrome/browser/signin/easy_unlock_service.h" | 27 #include "chrome/browser/signin/easy_unlock_service.h" |
28 #include "chrome/browser/signin/easy_unlock_service_regular.h" | 28 #include "chrome/browser/signin/easy_unlock_service_regular.h" |
29 #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" | 29 #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" |
30 #include "chrome/common/extensions/api/easy_unlock_private.h" | 30 #include "chrome/common/extensions/api/easy_unlock_private.h" |
31 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 32 #include "components/cryptauth/cryptauth_device_manager.h" |
| 33 #include "components/cryptauth/cryptauth_enrollment_manager.h" |
| 34 #include "components/cryptauth/cryptauth_enrollment_utils.h" |
| 35 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| 36 #include "components/cryptauth/secure_message_delegate.h" |
32 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" | 37 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" |
33 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h
" | 38 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h
" |
34 #include "components/proximity_auth/bluetooth_throttler_impl.h" | 39 #include "components/proximity_auth/bluetooth_throttler_impl.h" |
35 #include "components/proximity_auth/bluetooth_util.h" | 40 #include "components/proximity_auth/bluetooth_util.h" |
36 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h" | |
37 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" | |
38 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h" | |
39 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" | |
40 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | |
41 #include "components/proximity_auth/logging/logging.h" | 41 #include "components/proximity_auth/logging/logging.h" |
42 #include "components/proximity_auth/proximity_auth_client.h" | 42 #include "components/proximity_auth/proximity_auth_client.h" |
43 #include "components/proximity_auth/remote_device.h" | 43 #include "components/proximity_auth/remote_device.h" |
44 #include "components/proximity_auth/screenlock_bridge.h" | 44 #include "components/proximity_auth/screenlock_bridge.h" |
45 #include "components/proximity_auth/screenlock_state.h" | 45 #include "components/proximity_auth/screenlock_state.h" |
46 #include "components/proximity_auth/switches.h" | 46 #include "components/proximity_auth/switches.h" |
47 #include "components/signin/core/account_id/account_id.h" | 47 #include "components/signin/core/account_id/account_id.h" |
48 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
49 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
50 #include "extensions/browser/browser_context_keyed_api_factory.h" | 50 #include "extensions/browser/browser_context_keyed_api_factory.h" |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 easy_unlock_private::GetPermitAccess::Results::Create(*permit))); | 593 easy_unlock_private::GetPermitAccess::Results::Create(*permit))); |
594 } | 594 } |
595 | 595 |
596 return RespondNow(NoArguments()); | 596 return RespondNow(NoArguments()); |
597 } | 597 } |
598 | 598 |
599 void EasyUnlockPrivateGetPermitAccessFunction::GetKeyPairForExperiment( | 599 void EasyUnlockPrivateGetPermitAccessFunction::GetKeyPairForExperiment( |
600 std::string* user_public_key, | 600 std::string* user_public_key, |
601 std::string* user_private_key) { | 601 std::string* user_private_key) { |
602 Profile* profile = Profile::FromBrowserContext(browser_context()); | 602 Profile* profile = Profile::FromBrowserContext(browser_context()); |
603 proximity_auth::CryptAuthEnrollmentManager* enrollment_manager = | 603 cryptauth::CryptAuthEnrollmentManager* enrollment_manager = |
604 EasyUnlockService::Get(profile) | 604 EasyUnlockService::Get(profile) |
605 ->proximity_auth_client() | 605 ->proximity_auth_client() |
606 ->GetCryptAuthEnrollmentManager(); | 606 ->GetCryptAuthEnrollmentManager(); |
607 base::Base64UrlEncode(enrollment_manager->GetUserPublicKey(), | 607 base::Base64UrlEncode(enrollment_manager->GetUserPublicKey(), |
608 base::Base64UrlEncodePolicy::INCLUDE_PADDING, | 608 base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
609 user_public_key); | 609 user_public_key); |
610 base::Base64UrlEncode(enrollment_manager->GetUserPrivateKey(), | 610 base::Base64UrlEncode(enrollment_manager->GetUserPrivateKey(), |
611 base::Base64UrlEncodePolicy::INCLUDE_PADDING, | 611 base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
612 user_private_key); | 612 user_private_key); |
613 } | 613 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 SendResponse(true); | 711 SendResponse(true); |
712 } | 712 } |
713 | 713 |
714 return true; | 714 return true; |
715 } | 715 } |
716 | 716 |
717 std::string EasyUnlockPrivateGetRemoteDevicesFunction::GetUserPrivateKey() { | 717 std::string EasyUnlockPrivateGetRemoteDevicesFunction::GetUserPrivateKey() { |
718 Profile* profile = Profile::FromBrowserContext(browser_context()); | 718 Profile* profile = Profile::FromBrowserContext(browser_context()); |
719 proximity_auth::ProximityAuthClient* client = | 719 proximity_auth::ProximityAuthClient* client = |
720 EasyUnlockService::Get(profile)->proximity_auth_client(); | 720 EasyUnlockService::Get(profile)->proximity_auth_client(); |
721 proximity_auth::CryptAuthEnrollmentManager* enrollment_manager = | 721 cryptauth::CryptAuthEnrollmentManager* enrollment_manager = |
722 client->GetCryptAuthEnrollmentManager(); | 722 client->GetCryptAuthEnrollmentManager(); |
723 return enrollment_manager->GetUserPrivateKey(); | 723 return enrollment_manager->GetUserPrivateKey(); |
724 } | 724 } |
725 | 725 |
726 std::vector<cryptauth::ExternalDeviceInfo> | 726 std::vector<cryptauth::ExternalDeviceInfo> |
727 EasyUnlockPrivateGetRemoteDevicesFunction::GetUnlockKeys() { | 727 EasyUnlockPrivateGetRemoteDevicesFunction::GetUnlockKeys() { |
728 Profile* profile = Profile::FromBrowserContext(browser_context()); | 728 Profile* profile = Profile::FromBrowserContext(browser_context()); |
729 proximity_auth::ProximityAuthClient* client = | 729 proximity_auth::ProximityAuthClient* client = |
730 EasyUnlockService::Get(profile)->proximity_auth_client(); | 730 EasyUnlockService::Get(profile)->proximity_auth_client(); |
731 proximity_auth::CryptAuthDeviceManager* device_manager = | 731 cryptauth::CryptAuthDeviceManager* device_manager = |
732 client->GetCryptAuthDeviceManager(); | 732 client->GetCryptAuthDeviceManager(); |
733 return device_manager->unlock_keys(); | 733 return device_manager->unlock_keys(); |
734 } | 734 } |
735 | 735 |
736 void EasyUnlockPrivateGetRemoteDevicesFunction::ReturnDevicesForExperiment() { | 736 void EasyUnlockPrivateGetRemoteDevicesFunction::ReturnDevicesForExperiment() { |
737 // Check that we are inside a user profile. | 737 // Check that we are inside a user profile. |
738 Profile* profile = Profile::FromBrowserContext(browser_context()); | 738 Profile* profile = Profile::FromBrowserContext(browser_context()); |
739 EasyUnlockService* easy_unlock_service = EasyUnlockService::Get(profile); | 739 EasyUnlockService* easy_unlock_service = EasyUnlockService::Get(profile); |
740 if (easy_unlock_service->GetType() != EasyUnlockService::TYPE_REGULAR) { | 740 if (easy_unlock_service->GetType() != EasyUnlockService::TYPE_REGULAR) { |
741 SetError("This function must be called inside a user session."); | 741 SetError("This function must be called inside a user session."); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 if (account_id.is_valid()) { | 902 if (account_id.is_valid()) { |
903 easy_unlock_private::UserInfo user; | 903 easy_unlock_private::UserInfo user; |
904 user.user_id = account_id.GetUserEmail(); | 904 user.user_id = account_id.GetUserEmail(); |
905 user.logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; | 905 user.logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; |
906 user.data_ready = user.logged_in || service->GetRemoteDevices() != NULL; | 906 user.data_ready = user.logged_in || service->GetRemoteDevices() != NULL; |
907 | 907 |
908 EasyUnlockService::UserSettings user_settings = | 908 EasyUnlockService::UserSettings user_settings = |
909 EasyUnlockService::GetUserSettings(account_id); | 909 EasyUnlockService::GetUserSettings(account_id); |
910 user.require_close_proximity = user_settings.require_close_proximity; | 910 user.require_close_proximity = user_settings.require_close_proximity; |
911 | 911 |
912 user.device_user_id = proximity_auth::CalculateDeviceUserId( | 912 user.device_user_id = cryptauth::CalculateDeviceUserId( |
913 EasyUnlockService::GetDeviceId(), account_id.GetUserEmail()); | 913 EasyUnlockService::GetDeviceId(), account_id.GetUserEmail()); |
914 | 914 |
915 user.ble_discovery_enabled = | 915 user.ble_discovery_enabled = |
916 base::CommandLine::ForCurrentProcess()->HasSwitch( | 916 base::CommandLine::ForCurrentProcess()->HasSwitch( |
917 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery); | 917 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery); |
918 users.push_back(std::move(user)); | 918 users.push_back(std::move(user)); |
919 } | 919 } |
920 return RespondNow( | 920 return RespondNow( |
921 ArgumentList(easy_unlock_private::GetUserInfo::Results::Create(users))); | 921 ArgumentList(easy_unlock_private::GetUserInfo::Results::Create(users))); |
922 } | 922 } |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 GetConnectionManager(browser_context()) | 1181 GetConnectionManager(browser_context()) |
1182 ->GetDeviceAddress(extension(), params->connection_id); | 1182 ->GetDeviceAddress(extension(), params->connection_id); |
1183 if (device_address.empty()) | 1183 if (device_address.empty()) |
1184 return RespondNow(Error("Invalid connectionId.")); | 1184 return RespondNow(Error("Invalid connectionId.")); |
1185 return RespondNow(ArgumentList( | 1185 return RespondNow(ArgumentList( |
1186 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( | 1186 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( |
1187 device_address))); | 1187 device_address))); |
1188 } | 1188 } |
1189 | 1189 |
1190 } // namespace extensions | 1190 } // namespace extensions |
OLD | NEW |