| 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 "device/bluetooth/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "device/bluetooth/bluetooth_utils.h" | 10 #include "device/bluetooth/bluetooth_utils.h" |
| 11 #include "grit/device_bluetooth_strings.h" | 11 #include "grit/device_bluetooth_strings.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 bool BluetoothDevice::IsUUIDValid(const std::string& uuid) { | 17 bool BluetoothDevice::IsUUIDValid(const std::string& uuid) { |
| 18 return !bluetooth_utils::CanonicalUuid(uuid).empty(); | 18 return !bluetooth_utils::CanonicalUuid(uuid).empty(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 BluetoothDevice::BluetoothDevice() { | 21 BluetoothDevice::BluetoothDevice() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 BluetoothDevice::~BluetoothDevice() { | 24 BluetoothDevice::~BluetoothDevice() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 base::string16 BluetoothDevice::GetName() const { | 27 base::string16 BluetoothDevice::GetName() const { |
| 28 std::string name = GetDeviceName(); | 28 std::string name = GetDeviceName(); |
| 29 if (!name.empty()) { | 29 if (!name.empty()) { |
| 30 return UTF8ToUTF16(name); | 30 return base::UTF8ToUTF16(name); |
| 31 } else { | 31 } else { |
| 32 return GetAddressWithLocalizedDeviceTypeName(); | 32 return GetAddressWithLocalizedDeviceTypeName(); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 base::string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const { | 36 base::string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const { |
| 37 base::string16 address_utf16 = UTF8ToUTF16(GetAddress()); | 37 base::string16 address_utf16 = base::UTF8ToUTF16(GetAddress()); |
| 38 BluetoothDevice::DeviceType device_type = GetDeviceType(); | 38 BluetoothDevice::DeviceType device_type = GetDeviceType(); |
| 39 switch (device_type) { | 39 switch (device_type) { |
| 40 case DEVICE_COMPUTER: | 40 case DEVICE_COMPUTER: |
| 41 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_COMPUTER, | 41 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_COMPUTER, |
| 42 address_utf16); | 42 address_utf16); |
| 43 case DEVICE_PHONE: | 43 case DEVICE_PHONE: |
| 44 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_PHONE, | 44 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_PHONE, |
| 45 address_utf16); | 45 address_utf16); |
| 46 case DEVICE_MODEM: | 46 case DEVICE_MODEM: |
| 47 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MODEM, | 47 return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MODEM, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 for (BluetoothDevice::ServiceList::const_iterator iter = services.begin(); | 181 for (BluetoothDevice::ServiceList::const_iterator iter = services.begin(); |
| 182 iter != services.end(); | 182 iter != services.end(); |
| 183 ++iter) { | 183 ++iter) { |
| 184 if (bluetooth_utils::CanonicalUuid(*iter) == canonical_uuid) | 184 if (bluetooth_utils::CanonicalUuid(*iter) == canonical_uuid) |
| 185 return true; | 185 return true; |
| 186 } | 186 } |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace device | 190 } // namespace device |
| OLD | NEW |