Index: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
diff --git a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
index 6021e28fa026c304e7e85f335715e7399b3b2bd8..3a5175e868c463d8340b8f8882864a264360a529 100644 |
--- a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
+++ b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
@@ -710,5 +710,48 @@ bool EasyUnlockPrivateGetUserImageFunction::RunSync() { |
return true; |
} |
+EasyUnlockPrivateGetConnectionInfoFunction:: |
+ EasyUnlockPrivateGetConnectionInfoFunction() { |
+} |
+ |
+EasyUnlockPrivateGetConnectionInfoFunction:: |
+ ~EasyUnlockPrivateGetConnectionInfoFunction() { |
+} |
+ |
+bool EasyUnlockPrivateGetConnectionInfoFunction::DoWork( |
+ scoped_refptr<device::BluetoothAdapter> adapter) { |
+ scoped_ptr<easy_unlock_private::GetConnectionInfo::Params> params = |
+ easy_unlock_private::GetConnectionInfo::Params::Create(*args_); |
+ EXTENSION_FUNCTION_VALIDATE(params); |
+ |
+ device::BluetoothDevice* device = adapter->GetDevice(params->device_address); |
+ |
+ std::string error; |
+ if (!device) |
+ error = "Invalid Bluetooth device."; |
+ else if (!device->IsConnected()) |
+ error = "Bluetooth device not connected."; |
+ |
+ if (!error.empty()) { |
+ SetError(error); |
+ SendResponse(false); |
+ return true; |
+ } |
+ |
+ device->GetConnectionInfo(base::Bind( |
+ &EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo, this)); |
+ return false; |
+} |
+ |
+void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( |
+ const device::BluetoothDevice::ConnectionInfo& connection_info) { |
+ scoped_ptr<base::ListValue> results(new base::ListValue()); |
+ results->AppendInteger(connection_info.rssi); |
+ results->AppendInteger(connection_info.transmit_power); |
+ results->AppendInteger(connection_info.max_transmit_power); |
+ SetResultList(results.Pass()); |
+ SendResponse(true); |
+} |
+ |
} // namespace api |
} // namespace extensions |