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

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

Issue 2449813002: bluetooth: Implement acceptAllDevices (Closed)
Patch Set: Created 4 years, 2 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 95315cdf512aedaaef0d8f4415258688de7d0eda..8197309c817f03f5aec9111e2e863792dc3096f7 100644
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
@@ -52,6 +52,7 @@ constexpr int kTestScanDuration = 0;
void LogRequestDeviceOptions(
const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
VLOG(1) << "requestDevice called with the following filters: ";
+ VLOG(1) << "Accept All Devices: " << options->accept_all_devices;
int i = 0;
for (const auto& filter : options->filters) {
VLOG(1) << "Filter #" << ++i;
@@ -242,8 +243,9 @@ void BluetoothDeviceChooserController::GetDevice(
success_callback_ = success_callback;
error_callback_ = error_callback;
- // The renderer should never send empty filters.
- if (HasEmptyOrInvalidFilter(options->filters)) {
+ // The renderer should never send empty filters if acceptAllDevices is false.
+ if (!options->accept_all_devices &&
ortuno 2016/10/31 00:00:02 You can remove the accept_all_devices check. See c
+ HasEmptyOrInvalidFilter(options->filters)) {
web_bluetooth_service_->CrashRendererAndClosePipe(
bad_message::BDH_EMPTY_OR_INVALID_FILTERS);
return;
@@ -251,14 +253,16 @@ void BluetoothDeviceChooserController::GetDevice(
options_ = std::move(options);
LogRequestDeviceOptions(options_);
- // Check blacklist to reject invalid filters and adjust optional_services.
- if (BluetoothBlacklist::Get().IsExcluded(options_->filters)) {
+ // Check blacklist to reject invalid filters if acceptAllDevices is false.
+ if (!options_->accept_all_devices &&
ortuno 2016/10/31 00:00:02 !options_->filters.is_null()
+ BluetoothBlacklist::Get().IsExcluded(options_->filters)) {
RecordRequestDeviceOutcome(
UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER);
PostErrorCallback(
blink::mojom::WebBluetoothResult::REQUEST_DEVICE_WITH_BLACKLISTED_UUID);
return;
}
+ // Check blacklist to adjust optional_services.
BluetoothBlacklist::Get().RemoveExcludedUUIDs(options_.get());
const url::Origin requesting_origin =
@@ -352,7 +356,8 @@ void BluetoothDeviceChooserController::GetDevice(
void BluetoothDeviceChooserController::AddFilteredDevice(
const device::BluetoothDevice& device) {
- if (chooser_.get() && MatchesFilters(device, options_->filters)) {
+ if (chooser_.get() && (options_->accept_all_devices ||
ortuno 2016/10/31 00:00:02 options_->filters.is_null() || ...
+ MatchesFilters(device, options_->filters))) {
base::Optional<int8_t> rssi = device.GetInquiryRSSI();
chooser_->AddOrUpdateDevice(
device.GetAddress(), !!device.GetName() /* should_update_name */,
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_metrics.h » ('j') | content/renderer/bluetooth/bluetooth_type_converters.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698