| 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 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" | 30 #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" |
| 31 #include "chrome/common/extensions/api/easy_unlock_private.h" | 31 #include "chrome/common/extensions/api/easy_unlock_private.h" |
| 32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 33 #include "components/cryptauth/bluetooth_throttler_impl.h" | 33 #include "components/cryptauth/bluetooth_throttler_impl.h" |
| 34 #include "components/cryptauth/cryptauth_device_manager.h" | 34 #include "components/cryptauth/cryptauth_device_manager.h" |
| 35 #include "components/cryptauth/cryptauth_enrollment_manager.h" | 35 #include "components/cryptauth/cryptauth_enrollment_manager.h" |
| 36 #include "components/cryptauth/cryptauth_enrollment_utils.h" | 36 #include "components/cryptauth/cryptauth_enrollment_utils.h" |
| 37 #include "components/cryptauth/proto/cryptauth_api.pb.h" | 37 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| 38 #include "components/cryptauth/remote_device.h" | 38 #include "components/cryptauth/remote_device.h" |
| 39 #include "components/cryptauth/secure_message_delegate.h" | 39 #include "components/cryptauth/secure_message_delegate.h" |
| 40 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" | 40 #include "components/proximity_auth/bluetooth_low_energy_connection_finder.h" |
| 41 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h
" | |
| 42 #include "components/proximity_auth/bluetooth_util.h" | 41 #include "components/proximity_auth/bluetooth_util.h" |
| 43 #include "components/proximity_auth/logging/logging.h" | 42 #include "components/proximity_auth/logging/logging.h" |
| 44 #include "components/proximity_auth/proximity_auth_client.h" | 43 #include "components/proximity_auth/proximity_auth_client.h" |
| 45 #include "components/proximity_auth/screenlock_bridge.h" | 44 #include "components/proximity_auth/screenlock_bridge.h" |
| 46 #include "components/proximity_auth/screenlock_state.h" | 45 #include "components/proximity_auth/screenlock_state.h" |
| 47 #include "components/proximity_auth/switches.h" | 46 #include "components/proximity_auth/switches.h" |
| 48 #include "components/signin/core/account_id/account_id.h" | 47 #include "components/signin/core/account_id/account_id.h" |
| 49 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
| 50 #include "extensions/browser/browser_context_keyed_api_factory.h" | 49 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 51 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 results_ = easy_unlock_private::FindSetupConnection::Results::Create( | 1076 results_ = easy_unlock_private::FindSetupConnection::Results::Create( |
| 1078 connection_id, device_address); | 1077 connection_id, device_address); |
| 1079 SendResponse(true); | 1078 SendResponse(true); |
| 1080 } | 1079 } |
| 1081 | 1080 |
| 1082 bool EasyUnlockPrivateFindSetupConnectionFunction::RunAsync() { | 1081 bool EasyUnlockPrivateFindSetupConnectionFunction::RunAsync() { |
| 1083 std::unique_ptr<easy_unlock_private::FindSetupConnection::Params> params = | 1082 std::unique_ptr<easy_unlock_private::FindSetupConnection::Params> params = |
| 1084 easy_unlock_private::FindSetupConnection::Params::Create(*args_); | 1083 easy_unlock_private::FindSetupConnection::Params::Create(*args_); |
| 1085 EXTENSION_FUNCTION_VALIDATE(params); | 1084 EXTENSION_FUNCTION_VALIDATE(params); |
| 1086 | 1085 |
| 1087 // Creates a BLE connection finder to look for any device advertising | 1086 // TODO(tengs): Reimplement scanning for the remote device. |
| 1088 // |params->setup_service_uuid|. | |
| 1089 connection_finder_.reset( | |
| 1090 new proximity_auth::BluetoothLowEnergyConnectionFinder( | |
| 1091 cryptauth::RemoteDevice(), params->setup_service_uuid, | |
| 1092 proximity_auth::BluetoothLowEnergyConnectionFinder::FIND_ANY_DEVICE, | |
| 1093 nullptr, cryptauth::BluetoothThrottlerImpl::GetInstance(), 3)); | |
| 1094 | |
| 1095 connection_finder_->Find(base::Bind( | |
| 1096 &EasyUnlockPrivateFindSetupConnectionFunction::OnConnectionFound, this)); | |
| 1097 | 1087 |
| 1098 timer_.reset(new base::OneShotTimer()); | 1088 timer_.reset(new base::OneShotTimer()); |
| 1099 timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(params->time_out), | 1089 timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(params->time_out), |
| 1100 base::Bind(&EasyUnlockPrivateFindSetupConnectionFunction:: | 1090 base::Bind(&EasyUnlockPrivateFindSetupConnectionFunction:: |
| 1101 OnConnectionFinderTimedOut, | 1091 OnConnectionFinderTimedOut, |
| 1102 this)); | 1092 this)); |
| 1103 | 1093 |
| 1104 return true; | 1094 return true; |
| 1105 } | 1095 } |
| 1106 | 1096 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 GetConnectionManager(browser_context()) | 1169 GetConnectionManager(browser_context()) |
| 1180 ->GetDeviceAddress(extension(), params->connection_id); | 1170 ->GetDeviceAddress(extension(), params->connection_id); |
| 1181 if (device_address.empty()) | 1171 if (device_address.empty()) |
| 1182 return RespondNow(Error("Invalid connectionId.")); | 1172 return RespondNow(Error("Invalid connectionId.")); |
| 1183 return RespondNow(ArgumentList( | 1173 return RespondNow(ArgumentList( |
| 1184 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( | 1174 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( |
| 1185 device_address))); | 1175 device_address))); |
| 1186 } | 1176 } |
| 1187 | 1177 |
| 1188 } // namespace extensions | 1178 } // namespace extensions |
| OLD | NEW |