| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_classic_device_mac.h" | 5 #include "device/bluetooth/bluetooth_classic_device_mac.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/hash.h" | 10 #include "base/hash.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 IOBluetoothDevice* device) | 64 IOBluetoothDevice* device) |
| 65 : BluetoothDeviceMac(adapter), device_([device retain]) {} | 65 : BluetoothDeviceMac(adapter), device_([device retain]) {} |
| 66 | 66 |
| 67 BluetoothClassicDeviceMac::~BluetoothClassicDeviceMac() { | 67 BluetoothClassicDeviceMac::~BluetoothClassicDeviceMac() { |
| 68 } | 68 } |
| 69 | 69 |
| 70 uint32_t BluetoothClassicDeviceMac::GetBluetoothClass() const { | 70 uint32_t BluetoothClassicDeviceMac::GetBluetoothClass() const { |
| 71 return [device_ classOfDevice]; | 71 return [device_ classOfDevice]; |
| 72 } | 72 } |
| 73 | 73 |
| 74 std::string BluetoothClassicDeviceMac::GetDeviceName() const { | |
| 75 return base::SysNSStringToUTF8([device_ name]); | |
| 76 } | |
| 77 | |
| 78 void BluetoothClassicDeviceMac::CreateGattConnectionImpl() { | 74 void BluetoothClassicDeviceMac::CreateGattConnectionImpl() { |
| 79 // Classic devices do not support GATT connection. | 75 // Classic devices do not support GATT connection. |
| 80 DidFailToConnectGatt(ERROR_UNSUPPORTED_DEVICE); | 76 DidFailToConnectGatt(ERROR_UNSUPPORTED_DEVICE); |
| 81 } | 77 } |
| 82 | 78 |
| 83 void BluetoothClassicDeviceMac::DisconnectGatt() {} | 79 void BluetoothClassicDeviceMac::DisconnectGatt() {} |
| 84 | 80 |
| 85 std::string BluetoothClassicDeviceMac::GetAddress() const { | 81 std::string BluetoothClassicDeviceMac::GetAddress() const { |
| 86 return GetDeviceAddress(device_); | 82 return GetDeviceAddress(device_); |
| 87 } | 83 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 103 return 0; | 99 return 0; |
| 104 } | 100 } |
| 105 | 101 |
| 106 uint16_t BluetoothClassicDeviceMac::GetAppearance() const { | 102 uint16_t BluetoothClassicDeviceMac::GetAppearance() const { |
| 107 // TODO(crbug.com/588083): Implementing GetAppearance() | 103 // TODO(crbug.com/588083): Implementing GetAppearance() |
| 108 // on mac, win, and android platforms for chrome | 104 // on mac, win, and android platforms for chrome |
| 109 NOTIMPLEMENTED(); | 105 NOTIMPLEMENTED(); |
| 110 return 0; | 106 return 0; |
| 111 } | 107 } |
| 112 | 108 |
| 109 base::Optional<std::string> BluetoothClassicDeviceMac::GetName() const { |
| 110 if ([device_ name]) |
| 111 return base::SysNSStringToUTF8([device_ name]); |
| 112 return base::nullopt; |
| 113 } |
| 114 |
| 113 bool BluetoothClassicDeviceMac::IsPaired() const { | 115 bool BluetoothClassicDeviceMac::IsPaired() const { |
| 114 return [device_ isPaired]; | 116 return [device_ isPaired]; |
| 115 } | 117 } |
| 116 | 118 |
| 117 bool BluetoothClassicDeviceMac::IsConnected() const { | 119 bool BluetoothClassicDeviceMac::IsConnected() const { |
| 118 return [device_ isConnected]; | 120 return [device_ isConnected]; |
| 119 } | 121 } |
| 120 | 122 |
| 121 bool BluetoothClassicDeviceMac::IsGattConnected() const { | 123 bool BluetoothClassicDeviceMac::IsGattConnected() const { |
| 122 return false; // Classic devices do not support GATT connection. | 124 return false; // Classic devices do not support GATT connection. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 return power_level; | 283 return power_level; |
| 282 } | 284 } |
| 283 | 285 |
| 284 // static | 286 // static |
| 285 std::string BluetoothClassicDeviceMac::GetDeviceAddress( | 287 std::string BluetoothClassicDeviceMac::GetDeviceAddress( |
| 286 IOBluetoothDevice* device) { | 288 IOBluetoothDevice* device) { |
| 287 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); | 289 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); |
| 288 } | 290 } |
| 289 | 291 |
| 290 } // namespace device | 292 } // namespace device |
| OLD | NEW |