| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 } // namespace | 88 } // namespace |
| 89 | 89 |
| 90 namespace extensions { | 90 namespace extensions { |
| 91 namespace 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( |
| 98 new std::string(base::UTF16ToUTF8(device.GetNameForDisplay()))); |
| 98 out->device_class.reset(new int(device.GetBluetoothClass())); | 99 out->device_class.reset(new int(device.GetBluetoothClass())); |
| 99 | 100 |
| 100 // Only include the Device ID members when one exists for the device, and | 101 // Only include the Device ID members when one exists for the device, and |
| 101 // always include all or none. | 102 // always include all or none. |
| 102 if (ConvertVendorIDSourceToApi(device.GetVendorIDSource(), | 103 if (ConvertVendorIDSourceToApi(device.GetVendorIDSource(), |
| 103 &(out->vendor_id_source)) && | 104 &(out->vendor_id_source)) && |
| 104 out->vendor_id_source != VENDOR_ID_SOURCE_NONE) { | 105 out->vendor_id_source != VENDOR_ID_SOURCE_NONE) { |
| 105 out->vendor_id.reset(new int(device.GetVendorID())); | 106 out->vendor_id.reset(new int(device.GetVendorID())); |
| 106 out->product_id.reset(new int(device.GetProductID())); | 107 out->product_id.reset(new int(device.GetProductID())); |
| 107 out->device_id.reset(new int(device.GetDeviceID())); | 108 out->device_id.reset(new int(device.GetDeviceID())); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 137 out->discovering = adapter.IsDiscovering(); | 138 out->discovering = adapter.IsDiscovering(); |
| 138 out->available = adapter.IsPresent(); | 139 out->available = adapter.IsPresent(); |
| 139 out->powered = adapter.IsPowered(); | 140 out->powered = adapter.IsPowered(); |
| 140 out->name = adapter.GetName(); | 141 out->name = adapter.GetName(); |
| 141 out->address = adapter.GetAddress(); | 142 out->address = adapter.GetAddress(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 } // namespace bluetooth | 145 } // namespace bluetooth |
| 145 } // namespace api | 146 } // namespace api |
| 146 } // namespace extensions | 147 } // namespace extensions |
| OLD | NEW |