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

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

Issue 1264323002: bluetooth: Return specific message if Bluetooth Adapter is off (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-web-bluetooth-action
Patch Set: Add issue to TODO Created 5 years, 4 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 | « no previous file | content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
index 7a3c88842635c59bc8aac51e89fccef24b29b5d4..eff5a668cd974e6058511b2e8bb560725439700c 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -49,6 +49,8 @@ enum class UMARequestDeviceOutcome {
DISCOVERY_START_FAILED = 3,
DISCOVERY_STOP_FAILED = 4,
NO_MATCHING_DEVICES_FOUND = 5,
+ BLUETOOTH_ADAPTER_NOT_PRESENT = 6,
+ BLUETOOTH_ADAPTER_OFF = 7,
// NOTE: Add new requestDevice() outcomes immediately above this line. Make
// sure to update the enum list in
// tools/metrics/histogram/histograms.xml accordingly.
@@ -296,6 +298,30 @@ void BluetoothDispatcherHost::OnRequestDevice(
bad_message::ReceivedBadMessage(
this, bad_message::BDH_DUPLICATE_REQUEST_DEVICE_ID);
}
+ if (!adapter_->IsPresent()) {
+ VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice.";
+ RecordRequestDeviceOutcome(
+ UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT);
+ Send(new BluetoothMsg_RequestDeviceError(
+ thread_id, request_id, WebBluetoothError::NoBluetoothAdapter));
+ request_device_sessions_.erase(std::make_pair(thread_id, request_id));
+ return;
+ }
+ // TODO(jyasskin): Once the dialog is available, the dialog should check for
+ // the status of the adapter, i.e. check IsPowered() and
+ // BluetoothAdapter::Observer::PoweredChanged, and inform the user. But
+ // until the dialog is available we log/histogram the status and return
+ // with a message.
+ // https://crbug.com/517237
+ if (!adapter_->IsPowered()) {
+ VLOG(1) << "Bluetooth Adapter is not powered. Can't serve requestDevice.";
+ RecordRequestDeviceOutcome(
+ UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_OFF);
+ Send(new BluetoothMsg_RequestDeviceError(
+ thread_id, request_id, WebBluetoothError::BluetoothAdapterOff));
+ request_device_sessions_.erase(std::make_pair(thread_id, request_id));
+ return;
+ }
adapter_->StartDiscoverySessionWithFilter(
ComputeScanFilter(filters),
base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted,
« no previous file with comments | « no previous file | content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698