| OLD | NEW |
| 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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 VLOG(1) << "\t["; | 1006 VLOG(1) << "\t["; |
| 1006 for (const BluetoothUUID& service : filter.services) | 1007 for (const BluetoothUUID& service : filter.services) |
| 1007 VLOG(1) << "\t\t" << service.value(); | 1008 VLOG(1) << "\t\t" << service.value(); |
| 1008 VLOG(1) << "\t]"; | 1009 VLOG(1) << "\t]"; |
| 1009 } | 1010 } |
| 1010 | 1011 |
| 1011 VLOG(1) << "requestDevice called with the following optional services: "; | 1012 VLOG(1) << "requestDevice called with the following optional services: "; |
| 1012 for (const BluetoothUUID& service : optional_services) | 1013 for (const BluetoothUUID& service : optional_services) |
| 1013 VLOG(1) << "\t" << service.value(); | 1014 VLOG(1) << "\t" << service.value(); |
| 1014 | 1015 |
| 1016 // Check blacklist to reject invalid filters and adjust optional_services. |
| 1017 if (BluetoothBlacklist::Get().IsExcluded(filters)) { |
| 1018 RecordRequestDeviceOutcome( |
| 1019 UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER); |
| 1020 Send(new BluetoothMsg_RequestDeviceError( |
| 1021 thread_id, request_id, |
| 1022 WebBluetoothError::RequestDeviceWithBlacklistedUUID)); |
| 1023 return; |
| 1024 } |
| 1025 std::vector<BluetoothUUID> optional_services_blacklist_filtered( |
| 1026 optional_services); |
| 1027 BluetoothBlacklist::Get().RemoveExcludedUuids( |
| 1028 &optional_services_blacklist_filtered); |
| 1029 |
| 1015 RenderFrameHostImpl* render_frame_host = | 1030 RenderFrameHostImpl* render_frame_host = |
| 1016 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); | 1031 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); |
| 1017 | 1032 |
| 1018 if (!render_frame_host) { | 1033 if (!render_frame_host) { |
| 1019 DLOG(WARNING) | 1034 DLOG(WARNING) |
| 1020 << "Got a requestDevice IPC without a matching RenderFrameHost: " | 1035 << "Got a requestDevice IPC without a matching RenderFrameHost: " |
| 1021 << render_process_id_ << ", " << frame_routing_id; | 1036 << render_process_id_ << ", " << frame_routing_id; |
| 1022 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME); | 1037 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME); |
| 1023 Send(new BluetoothMsg_RequestDeviceError( | 1038 Send(new BluetoothMsg_RequestDeviceError( |
| 1024 thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame)); | 1039 thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1048 if (HasEmptyOrInvalidFilter(filters)) { | 1063 if (HasEmptyOrInvalidFilter(filters)) { |
| 1049 bad_message::ReceivedBadMessage(this, | 1064 bad_message::ReceivedBadMessage(this, |
| 1050 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); | 1065 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); |
| 1051 return; | 1066 return; |
| 1052 } | 1067 } |
| 1053 | 1068 |
| 1054 // Create storage for the information that backs the chooser, and show the | 1069 // Create storage for the information that backs the chooser, and show the |
| 1055 // chooser. | 1070 // chooser. |
| 1056 RequestDeviceSession* const session = new RequestDeviceSession( | 1071 RequestDeviceSession* const session = new RequestDeviceSession( |
| 1057 thread_id, request_id, render_frame_host->GetLastCommittedOrigin(), | 1072 thread_id, request_id, render_frame_host->GetLastCommittedOrigin(), |
| 1058 filters, optional_services); | 1073 filters, optional_services_blacklist_filtered); |
| 1059 int chooser_id = request_device_sessions_.Add(session); | 1074 int chooser_id = request_device_sessions_.Add(session); |
| 1060 | 1075 |
| 1061 BluetoothChooser::EventHandler chooser_event_handler = | 1076 BluetoothChooser::EventHandler chooser_event_handler = |
| 1062 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent, | 1077 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent, |
| 1063 weak_ptr_on_ui_thread_, chooser_id); | 1078 weak_ptr_on_ui_thread_, chooser_id); |
| 1064 if (WebContents* web_contents = | 1079 if (WebContents* web_contents = |
| 1065 WebContents::FromRenderFrameHost(render_frame_host)) { | 1080 WebContents::FromRenderFrameHost(render_frame_host)) { |
| 1066 if (WebContentsDelegate* delegate = web_contents->GetDelegate()) { | 1081 if (WebContentsDelegate* delegate = web_contents->GetDelegate()) { |
| 1067 session->chooser = delegate->RunBluetoothChooser( | 1082 session->chooser = delegate->RunBluetoothChooser( |
| 1068 web_contents, chooser_event_handler, | 1083 web_contents, chooser_event_handler, |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1520 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1506 NOTIMPLEMENTED(); | 1521 NOTIMPLEMENTED(); |
| 1507 } | 1522 } |
| 1508 | 1523 |
| 1509 void BluetoothDispatcherHost::ShowNeedLocationLink() { | 1524 void BluetoothDispatcherHost::ShowNeedLocationLink() { |
| 1510 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1525 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1511 NOTIMPLEMENTED(); | 1526 NOTIMPLEMENTED(); |
| 1512 } | 1527 } |
| 1513 | 1528 |
| 1514 } // namespace content | 1529 } // namespace content |
| OLD | NEW |