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/bluetooth_low_energy_connection_finder.h" | 40 #include "components/proximity_auth/bluetooth_low_energy_setup_connection_finder
.h" |
41 #include "components/proximity_auth/bluetooth_util.h" | 41 #include "components/proximity_auth/bluetooth_util.h" |
42 #include "components/proximity_auth/logging/logging.h" | 42 #include "components/proximity_auth/logging/logging.h" |
43 #include "components/proximity_auth/proximity_auth_client.h" | 43 #include "components/proximity_auth/proximity_auth_client.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/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
49 #include "extensions/browser/browser_context_keyed_api_factory.h" | 49 #include "extensions/browser/browser_context_keyed_api_factory.h" |
50 #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... |
1076 results_ = easy_unlock_private::FindSetupConnection::Results::Create( | 1076 results_ = easy_unlock_private::FindSetupConnection::Results::Create( |
1077 connection_id, device_address); | 1077 connection_id, device_address); |
1078 SendResponse(true); | 1078 SendResponse(true); |
1079 } | 1079 } |
1080 | 1080 |
1081 bool EasyUnlockPrivateFindSetupConnectionFunction::RunAsync() { | 1081 bool EasyUnlockPrivateFindSetupConnectionFunction::RunAsync() { |
1082 std::unique_ptr<easy_unlock_private::FindSetupConnection::Params> params = | 1082 std::unique_ptr<easy_unlock_private::FindSetupConnection::Params> params = |
1083 easy_unlock_private::FindSetupConnection::Params::Create(*args_); | 1083 easy_unlock_private::FindSetupConnection::Params::Create(*args_); |
1084 EXTENSION_FUNCTION_VALIDATE(params); | 1084 EXTENSION_FUNCTION_VALIDATE(params); |
1085 | 1085 |
1086 // TODO(tengs): Reimplement scanning for the remote device. | 1086 // Creates a BLE connection finder to look for any device advertising |
| 1087 // |params->setup_service_uuid|. |
| 1088 connection_finder_.reset( |
| 1089 new proximity_auth::BluetoothLowEnergySetupConnectionFinder( |
| 1090 params->setup_service_uuid, |
| 1091 cryptauth::BluetoothThrottlerImpl::GetInstance())); |
| 1092 |
| 1093 connection_finder_->Find(base::Bind( |
| 1094 &EasyUnlockPrivateFindSetupConnectionFunction::OnConnectionFound, this)); |
1087 | 1095 |
1088 timer_.reset(new base::OneShotTimer()); | 1096 timer_.reset(new base::OneShotTimer()); |
1089 timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(params->time_out), | 1097 timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(params->time_out), |
1090 base::Bind(&EasyUnlockPrivateFindSetupConnectionFunction:: | 1098 base::Bind(&EasyUnlockPrivateFindSetupConnectionFunction:: |
1091 OnConnectionFinderTimedOut, | 1099 OnConnectionFinderTimedOut, |
1092 this)); | 1100 this)); |
1093 | 1101 |
1094 return true; | 1102 return true; |
1095 } | 1103 } |
1096 | 1104 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 GetConnectionManager(browser_context()) | 1177 GetConnectionManager(browser_context()) |
1170 ->GetDeviceAddress(extension(), params->connection_id); | 1178 ->GetDeviceAddress(extension(), params->connection_id); |
1171 if (device_address.empty()) | 1179 if (device_address.empty()) |
1172 return RespondNow(Error("Invalid connectionId.")); | 1180 return RespondNow(Error("Invalid connectionId.")); |
1173 return RespondNow(ArgumentList( | 1181 return RespondNow(ArgumentList( |
1174 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( | 1182 easy_unlock_private::SetupConnectionGetDeviceAddress::Results::Create( |
1175 device_address))); | 1183 device_address))); |
1176 } | 1184 } |
1177 | 1185 |
1178 } // namespace extensions | 1186 } // namespace extensions |
OLD | NEW |