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

Unified Diff: content/browser/bluetooth/bluetooth_device_chooser_controller.cc

Issue 2304213002: Show device connection and paired status in chooser on Mac (Closed)
Patch Set: updated variable name Created 4 years, 3 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: content/browser/bluetooth/bluetooth_device_chooser_controller.cc
diff --git a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
index d524f19a864af9ab0535804a44eb4ad78e27bf78..6833e604b15d42e1aaf64c6dd6bfcc21ae0f9802 100644
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
@@ -198,7 +198,9 @@ UMARequestDeviceOutcome OutcomeFromChooserEvent(BluetoothChooser::Event event) {
BluetoothDeviceChooserController::BluetoothDeviceChooserController(
WebBluetoothServiceImpl* web_bluetooth_service,
RenderFrameHost* render_frame_host,
- device::BluetoothAdapter* adapter)
+ device::BluetoothAdapter* adapter,
+ BluetoothAllowedDevicesMap* bluetooth_allowed_devices_map,
+ const url::Origin& origin)
: adapter_(adapter),
web_bluetooth_service_(web_bluetooth_service),
render_frame_host_(render_frame_host),
@@ -214,6 +216,8 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController(
// destructor starts.
base::Unretained(this)),
/*is_repeating=*/false),
+ bluetooth_allowed_devices_map_(bluetooth_allowed_devices_map),
+ origin_(origin),
weak_ptr_factory_(this) {
CHECK(adapter_);
}
@@ -350,11 +354,26 @@ void BluetoothDeviceChooserController::AddFilteredDevice(
const device::BluetoothDevice& device) {
if (chooser_.get() && MatchesFilters(device, options_->filters)) {
base::Optional<int8_t> rssi = device.GetInquiryRSSI();
+ bool is_paired = false;
+ const WebBluetoothDeviceId* device_id_ptr =
+ bluetooth_allowed_devices_map_->GetDeviceId(origin_,
+ device.GetAddress());
+ if (device_id_ptr) {
ortuno 2016/09/12 03:45:22 As long as the user has paired with the device in
juncai 2016/09/12 20:37:12 Done.
+ device::BluetoothDevice::UUIDSet uuids = device.GetUUIDs();
+ for (const auto& uuid : uuids) {
+ if (bluetooth_allowed_devices_map_->IsOriginAllowedToAccessService(
+ origin_, *device_id_ptr, uuid)) {
+ is_paired = true;
+ break;
+ }
+ }
+ }
+
chooser_->AddOrUpdateDevice(
device.GetAddress(), !!device.GetName() /* should_update_name */,
device.GetNameForDisplay(),
- // TODO(http://crbug.com/543466): Show connection and paired status.
- false /* is_gatt_connected */, false /* is_paired */,
+ device.IsGattConnected() /* is_gatt_connected */,
ortuno 2016/09/12 03:45:22 I don't think you need the comments anymore. It's
juncai 2016/09/12 20:37:12 Done.
+ is_paired /* is_paired */,
rssi ? CalculateSignalStrengthLevel(rssi.value()) : -1);
}
}

Powered by Google App Engine
This is Rietveld 408576698