OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bluetooth_api_utils.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_api_utils.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "device/bluetooth/bluetooth_adapter.h" | 9 #include "device/bluetooth/bluetooth_adapter.h" |
10 #include "device/bluetooth/bluetooth_device.h" | 10 #include "device/bluetooth/bluetooth_device.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 out->connecting.reset(new bool(device.IsConnecting())); | 114 out->connecting.reset(new bool(device.IsConnecting())); |
115 out->connectable.reset(new bool(device.IsConnectable())); | 115 out->connectable.reset(new bool(device.IsConnectable())); |
116 | 116 |
117 std::vector<std::string>* string_uuids = new std::vector<std::string>(); | 117 std::vector<std::string>* string_uuids = new std::vector<std::string>(); |
118 const device::BluetoothDevice::UUIDList& uuids = device.GetUUIDs(); | 118 const device::BluetoothDevice::UUIDList& uuids = device.GetUUIDs(); |
119 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin(); | 119 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin(); |
120 iter != uuids.end(); ++iter) | 120 iter != uuids.end(); ++iter) |
121 string_uuids->push_back(iter->canonical_value()); | 121 string_uuids->push_back(iter->canonical_value()); |
122 out->uuids.reset(string_uuids); | 122 out->uuids.reset(string_uuids); |
123 | 123 |
124 if (device.GetInquiryRSSI() != device::BluetoothDevice::kUnknownPower) | 124 if (device.GetInquiryRSSI()) |
125 out->inquiry_rssi.reset(new int(device.GetInquiryRSSI())); | 125 out->inquiry_rssi.reset(new int(device.GetInquiryRSSI().value())); |
126 else | 126 else |
127 out->inquiry_rssi.reset(); | 127 out->inquiry_rssi.reset(); |
128 | 128 |
129 if (device.GetInquiryTxPower() != device::BluetoothDevice::kUnknownPower) | 129 if (device.GetInquiryTxPower()) |
130 out->inquiry_tx_power.reset(new int(device.GetInquiryTxPower())); | 130 out->inquiry_tx_power.reset(new int(device.GetInquiryTxPower().value())); |
131 else | 131 else |
132 out->inquiry_tx_power.reset(); | 132 out->inquiry_tx_power.reset(); |
133 } | 133 } |
134 | 134 |
135 void PopulateAdapterState(const device::BluetoothAdapter& adapter, | 135 void PopulateAdapterState(const device::BluetoothAdapter& adapter, |
136 AdapterState* out) { | 136 AdapterState* out) { |
137 out->discovering = adapter.IsDiscovering(); | 137 out->discovering = adapter.IsDiscovering(); |
138 out->available = adapter.IsPresent(); | 138 out->available = adapter.IsPresent(); |
139 out->powered = adapter.IsPowered(); | 139 out->powered = adapter.IsPowered(); |
140 out->name = adapter.GetName(); | 140 out->name = adapter.GetName(); |
141 out->address = adapter.GetAddress(); | 141 out->address = adapter.GetAddress(); |
142 } | 142 } |
143 | 143 |
144 } // namespace bluetooth | 144 } // namespace bluetooth |
145 } // namespace api | 145 } // namespace api |
146 } // namespace extensions | 146 } // namespace extensions |
OLD | NEW |