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 69a7376e348ed422f4432dbce4846d2bd427ed7d..74377d61b6c85406af29dbefa84f1edcc20b425c 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" |
@@ -992,6 +993,7 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl( |
int request_id, |
int frame_routing_id, |
const std::vector<BluetoothScanFilter>& filters, |
+ // Use local optional_services_blacklist_filtered in this method. |
ortuno
2016/02/12 16:41:47
Unsure what this comment means or why it's in the
scheib
2016/02/12 18:25:32
See if this new approach is clearer.
|
const std::vector<BluetoothUUID>& optional_services) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::REQUEST_DEVICE); |
@@ -1012,6 +1014,18 @@ 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)) { |
+ Send(new BluetoothMsg_RequestDeviceError( |
ortuno
2016/02/12 16:41:47
You need to record the outcome with RecordRequestD
scheib
2016/02/12 18:25:32
Done.
|
+ thread_id, request_id, |
+ WebBluetoothError::RequestDeviceWithBlacklistedUUID)); |
+ return; |
+ } |
+ std::vector<BluetoothUUID> optional_services_blacklist_filtered( |
+ optional_services); |
+ BluetoothBlacklist::Get().RemoveExcludedUuids( |
ortuno
2016/02/12 16:41:47
Didn't know LazyInstance::Get() returned a referen
scheib
2016/02/12 18:25:32
One benefit of lazyinstance is that it reserves st
|
+ &optional_services_blacklist_filtered); |
+ |
RenderFrameHostImpl* render_frame_host = |
RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); |
@@ -1055,7 +1069,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 = |