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

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: optional_services name and check from IsOriginAllowedToAccessService 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 69a7376e348ed422f4432dbce4846d2bd427ed7d..a37390f71bdb3b0fd9aeb7158a6b07b8fa119047 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"
@@ -1012,6 +1013,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);
@@ -1055,7 +1070,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 =

Powered by Google App Engine
This is Rietveld 408576698