| 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 "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_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 "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_connection.h" | |
| 11 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_notify_session.h" | |
| 12 #include "chrome/browser/extensions/api/bluetooth_low_energy/utils.h" | |
| 13 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" | |
| 14 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 15 #include "device/bluetooth/bluetooth_adapter_factory.h" | 11 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 16 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 12 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 17 #include "device/bluetooth/bluetooth_gatt_connection.h" | 13 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 18 #include "device/bluetooth/bluetooth_gatt_descriptor.h" | 14 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 15 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_conne
ction.h" |
| 16 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_notif
y_session.h" |
| 17 #include "extensions/browser/api/bluetooth_low_energy/utils.h" |
| 19 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
| 20 #include "extensions/common/api/bluetooth/bluetooth_manifest_data.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 using device::BluetoothAdapter; | 24 using device::BluetoothAdapter; |
| 25 using device::BluetoothAdapterFactory; | 25 using device::BluetoothAdapterFactory; |
| 26 using device::BluetoothDevice; | 26 using device::BluetoothDevice; |
| 27 using device::BluetoothGattCharacteristic; | 27 using device::BluetoothGattCharacteristic; |
| 28 using device::BluetoothGattConnection; | 28 using device::BluetoothGattConnection; |
| 29 using device::BluetoothGattDescriptor; | 29 using device::BluetoothGattDescriptor; |
| 30 using device::BluetoothGattService; | 30 using device::BluetoothGattService; |
| 31 | 31 |
| 32 namespace apibtle = extensions::api::bluetooth_low_energy; | 32 namespace apibtle = extensions::core_api::bluetooth_low_energy; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 void PopulateService(const BluetoothGattService* service, | 36 void PopulateService(const BluetoothGattService* service, |
| 37 apibtle::Service* out) { | 37 apibtle::Service* out) { |
| 38 DCHECK(out); | 38 DCHECK(out); |
| 39 | 39 |
| 40 out->uuid = service->GetUUID().canonical_value(); | 40 out->uuid = service->GetUUID().canonical_value(); |
| 41 out->is_primary = service->IsPrimary(); | 41 out->is_primary = service->IsPrimary(); |
| 42 out->is_local = service->IsLocal(); | 42 out->is_local = service->IsLocal(); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 out_descriptors->push_back(api_descriptor); | 510 out_descriptors->push_back(api_descriptor); |
| 511 } | 511 } |
| 512 | 512 |
| 513 return kStatusSuccess; | 513 return kStatusSuccess; |
| 514 } | 514 } |
| 515 | 515 |
| 516 BluetoothLowEnergyEventRouter::Status | 516 BluetoothLowEnergyEventRouter::Status |
| 517 BluetoothLowEnergyEventRouter::GetDescriptor( | 517 BluetoothLowEnergyEventRouter::GetDescriptor( |
| 518 const Extension* extension, | 518 const Extension* extension, |
| 519 const std::string& instance_id, | 519 const std::string& instance_id, |
| 520 api::bluetooth_low_energy::Descriptor* out_descriptor) const { | 520 core_api::bluetooth_low_energy::Descriptor* out_descriptor) const { |
| 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 522 DCHECK(extension); | 522 DCHECK(extension); |
| 523 DCHECK(out_descriptor); | 523 DCHECK(out_descriptor); |
| 524 if (!adapter_.get()) { | 524 if (!adapter_.get()) { |
| 525 VLOG(1) << "BluetoothAdapter not ready."; | 525 VLOG(1) << "BluetoothAdapter not ready."; |
| 526 return kStatusErrorFailed; | 526 return kStatusErrorFailed; |
| 527 } | 527 } |
| 528 | 528 |
| 529 BluetoothGattDescriptor* descriptor = FindDescriptorById(instance_id); | 529 BluetoothGattDescriptor* descriptor = FindDescriptorById(instance_id); |
| 530 if (!descriptor) { | 530 if (!descriptor) { |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 continue; | 1441 continue; |
| 1442 | 1442 |
| 1443 manager->Remove(extension_id, *iter); | 1443 manager->Remove(extension_id, *iter); |
| 1444 return true; | 1444 return true; |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 return false; | 1447 return false; |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 } // namespace extensions | 1450 } // namespace extensions |
| OLD | NEW |