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 = |