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

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

Issue 1842223003: Remove outdated devices from Android device chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on master Created 4 years, 7 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.
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 new FirstDeviceBluetoothChooser(chooser_event_handler)); 750 new FirstDeviceBluetoothChooser(chooser_event_handler));
751 } 751 }
752 752
753 if (!session->chooser->CanAskForScanningPermission()) { 753 if (!session->chooser->CanAskForScanningPermission()) {
754 VLOG(1) << "Closing immediately because Chooser cannot obtain permission."; 754 VLOG(1) << "Closing immediately because Chooser cannot obtain permission.";
755 OnBluetoothChooserEvent(chooser_id, 755 OnBluetoothChooserEvent(chooser_id,
756 BluetoothChooser::Event::DENIED_PERMISSION, ""); 756 BluetoothChooser::Event::DENIED_PERMISSION, "");
757 return; 757 return;
758 } 758 }
759 759
760 // Populate the initial list of devices. 760 PopulateWithExistingDevices(session, chooser_id);
761 VLOG(1) << "Populating " << adapter_->GetDevices().size()
762 << " devices in chooser " << chooser_id;
763 for (const device::BluetoothDevice* device : adapter_->GetDevices()) {
764 VLOG(1) << "\t" << device->GetAddress();
765 session->AddFilteredDevice(*device);
766 }
767 761
768 if (!session->chooser) { 762 if (!session->chooser) {
769 // If the dialog's closing, no need to do any of the rest of this. 763 // If the dialog's closing, no need to do any of the rest of this.
770 return; 764 return;
771 } 765 }
772 766
773 if (!adapter_->IsPowered()) { 767 if (!adapter_->IsPowered()) {
774 session->chooser->SetAdapterPresence( 768 session->chooser->SetAdapterPresence(
775 BluetoothChooser::AdapterPresence::POWERED_OFF); 769 BluetoothChooser::AdapterPresence::POWERED_OFF);
776 return; 770 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 const std::string& device_id) { 811 const std::string& device_id) {
818 DCHECK_CURRENTLY_ON(BrowserThread::UI); 812 DCHECK_CURRENTLY_ON(BrowserThread::UI);
819 RequestDeviceSession* session = request_device_sessions_.Lookup(chooser_id); 813 RequestDeviceSession* session = request_device_sessions_.Lookup(chooser_id);
820 DCHECK(session) << "Shouldn't receive an event (" << static_cast<int>(event) 814 DCHECK(session) << "Shouldn't receive an event (" << static_cast<int>(event)
821 << ") from a closed chooser."; 815 << ") from a closed chooser.";
822 CHECK(session->chooser) << "Shouldn't receive an event (" 816 CHECK(session->chooser) << "Shouldn't receive an event ("
823 << static_cast<int>(event) 817 << static_cast<int>(event)
824 << ") from a closed chooser."; 818 << ") from a closed chooser.";
825 switch (event) { 819 switch (event) {
826 case BluetoothChooser::Event::RESCAN: 820 case BluetoothChooser::Event::RESCAN:
821 PopulateWithExistingDevices(session, chooser_id);
827 StartDeviceDiscovery(session, chooser_id); 822 StartDeviceDiscovery(session, chooser_id);
828 // No need to close the chooser so we return. 823 // No need to close the chooser so we return.
829 return; 824 return;
830 case BluetoothChooser::Event::DENIED_PERMISSION: 825 case BluetoothChooser::Event::DENIED_PERMISSION:
831 case BluetoothChooser::Event::CANCELLED: 826 case BluetoothChooser::Event::CANCELLED:
832 case BluetoothChooser::Event::SELECTED: 827 case BluetoothChooser::Event::SELECTED:
833 break; 828 break;
834 case BluetoothChooser::Event::SHOW_OVERVIEW_HELP: 829 case BluetoothChooser::Event::SHOW_OVERVIEW_HELP:
835 VLOG(1) << "Overview Help link pressed."; 830 VLOG(1) << "Overview Help link pressed.";
836 break; 831 break;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 if (adapter_) { 1001 if (adapter_) {
1007 adapter_->RemoveObserver(observer); 1002 adapter_->RemoveObserver(observer);
1008 } 1003 }
1009 } 1004 }
1010 1005
1011 url::Origin BluetoothDispatcherHost::GetOrigin(int frame_routing_id) { 1006 url::Origin BluetoothDispatcherHost::GetOrigin(int frame_routing_id) {
1012 return RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id) 1007 return RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id)
1013 ->GetLastCommittedOrigin(); 1008 ->GetLastCommittedOrigin();
1014 } 1009 }
1015 1010
1011 void BluetoothDispatcherHost::PopulateWithExistingDevices(
1012 RequestDeviceSession* session,
1013 int chooser_id) {
1014 // Populate the initial list of devices.
scheib 2016/05/06 00:41:50 This comment not needed now that the code block is
1015 VLOG(1) << "Populating " << adapter_->GetDevices().size()
1016 << " devices in chooser " << chooser_id;
1017 for (const device::BluetoothDevice* device : adapter_->GetDevices()) {
1018 VLOG(1) << "\t" << device->GetAddress();
1019 session->AddFilteredDevice(*device);
1020 }
1021 }
1022
1016 } // namespace content 1023 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698