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

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1848663002: bluetooth: Remove indicator only when there are no more devices connected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 // in case a hostile renderer is trying to disconnect a device that the 717 // in case a hostile renderer is trying to disconnect a device that the
718 // renderer is not allowed to access. 718 // renderer is not allowed to access.
719 if (allowed_devices_map_.GetDeviceAddress(GetOrigin(frame_routing_id), 719 if (allowed_devices_map_.GetDeviceAddress(GetOrigin(frame_routing_id),
720 device_id) 720 device_id)
721 .empty()) { 721 .empty()) {
722 bad_message::ReceivedBadMessage( 722 bad_message::ReceivedBadMessage(
723 this, bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); 723 this, bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN);
724 return; 724 return;
725 } 725 }
726 726
727 RenderFrameHostImpl* render_frame_host =
728 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
729 WebContents* web_contents =
730 WebContents::FromRenderFrameHost(render_frame_host);
731 if (web_contents) {
732 web_contents->SetBluetoothDeviceConnected(false);
733 }
734
735 // The last BluetoothGattConnection for a device closes the connection when 727 // The last BluetoothGattConnection for a device closes the connection when
736 // it's destroyed. 728 // it's destroyed.
737 if (device_id_to_connection_map_.erase(device_id)) { 729 if (device_id_to_connection_map_.erase(device_id)) {
738 VLOG(1) << "Disconnecting device: " << device_id; 730 VLOG(1) << "Disconnecting device: " << device_id;
731
732 if (!device_id_to_connection_map_.empty()) {
Jeffrey Yasskin 2016/03/31 16:18:43 Currently, this is going to keep the indicator sho
ortuno 2016/03/31 17:53:25 OK. What do you think of the new approach?
733 // Another device is still connected.
734 return;
Jeffrey Yasskin 2016/03/31 16:18:43 For this sort of thing, I'd avoid returning early,
735 }
736
737 // Indicate no more BT devices are connected.
738 RenderFrameHostImpl* render_frame_host =
739 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
740 WebContents* web_contents =
741 WebContents::FromRenderFrameHost(render_frame_host);
742 if (web_contents) {
743 web_contents->SetBluetoothDeviceConnected(false);
744 }
739 } 745 }
740 } 746 }
741 747
742 void BluetoothDispatcherHost::OnGetPrimaryService( 748 void BluetoothDispatcherHost::OnGetPrimaryService(
743 int thread_id, 749 int thread_id,
744 int request_id, 750 int request_id,
745 int frame_routing_id, 751 int frame_routing_id,
746 const std::string& device_id, 752 const std::string& device_id,
747 const std::string& service_uuid) { 753 const std::string& service_uuid) {
748 DCHECK_CURRENTLY_ON(BrowserThread::UI); 754 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 1686
1681 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1687 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1682 int frame_routing_id, 1688 int frame_routing_id,
1683 const std::string& characteristic_instance_id) { 1689 const std::string& characteristic_instance_id) {
1684 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1690 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1685 characteristic_instance_id) 1691 characteristic_instance_id)
1686 .outcome != CacheQueryOutcome::BAD_RENDERER; 1692 .outcome != CacheQueryOutcome::BAD_RENDERER;
1687 } 1693 }
1688 1694
1689 } // namespace content 1695 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698