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

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

Issue 1666003002: bluetooth: Add Web Bluetooth blacklist checks to requestDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-blacklist-
Patch Set: fix test expectation with updated error string Created 4 years, 10 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_dispatcher_host.cc
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
index c5fca31a414aae21892c9eef0e8e7dec6b581765..481cdbab06183743dd655ab28613b73df8cfad95 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -20,6 +20,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/bad_message.h"
+#include "content/browser/bluetooth/bluetooth_blacklist.h"
#include "content/browser/bluetooth/bluetooth_metrics.h"
#include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
@@ -1007,6 +1008,20 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl(
for (const BluetoothUUID& service : optional_services)
VLOG(1) << "\t" << service.value();
+ // Check blacklist to reject invalid filters and adjust optional_services.
+ if (BluetoothBlacklist::Get().IsExcluded(filters)) {
+ RecordRequestDeviceOutcome(
+ UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER);
+ Send(new BluetoothMsg_RequestDeviceError(
+ thread_id, request_id,
+ WebBluetoothError::RequestDeviceWithBlacklistedUUID));
+ return;
+ }
+ std::vector<BluetoothUUID> optional_services_blacklist_filtered(
+ optional_services);
+ BluetoothBlacklist::Get().RemoveExcludedUuids(
+ &optional_services_blacklist_filtered);
+
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
@@ -1050,7 +1065,7 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl(
// chooser.
RequestDeviceSession* const session = new RequestDeviceSession(
thread_id, request_id, render_frame_host->GetLastCommittedOrigin(),
- filters, optional_services);
+ filters, optional_services_blacklist_filtered);
int chooser_id = request_device_sessions_.Add(session);
BluetoothChooser::EventHandler chooser_event_handler =
« no previous file with comments | « content/browser/bluetooth/bluetooth_allowed_devices_map.cc ('k') | content/browser/bluetooth/bluetooth_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698