Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1655)

Unified Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc

Issue 813303003: Add easyUnlockPrivate.getConnection API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
Yoyo Zhou 2015/01/08 20:23:05 Aside: It looks like BluetoothExtensionFunction ju
Tim Song 2015/01/09 00:31:46 I followed the styles of the other subclasses that
+ }
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698