| 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 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event
_router.h" | 5 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event
_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 out->device_address.reset( | 48 out->device_address.reset( |
| 49 new std::string(service->GetDevice()->GetAddress())); | 49 new std::string(service->GetDevice()->GetAddress())); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void PopulateCharacteristicProperties( | 52 void PopulateCharacteristicProperties( |
| 53 BluetoothGattCharacteristic::Properties properties, | 53 BluetoothGattCharacteristic::Properties properties, |
| 54 std::vector<apibtle::CharacteristicProperty>* api_properties) { | 54 std::vector<apibtle::CharacteristicProperty>* api_properties) { |
| 55 DCHECK(api_properties && api_properties->empty()); | 55 DCHECK(api_properties && api_properties->empty()); |
| 56 | 56 |
| 57 if (properties == BluetoothGattCharacteristic::kPropertyNone) | 57 if (properties == BluetoothGattCharacteristic::PROPERTY_NONE) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 if (properties & BluetoothGattCharacteristic::kPropertyBroadcast) | 60 if (properties & BluetoothGattCharacteristic::PROPERTY_BROADCAST) |
| 61 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_BROADCAST); | 61 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_BROADCAST); |
| 62 if (properties & BluetoothGattCharacteristic::kPropertyRead) | 62 if (properties & BluetoothGattCharacteristic::PROPERTY_READ) |
| 63 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_READ); | 63 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_READ); |
| 64 if (properties & BluetoothGattCharacteristic::kPropertyWriteWithoutResponse) { | 64 if (properties & |
| 65 BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE) { |
| 65 api_properties->push_back( | 66 api_properties->push_back( |
| 66 apibtle::CHARACTERISTIC_PROPERTY_WRITEWITHOUTRESPONSE); | 67 apibtle::CHARACTERISTIC_PROPERTY_WRITEWITHOUTRESPONSE); |
| 67 } | 68 } |
| 68 if (properties & BluetoothGattCharacteristic::kPropertyWrite) | 69 if (properties & BluetoothGattCharacteristic::PROPERTY_WRITE) |
| 69 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_WRITE); | 70 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_WRITE); |
| 70 if (properties & BluetoothGattCharacteristic::kPropertyNotify) | 71 if (properties & BluetoothGattCharacteristic::PROPERTY_NOTIFY) |
| 71 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_NOTIFY); | 72 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_NOTIFY); |
| 72 if (properties & BluetoothGattCharacteristic::kPropertyIndicate) | 73 if (properties & BluetoothGattCharacteristic::PROPERTY_INDICATE) |
| 73 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_INDICATE); | 74 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_INDICATE); |
| 74 if (properties & | 75 if (properties & |
| 75 BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites) { | 76 BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES) { |
| 76 api_properties->push_back( | 77 api_properties->push_back( |
| 77 apibtle::CHARACTERISTIC_PROPERTY_AUTHENTICATEDSIGNEDWRITES); | 78 apibtle::CHARACTERISTIC_PROPERTY_AUTHENTICATEDSIGNEDWRITES); |
| 78 } | 79 } |
| 79 if (properties & BluetoothGattCharacteristic::kPropertyExtendedProperties) { | 80 if (properties & BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES) { |
| 80 api_properties->push_back( | 81 api_properties->push_back( |
| 81 apibtle::CHARACTERISTIC_PROPERTY_EXTENDEDPROPERTIES); | 82 apibtle::CHARACTERISTIC_PROPERTY_EXTENDEDPROPERTIES); |
| 82 } | 83 } |
| 83 if (properties & BluetoothGattCharacteristic::kPropertyReliableWrite) | 84 if (properties & BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE) |
| 84 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_RELIABLEWRITE); | 85 api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_RELIABLEWRITE); |
| 85 if (properties & BluetoothGattCharacteristic::kPropertyWritableAuxiliaries) { | 86 if (properties & BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES) { |
| 86 api_properties->push_back( | 87 api_properties->push_back( |
| 87 apibtle::CHARACTERISTIC_PROPERTY_WRITABLEAUXILIARIES); | 88 apibtle::CHARACTERISTIC_PROPERTY_WRITABLEAUXILIARIES); |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 | 91 |
| 91 void PopulateCharacteristic(const BluetoothGattCharacteristic* characteristic, | 92 void PopulateCharacteristic(const BluetoothGattCharacteristic* characteristic, |
| 92 apibtle::Characteristic* out) { | 93 apibtle::Characteristic* out) { |
| 93 DCHECK(out); | 94 DCHECK(out); |
| 94 | 95 |
| 95 out->uuid = characteristic->GetUUID().canonical_value(); | 96 out->uuid = characteristic->GetUUID().canonical_value(); |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 continue; | 1447 continue; |
| 1447 | 1448 |
| 1448 manager->Remove(extension_id, *iter); | 1449 manager->Remove(extension_id, *iter); |
| 1449 return true; | 1450 return true; |
| 1450 } | 1451 } |
| 1451 | 1452 |
| 1452 return false; | 1453 return false; |
| 1453 } | 1454 } |
| 1454 | 1455 |
| 1455 } // namespace extensions | 1456 } // namespace extensions |
| OLD | NEW |