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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64url.h" | 9 #include "base/base64url.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" | 35 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" |
36 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h" | 36 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h" |
37 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" | 37 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" |
38 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | 38 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" |
39 #include "components/proximity_auth/logging/logging.h" | 39 #include "components/proximity_auth/logging/logging.h" |
40 #include "components/proximity_auth/proximity_auth_client.h" | 40 #include "components/proximity_auth/proximity_auth_client.h" |
41 #include "components/proximity_auth/remote_device.h" | 41 #include "components/proximity_auth/remote_device.h" |
42 #include "components/proximity_auth/screenlock_bridge.h" | 42 #include "components/proximity_auth/screenlock_bridge.h" |
43 #include "components/proximity_auth/screenlock_state.h" | 43 #include "components/proximity_auth/screenlock_state.h" |
44 #include "components/proximity_auth/switches.h" | 44 #include "components/proximity_auth/switches.h" |
| 45 #include "components/signin/core/account_id/account_id.h" |
45 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
47 #include "extensions/browser/browser_context_keyed_api_factory.h" | 48 #include "extensions/browser/browser_context_keyed_api_factory.h" |
48 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
49 #include "ui/gfx/geometry/rect.h" | 50 #include "ui/gfx/geometry/rect.h" |
50 #include "ui/gfx/range/range.h" | 51 #include "ui/gfx/range/range.h" |
51 | 52 |
52 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
53 #include "ash/system/chromeos/devicetype_utils.h" | 54 #include "ash/system/chromeos/devicetype_utils.h" |
54 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" | 55 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 const std::string challenge = | 835 const std::string challenge = |
835 EasyUnlockService::Get(profile)->GetChallenge(); | 836 EasyUnlockService::Get(profile)->GetChallenge(); |
836 if (!challenge.empty() && !params->nonce.empty()) { | 837 if (!challenge.empty() && !params->nonce.empty()) { |
837 EasyUnlockTpmKeyManager* key_manager = | 838 EasyUnlockTpmKeyManager* key_manager = |
838 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile); | 839 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile); |
839 if (!key_manager) { | 840 if (!key_manager) { |
840 SetError("No EasyUnlockTpmKeyManager."); | 841 SetError("No EasyUnlockTpmKeyManager."); |
841 return false; | 842 return false; |
842 } | 843 } |
843 key_manager->SignUsingTpmKey( | 844 key_manager->SignUsingTpmKey( |
844 EasyUnlockService::Get(profile)->GetUserEmail(), | 845 EasyUnlockService::Get(profile)->GetAccountId(), |
845 std::string(params->nonce.begin(), params->nonce.end()), | 846 std::string(params->nonce.begin(), params->nonce.end()), |
846 base::Bind(&EasyUnlockPrivateGetSignInChallengeFunction::OnDone, this, | 847 base::Bind(&EasyUnlockPrivateGetSignInChallengeFunction::OnDone, this, |
847 challenge)); | 848 challenge)); |
848 } else { | 849 } else { |
849 OnDone(challenge, std::string()); | 850 OnDone(challenge, std::string()); |
850 } | 851 } |
851 return true; | 852 return true; |
852 #else // if !defined(OS_CHROMEOS) | 853 #else // if !defined(OS_CHROMEOS) |
853 SetError("Sign-in not supported."); | 854 SetError("Sign-in not supported."); |
854 return false; | 855 return false; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() { | 887 EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() { |
887 } | 888 } |
888 | 889 |
889 EasyUnlockPrivateGetUserInfoFunction::~EasyUnlockPrivateGetUserInfoFunction() { | 890 EasyUnlockPrivateGetUserInfoFunction::~EasyUnlockPrivateGetUserInfoFunction() { |
890 } | 891 } |
891 | 892 |
892 bool EasyUnlockPrivateGetUserInfoFunction::RunSync() { | 893 bool EasyUnlockPrivateGetUserInfoFunction::RunSync() { |
893 EasyUnlockService* service = | 894 EasyUnlockService* service = |
894 EasyUnlockService::Get(Profile::FromBrowserContext(browser_context())); | 895 EasyUnlockService::Get(Profile::FromBrowserContext(browser_context())); |
895 std::vector<linked_ptr<easy_unlock_private::UserInfo> > users; | 896 std::vector<linked_ptr<easy_unlock_private::UserInfo> > users; |
896 std::string user_id = service->GetUserEmail(); | 897 const AccountId& account_id = service->GetAccountId(); |
897 if (!user_id.empty()) { | 898 if (account_id.is_valid()) { |
898 users.push_back( | 899 users.push_back( |
899 linked_ptr<easy_unlock_private::UserInfo>( | 900 linked_ptr<easy_unlock_private::UserInfo>( |
900 new easy_unlock_private::UserInfo())); | 901 new easy_unlock_private::UserInfo())); |
901 users[0]->user_id = user_id; | 902 users[0]->user_id = account_id.GetUserEmail(); |
902 users[0]->logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; | 903 users[0]->logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; |
903 users[0]->data_ready = users[0]->logged_in || | 904 users[0]->data_ready = users[0]->logged_in || |
904 service->GetRemoteDevices() != NULL; | 905 service->GetRemoteDevices() != NULL; |
905 | 906 |
906 EasyUnlockService::UserSettings user_settings = | 907 EasyUnlockService::UserSettings user_settings = |
907 EasyUnlockService::GetUserSettings(user_id); | 908 EasyUnlockService::GetUserSettings(account_id); |
908 users[0]->require_close_proximity = user_settings.require_close_proximity; | 909 users[0]->require_close_proximity = user_settings.require_close_proximity; |
909 | 910 |
910 users[0]->device_user_id = proximity_auth::CalculateDeviceUserId( | 911 users[0]->device_user_id = proximity_auth::CalculateDeviceUserId( |
911 EasyUnlockService::GetDeviceId(), user_id); | 912 EasyUnlockService::GetDeviceId(), account_id.GetUserEmail()); |
912 | 913 |
913 users[0]->ble_discovery_enabled = | 914 users[0]->ble_discovery_enabled = |
914 base::CommandLine::ForCurrentProcess()->HasSwitch( | 915 base::CommandLine::ForCurrentProcess()->HasSwitch( |
915 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery); | 916 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery); |
916 } | 917 } |
917 results_ = easy_unlock_private::GetUserInfo::Results::Create(users); | 918 results_ = easy_unlock_private::GetUserInfo::Results::Create(users); |
918 return true; | 919 return true; |
919 } | 920 } |
920 | 921 |
921 EasyUnlockPrivateGetConnectionInfoFunction:: | 922 EasyUnlockPrivateGetConnectionInfoFunction:: |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 ->GetDeviceAddress(extension(), params->connection_id); | 1176 ->GetDeviceAddress(extension(), params->connection_id); |
1176 results_ = | 1177 results_ = |
1177 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( | 1178 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( |
1178 device_address); | 1179 device_address); |
1179 if (device_address.empty()) | 1180 if (device_address.empty()) |
1180 SetError("Invalid connectionId."); | 1181 SetError("Invalid connectionId."); |
1181 return true; | 1182 return true; |
1182 } | 1183 } |
1183 | 1184 |
1184 } // namespace extensions | 1185 } // namespace extensions |
OLD | NEW |