Chromium Code Reviews| 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..5c2c1f60fb7fd26240cf4d45319e9cc034a23a97 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,10 +993,12 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl( |
| int request_id, |
| int frame_routing_id, |
| const std::vector<BluetoothScanFilter>& filters, |
| - const std::vector<BluetoothUUID>& optional_services) { |
| + const std::vector<BluetoothUUID>& |
| + optional_services_before_being_filtered_by_blacklist) { |
|
ortuno
2016/02/12 18:34:59
I'm not sure how to handle the naming here. Should
scheib
2016/02/12 21:00:52
After in person discussion decided to keep name 'o
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::REQUEST_DEVICE); |
| - RecordRequestDeviceArguments(filters, optional_services); |
| + RecordRequestDeviceArguments( |
| + filters, optional_services_before_being_filtered_by_blacklist); |
| VLOG(1) << "requestDevice called with the following filters: "; |
| for (const BluetoothScanFilter& filter : filters) { |
| @@ -1009,9 +1012,24 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl( |
| } |
| VLOG(1) << "requestDevice called with the following optional services: "; |
| - for (const BluetoothUUID& service : optional_services) |
| + for (const BluetoothUUID& service : |
| + optional_services_before_being_filtered_by_blacklist) |
| 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_before_being_filtered_by_blacklist); |
| + BluetoothBlacklist::Get().RemoveExcludedUuids( |
| + &optional_services_blacklist_filtered); |
| + |
| RenderFrameHostImpl* render_frame_host = |
| RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); |
| @@ -1055,7 +1073,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 = |