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