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" |
11 #include "extensions/common/api/bluetooth.h" | 11 #include "extensions/common/api/bluetooth.h" |
12 | 12 |
13 namespace bluetooth = extensions::core_api::bluetooth; | 13 namespace bluetooth = extensions::api::bluetooth; |
14 | 14 |
15 using device::BluetoothDevice; | 15 using device::BluetoothDevice; |
16 using bluetooth::VendorIdSource; | 16 using bluetooth::VendorIdSource; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 bool ConvertVendorIDSourceToApi(const BluetoothDevice::VendorIDSource& input, | 20 bool ConvertVendorIDSourceToApi(const BluetoothDevice::VendorIDSource& input, |
21 bluetooth::VendorIdSource* output) { | 21 bluetooth::VendorIdSource* output) { |
22 switch (input) { | 22 switch (input) { |
23 case BluetoothDevice::VENDOR_ID_UNKNOWN: | 23 case BluetoothDevice::VENDOR_ID_UNKNOWN: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 *output = bluetooth::DEVICE_TYPE_KEYBOARDMOUSECOMBO; | 81 *output = bluetooth::DEVICE_TYPE_KEYBOARDMOUSECOMBO; |
82 return true; | 82 return true; |
83 default: | 83 default: |
84 return false; | 84 return false; |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 namespace extensions { | 90 namespace extensions { |
91 namespace core_api { | 91 namespace api { |
92 namespace bluetooth { | 92 namespace bluetooth { |
93 | 93 |
94 void BluetoothDeviceToApiDevice(const device::BluetoothDevice& device, | 94 void BluetoothDeviceToApiDevice(const device::BluetoothDevice& device, |
95 Device* out) { | 95 Device* out) { |
96 out->address = device.GetAddress(); | 96 out->address = device.GetAddress(); |
97 out->name.reset(new std::string(base::UTF16ToUTF8(device.GetName()))); | 97 out->name.reset(new std::string(base::UTF16ToUTF8(device.GetName()))); |
98 out->device_class.reset(new int(device.GetBluetoothClass())); | 98 out->device_class.reset(new int(device.GetBluetoothClass())); |
99 | 99 |
100 // Only include the Device ID members when one exists for the device, and | 100 // Only include the Device ID members when one exists for the device, and |
101 // always include all or none. | 101 // always include all or none. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void PopulateAdapterState(const device::BluetoothAdapter& adapter, | 133 void PopulateAdapterState(const device::BluetoothAdapter& adapter, |
134 AdapterState* out) { | 134 AdapterState* out) { |
135 out->discovering = adapter.IsDiscovering(); | 135 out->discovering = adapter.IsDiscovering(); |
136 out->available = adapter.IsPresent(); | 136 out->available = adapter.IsPresent(); |
137 out->powered = adapter.IsPowered(); | 137 out->powered = adapter.IsPowered(); |
138 out->name = adapter.GetName(); | 138 out->name = adapter.GetName(); |
139 out->address = adapter.GetAddress(); | 139 out->address = adapter.GetAddress(); |
140 } | 140 } |
141 | 141 |
142 } // namespace bluetooth | 142 } // namespace bluetooth |
143 } // namespace core_api | 143 } // namespace api |
144 } // namespace extensions | 144 } // namespace extensions |
OLD | NEW |