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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ID Not In Map Note: 5 // ID Not In Map Note:
6 // A service, characteristic, or descriptor ID not in the corresponding 6 // A service, characteristic, or descriptor ID not in the corresponding
7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_,
8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer
9 // obtains the corresponding ID from this class and it will be added to the map 9 // obtains the corresponding ID from this class and it will be added to the map
10 // at that time. 10 // at that time.
11 11
12 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" 12 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h"
13 13
14 #include <stddef.h> 14 #include <stddef.h>
15 15
16 #include <utility> 16 #include <utility>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
22 #include "content/browser/bad_message.h" 22 #include "content/browser/bad_message.h"
23 #include "content/browser/bluetooth/bluetooth_blacklist.h"
23 #include "content/browser/bluetooth/bluetooth_metrics.h" 24 #include "content/browser/bluetooth/bluetooth_metrics.h"
24 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h" 25 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
25 #include "content/browser/frame_host/render_frame_host_impl.h" 26 #include "content/browser/frame_host/render_frame_host_impl.h"
26 #include "content/common/bluetooth/bluetooth_messages.h" 27 #include "content/common/bluetooth/bluetooth_messages.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_delegate.h" 29 #include "content/public/browser/web_contents_delegate.h"
29 #include "device/bluetooth/bluetooth_adapter.h" 30 #include "device/bluetooth/bluetooth_adapter.h"
30 #include "device/bluetooth/bluetooth_adapter_factory.h" 31 #include "device/bluetooth/bluetooth_adapter_factory.h"
31 #include "device/bluetooth/bluetooth_device.h" 32 #include "device/bluetooth/bluetooth_device.h"
32 #include "device/bluetooth/bluetooth_discovery_session.h" 33 #include "device/bluetooth/bluetooth_discovery_session.h"
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 VLOG(1) << "\t["; 1001 VLOG(1) << "\t[";
1001 for (const BluetoothUUID& service : filter.services) 1002 for (const BluetoothUUID& service : filter.services)
1002 VLOG(1) << "\t\t" << service.value(); 1003 VLOG(1) << "\t\t" << service.value();
1003 VLOG(1) << "\t]"; 1004 VLOG(1) << "\t]";
1004 } 1005 }
1005 1006
1006 VLOG(1) << "requestDevice called with the following optional services: "; 1007 VLOG(1) << "requestDevice called with the following optional services: ";
1007 for (const BluetoothUUID& service : optional_services) 1008 for (const BluetoothUUID& service : optional_services)
1008 VLOG(1) << "\t" << service.value(); 1009 VLOG(1) << "\t" << service.value();
1009 1010
1011 // Check blacklist to reject invalid filters and adjust optional_services.
1012 if (BluetoothBlacklist::Get().IsExcluded(filters)) {
1013 RecordRequestDeviceOutcome(
1014 UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER);
1015 Send(new BluetoothMsg_RequestDeviceError(
1016 thread_id, request_id,
1017 WebBluetoothError::RequestDeviceWithBlacklistedUUID));
1018 return;
1019 }
1020 std::vector<BluetoothUUID> optional_services_blacklist_filtered(
1021 optional_services);
1022 BluetoothBlacklist::Get().RemoveExcludedUuids(
1023 &optional_services_blacklist_filtered);
1024
1010 RenderFrameHostImpl* render_frame_host = 1025 RenderFrameHostImpl* render_frame_host =
1011 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); 1026 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
1012 1027
1013 if (!render_frame_host) { 1028 if (!render_frame_host) {
1014 DLOG(WARNING) 1029 DLOG(WARNING)
1015 << "Got a requestDevice IPC without a matching RenderFrameHost: " 1030 << "Got a requestDevice IPC without a matching RenderFrameHost: "
1016 << render_process_id_ << ", " << frame_routing_id; 1031 << render_process_id_ << ", " << frame_routing_id;
1017 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME); 1032 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME);
1018 Send(new BluetoothMsg_RequestDeviceError( 1033 Send(new BluetoothMsg_RequestDeviceError(
1019 thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame)); 1034 thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame));
(...skipping 23 matching lines...) Expand all
1043 if (HasEmptyOrInvalidFilter(filters)) { 1058 if (HasEmptyOrInvalidFilter(filters)) {
1044 bad_message::ReceivedBadMessage(this, 1059 bad_message::ReceivedBadMessage(this,
1045 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); 1060 bad_message::BDH_EMPTY_OR_INVALID_FILTERS);
1046 return; 1061 return;
1047 } 1062 }
1048 1063
1049 // Create storage for the information that backs the chooser, and show the 1064 // Create storage for the information that backs the chooser, and show the
1050 // chooser. 1065 // chooser.
1051 RequestDeviceSession* const session = new RequestDeviceSession( 1066 RequestDeviceSession* const session = new RequestDeviceSession(
1052 thread_id, request_id, render_frame_host->GetLastCommittedOrigin(), 1067 thread_id, request_id, render_frame_host->GetLastCommittedOrigin(),
1053 filters, optional_services); 1068 filters, optional_services_blacklist_filtered);
1054 int chooser_id = request_device_sessions_.Add(session); 1069 int chooser_id = request_device_sessions_.Add(session);
1055 1070
1056 BluetoothChooser::EventHandler chooser_event_handler = 1071 BluetoothChooser::EventHandler chooser_event_handler =
1057 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent, 1072 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent,
1058 weak_ptr_on_ui_thread_, chooser_id); 1073 weak_ptr_on_ui_thread_, chooser_id);
1059 if (WebContents* web_contents = 1074 if (WebContents* web_contents =
1060 WebContents::FromRenderFrameHost(render_frame_host)) { 1075 WebContents::FromRenderFrameHost(render_frame_host)) {
1061 if (WebContentsDelegate* delegate = web_contents->GetDelegate()) { 1076 if (WebContentsDelegate* delegate = web_contents->GetDelegate()) {
1062 session->chooser = delegate->RunBluetoothChooser( 1077 session->chooser = delegate->RunBluetoothChooser(
1063 web_contents, chooser_event_handler, 1078 web_contents, chooser_event_handler,
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1515 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1501 NOTIMPLEMENTED(); 1516 NOTIMPLEMENTED();
1502 } 1517 }
1503 1518
1504 void BluetoothDispatcherHost::ShowNeedLocationLink() { 1519 void BluetoothDispatcherHost::ShowNeedLocationLink() {
1505 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1520 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1506 NOTIMPLEMENTED(); 1521 NOTIMPLEMENTED();
1507 } 1522 }
1508 1523
1509 } // namespace content 1524 } // namespace content
OLDNEW
« 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