Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: device/bluetooth/bluetooth_device.cc

Issue 13416005: Bluetooth: clean up BluetoothDevice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More win visible fixes Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_chromeos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_device.cc
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
index a2249c50709db713510a7caab4ed1fb546269bb7..f7bea9ed95422afe8618efb42474ce1d2d08f864 100644
--- a/device/bluetooth/bluetooth_device.cc
+++ b/device/bluetooth/bluetooth_device.cc
@@ -18,84 +18,77 @@ bool BluetoothDevice::IsUUIDValid(const std::string& uuid) {
return !bluetooth_utils::CanonicalUuid(uuid).empty();
}
-BluetoothDevice::BluetoothDevice()
- : bluetooth_class_(0),
- visible_(false),
- bonded_(false),
- connected_(false),
- connectable_(true),
- connecting_(false) {
+BluetoothDevice::BluetoothDevice() {
}
BluetoothDevice::~BluetoothDevice() {
}
-const std::string& BluetoothDevice::address() const {
- return address_;
-}
-
string16 BluetoothDevice::GetName() const {
- if (!name_.empty()) {
- return UTF8ToUTF16(name_);
+ std::string name = GetDeviceName();
+ if (!name.empty()) {
+ return UTF8ToUTF16(name);
} else {
return GetAddressWithLocalizedDeviceTypeName();
}
}
string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
- string16 address = UTF8ToUTF16(address_);
+ string16 address_utf16 = UTF8ToUTF16(GetAddress());
BluetoothDevice::DeviceType device_type = GetDeviceType();
switch (device_type) {
case DEVICE_COMPUTER:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_COMPUTER,
- address);
+ address_utf16);
case DEVICE_PHONE:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_PHONE,
- address);
+ address_utf16);
case DEVICE_MODEM:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MODEM,
- address);
+ address_utf16);
case DEVICE_AUDIO:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_AUDIO,
- address);
+ address_utf16);
case DEVICE_CAR_AUDIO:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_CAR_AUDIO,
- address);
+ address_utf16);
case DEVICE_VIDEO:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_VIDEO,
- address);
+ address_utf16);
case DEVICE_JOYSTICK:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_JOYSTICK,
- address);
+ address_utf16);
case DEVICE_GAMEPAD:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_GAMEPAD,
- address);
+ address_utf16);
case DEVICE_KEYBOARD:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_KEYBOARD,
- address);
+ address_utf16);
case DEVICE_MOUSE:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_MOUSE,
- address);
+ address_utf16);
case DEVICE_TABLET:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_TABLET,
- address);
+ address_utf16);
case DEVICE_KEYBOARD_MOUSE_COMBO:
return l10n_util::GetStringFUTF16(
- IDS_BLUETOOTH_DEVICE_KEYBOARD_MOUSE_COMBO, address);
+ IDS_BLUETOOTH_DEVICE_KEYBOARD_MOUSE_COMBO, address_utf16);
default:
- return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_UNKNOWN, address);
+ return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_UNKNOWN,
+ address_utf16);
}
}
BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
// https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
- switch ((bluetooth_class_ & 0x1f00) >> 8) {
+ uint32 bluetooth_class = GetBluetoothClass();
+ switch ((bluetooth_class & 0x1f00) >> 8) {
case 0x01:
// Computer major device class.
return DEVICE_COMPUTER;
case 0x02:
// Phone major device class.
- switch ((bluetooth_class_ & 0xfc) >> 2) {
+ switch ((bluetooth_class & 0xfc) >> 2) {
case 0x01:
case 0x02:
case 0x03:
@@ -109,7 +102,7 @@ BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
break;
case 0x04:
// Audio major device class.
- switch ((bluetooth_class_ & 0xfc) >> 2) {
+ switch ((bluetooth_class & 0xfc) >> 2) {
case 0x08:
// Car audio.
return DEVICE_CAR_AUDIO;
@@ -127,10 +120,10 @@ BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
break;
case 0x05:
// Peripheral major device class.
- switch ((bluetooth_class_ & 0xc0) >> 6) {
+ switch ((bluetooth_class & 0xc0) >> 6) {
case 0x00:
// "Not a keyboard or pointing device."
- switch ((bluetooth_class_ & 0x01e) >> 2) {
+ switch ((bluetooth_class & 0x01e) >> 2) {
case 0x01:
// Joystick.
return DEVICE_JOYSTICK;
@@ -146,7 +139,7 @@ BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
return DEVICE_KEYBOARD;
case 0x02:
// Pointing device.
- switch ((bluetooth_class_ & 0x01e) >> 2) {
+ switch ((bluetooth_class & 0x01e) >> 2) {
case 0x05:
// Digitizer tablet.
return DEVICE_TABLET;
@@ -165,30 +158,11 @@ BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
return DEVICE_UNKNOWN;
}
-bool BluetoothDevice::IsVisible() const {
- return visible_;
-}
-
-bool BluetoothDevice::IsBonded() const {
- return bonded_;
-}
-
-bool BluetoothDevice::IsConnected() const {
- return connected_;
-}
-
-bool BluetoothDevice::IsConnectable() const {
- return connectable_;
-}
-
-bool BluetoothDevice::IsConnecting() const {
- return connecting_;
-}
bool BluetoothDevice::ProvidesServiceWithUUID(
const std::string& uuid) const {
std::string canonical_uuid = bluetooth_utils::CanonicalUuid(uuid);
- const BluetoothDevice::ServiceList& services = GetServices();
+ BluetoothDevice::ServiceList services = GetServices();
for (BluetoothDevice::ServiceList::const_iterator iter = services.begin();
iter != services.end();
++iter) {
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698