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 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 new FirstDeviceBluetoothChooser(chooser_event_handler)); | 1279 new FirstDeviceBluetoothChooser(chooser_event_handler)); |
1280 } | 1280 } |
1281 | 1281 |
1282 if (!session->chooser->CanAskForScanningPermission()) { | 1282 if (!session->chooser->CanAskForScanningPermission()) { |
1283 VLOG(1) << "Closing immediately because Chooser cannot obtain permission."; | 1283 VLOG(1) << "Closing immediately because Chooser cannot obtain permission."; |
1284 OnBluetoothChooserEvent(chooser_id, | 1284 OnBluetoothChooserEvent(chooser_id, |
1285 BluetoothChooser::Event::DENIED_PERMISSION, ""); | 1285 BluetoothChooser::Event::DENIED_PERMISSION, ""); |
1286 return; | 1286 return; |
1287 } | 1287 } |
1288 | 1288 |
1289 // Populate the initial list of devices. | 1289 PopulateWithExistingDevices(session, chooser_id); |
1290 VLOG(1) << "Populating " << adapter_->GetDevices().size() | |
1291 << " devices in chooser " << chooser_id; | |
1292 for (const device::BluetoothDevice* device : adapter_->GetDevices()) { | |
1293 VLOG(1) << "\t" << device->GetAddress(); | |
1294 session->AddFilteredDevice(*device); | |
1295 } | |
1296 | 1290 |
1297 if (!session->chooser) { | 1291 if (!session->chooser) { |
1298 // If the dialog's closing, no need to do any of the rest of this. | 1292 // If the dialog's closing, no need to do any of the rest of this. |
1299 return; | 1293 return; |
1300 } | 1294 } |
1301 | 1295 |
1302 if (!adapter_->IsPowered()) { | 1296 if (!adapter_->IsPowered()) { |
1303 session->chooser->SetAdapterPresence( | 1297 session->chooser->SetAdapterPresence( |
1304 BluetoothChooser::AdapterPresence::POWERED_OFF); | 1298 BluetoothChooser::AdapterPresence::POWERED_OFF); |
1305 return; | 1299 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 const std::string& device_id) { | 1340 const std::string& device_id) { |
1347 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1341 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1348 RequestDeviceSession* session = request_device_sessions_.Lookup(chooser_id); | 1342 RequestDeviceSession* session = request_device_sessions_.Lookup(chooser_id); |
1349 DCHECK(session) << "Shouldn't receive an event (" << static_cast<int>(event) | 1343 DCHECK(session) << "Shouldn't receive an event (" << static_cast<int>(event) |
1350 << ") from a closed chooser."; | 1344 << ") from a closed chooser."; |
1351 CHECK(session->chooser) << "Shouldn't receive an event (" | 1345 CHECK(session->chooser) << "Shouldn't receive an event (" |
1352 << static_cast<int>(event) | 1346 << static_cast<int>(event) |
1353 << ") from a closed chooser."; | 1347 << ") from a closed chooser."; |
1354 switch (event) { | 1348 switch (event) { |
1355 case BluetoothChooser::Event::RESCAN: | 1349 case BluetoothChooser::Event::RESCAN: |
1350 PopulateWithExistingDevices(session, chooser_id); | |
1356 StartDeviceDiscovery(session, chooser_id); | 1351 StartDeviceDiscovery(session, chooser_id); |
1357 // No need to close the chooser so we return. | 1352 // No need to close the chooser so we return. |
1358 return; | 1353 return; |
1359 case BluetoothChooser::Event::DENIED_PERMISSION: | 1354 case BluetoothChooser::Event::DENIED_PERMISSION: |
1360 case BluetoothChooser::Event::CANCELLED: | 1355 case BluetoothChooser::Event::CANCELLED: |
1361 case BluetoothChooser::Event::SELECTED: | 1356 case BluetoothChooser::Event::SELECTED: |
1362 break; | 1357 break; |
1363 case BluetoothChooser::Event::SHOW_OVERVIEW_HELP: | 1358 case BluetoothChooser::Event::SHOW_OVERVIEW_HELP: |
1364 VLOG(1) << "Overview Help link pressed."; | 1359 VLOG(1) << "Overview Help link pressed."; |
1365 break; | 1360 break; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1700 } | 1695 } |
1701 | 1696 |
1702 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( | 1697 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( |
1703 int frame_routing_id, | 1698 int frame_routing_id, |
1704 const std::string& characteristic_instance_id) { | 1699 const std::string& characteristic_instance_id) { |
1705 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), | 1700 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), |
1706 characteristic_instance_id) | 1701 characteristic_instance_id) |
1707 .outcome != CacheQueryOutcome::BAD_RENDERER; | 1702 .outcome != CacheQueryOutcome::BAD_RENDERER; |
1708 } | 1703 } |
1709 | 1704 |
1705 void BluetoothDispatcherHost::PopulateWithExistingDevices( | |
1706 RequestDeviceSession* session, | |
1707 int chooser_id) { | |
1708 #if defined(OS_ANDROID) | |
scheib
2016/04/07 22:05:02
I'm concerned about this being platform specific.
| |
1709 adapter_->RemoveTimedOutDevices(); | |
1710 #endif // defined(OS_ANDROID) | |
1711 | |
1712 // Populate the initial list of devices. | |
1713 VLOG(1) << "Populating " << adapter_->GetDevices().size() | |
1714 << " devices in chooser " << chooser_id; | |
1715 for (const device::BluetoothDevice* device : adapter_->GetDevices()) { | |
1716 VLOG(1) << "\t" << device->GetAddress(); | |
1717 session->AddFilteredDevice(*device); | |
1718 } | |
1719 } | |
1720 | |
1710 } // namespace content | 1721 } // namespace content |
OLD | NEW |