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

Unified Diff: content/child/bluetooth/bluetooth_dispatcher.cc

Issue 885723002: bluetooth: Provide more device attributes in requestDevice reply. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-0
Patch Set: uuids initializer fixed. 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
« no previous file with comments | « content/child/bluetooth/bluetooth_dispatcher.h ('k') | content/common/bluetooth/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/bluetooth/bluetooth_dispatcher.cc
diff --git a/content/child/bluetooth/bluetooth_dispatcher.cc b/content/child/bluetooth/bluetooth_dispatcher.cc
index 41a28a9ee2738d1b042b7b4a1618df7bdc6e297a..47754246e1d7daa3ecf46b6bb3b709172333c8d3 100644
--- a/content/child/bluetooth/bluetooth_dispatcher.cc
+++ b/content/child/bluetooth/bluetooth_dispatcher.cc
@@ -18,6 +18,7 @@ using blink::WebBluetoothDevice;
using blink::WebBluetoothError;
using blink::WebBluetoothRequestDeviceCallbacks;
using blink::WebString;
+using blink::WebVector;
namespace content {
@@ -45,6 +46,20 @@ WebBluetoothError::ErrorType WebBluetoothErrorFromBluetoothError(
return WebBluetoothError::NotFoundError;
}
+WebBluetoothDevice::VendorIDSource GetWebVendorIdSource(
+ device::BluetoothDevice::VendorIDSource vendor_id_source) {
+ switch (vendor_id_source) {
+ case device::BluetoothDevice::VENDOR_ID_UNKNOWN:
+ return WebBluetoothDevice::VendorIDSource::Unknown;
+ case device::BluetoothDevice::VENDOR_ID_BLUETOOTH:
+ return WebBluetoothDevice::VendorIDSource::Bluetooth;
+ case device::BluetoothDevice::VENDOR_ID_USB:
+ return WebBluetoothDevice::VendorIDSource::USB;
+ }
+ NOTREACHED();
+ return WebBluetoothDevice::VendorIDSource::Unknown;
+}
+
} // namespace
BluetoothDispatcher::BluetoothDispatcher(ThreadSafeSender* sender)
@@ -104,11 +119,19 @@ void BluetoothDispatcher::OnWorkerRunLoopStopped() {
void BluetoothDispatcher::OnRequestDeviceSuccess(
int thread_id,
int request_id,
- const std::string& device_instance_id) {
+ const BluetoothDevice& device) {
DCHECK(pending_requests_.Lookup(request_id)) << request_id;
+
+ WebVector<WebString> uuids(device.uuids.size());
+ for (size_t i = 0; i < device.uuids.size(); ++i)
+ uuids[i] = WebString::fromUTF8(device.uuids[i].c_str());
+
pending_requests_.Lookup(request_id)
- ->onSuccess(
- new WebBluetoothDevice(WebString::fromUTF8(device_instance_id)));
+ ->onSuccess(new WebBluetoothDevice(
+ WebString::fromUTF8(device.instance_id), WebString(device.name),
+ device.device_class, GetWebVendorIdSource(device.vendor_id_source),
+ device.vendor_id, device.product_id, device.product_version,
+ device.paired, device.connected, uuids));
pending_requests_.Remove(request_id);
}
« no previous file with comments | « content/child/bluetooth/bluetooth_dispatcher.h ('k') | content/common/bluetooth/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698