| 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. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 } | 694 } |
| 695 | 695 |
| 696 void BluetoothDispatcherHost::OnGATTServerDisconnect( | 696 void BluetoothDispatcherHost::OnGATTServerDisconnect( |
| 697 int thread_id, | 697 int thread_id, |
| 698 int frame_routing_id, | 698 int frame_routing_id, |
| 699 const std::string& device_id) { | 699 const std::string& device_id) { |
| 700 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 700 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 701 RecordWebBluetoothFunctionCall( | 701 RecordWebBluetoothFunctionCall( |
| 702 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); | 702 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); |
| 703 | 703 |
| 704 // Make sure the origin is allowed to access the device. We perform this check | 704 // Frames can send a disconnect request after they've started navigating, |
| 705 // in case a hostile renderer is trying to disconnect a device that the | 705 // making calls to GetLastCommitted origin invalid. Because we still need |
| 706 // renderer is not allowed to access. | 706 // to disconnect the device, otherwise we would leave users with no other |
| 707 if (allowed_devices_map_.GetDeviceAddress(GetOrigin(frame_routing_id), | 707 // option to disconnect than closing the tab, we purposefully don't |
| 708 device_id) | 708 // check if the frame has permission to interact with the device. |
| 709 .empty()) { | |
| 710 bad_message::ReceivedBadMessage( | |
| 711 this, bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); | |
| 712 return; | |
| 713 } | |
| 714 | 709 |
| 715 RenderFrameHostImpl* render_frame_host = | 710 RenderFrameHostImpl* render_frame_host = |
| 716 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); | 711 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); |
| 717 WebContents* web_contents = | 712 WebContents* web_contents = |
| 718 WebContents::FromRenderFrameHost(render_frame_host); | 713 WebContents::FromRenderFrameHost(render_frame_host); |
| 719 if (web_contents) { | 714 if (web_contents) { |
| 720 web_contents->SetBluetoothDeviceConnected(false); | 715 web_contents->SetBluetoothDeviceConnected(false); |
| 721 } | 716 } |
| 722 | 717 |
| 723 // The last BluetoothGattConnection for a device closes the connection when | 718 // The last BluetoothGattConnection for a device closes the connection when |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 | 1616 |
| 1622 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( | 1617 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( |
| 1623 int frame_routing_id, | 1618 int frame_routing_id, |
| 1624 const std::string& characteristic_instance_id) { | 1619 const std::string& characteristic_instance_id) { |
| 1625 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), | 1620 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), |
| 1626 characteristic_instance_id) | 1621 characteristic_instance_id) |
| 1627 .outcome != CacheQueryOutcome::BAD_RENDERER; | 1622 .outcome != CacheQueryOutcome::BAD_RENDERER; |
| 1628 } | 1623 } |
| 1629 | 1624 |
| 1630 } // namespace content | 1625 } // namespace content |
| OLD | NEW |