| 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_device_mac.h" | 5 #include "device/bluetooth/bluetooth_device_mac.h" |
| 6 | 6 |
| 7 #include <IOBluetooth/Bluetooth.h> | 7 #include <IOBluetooth/Bluetooth.h> |
| 8 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 8 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
| 9 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> | 9 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> |
| 10 #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> | 10 #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 - (NSString*)addressString; | 29 - (NSString*)addressString; |
| 30 - (NSString*)name; | 30 - (NSString*)name; |
| 31 - (unsigned int)classOfDevice; | 31 - (unsigned int)classOfDevice; |
| 32 - (NSArray*)services; | 32 - (NSArray*)services; |
| 33 @end | 33 @end |
| 34 | 34 |
| 35 #endif // MAC_OS_X_VERSION_10_7 | 35 #endif // MAC_OS_X_VERSION_10_7 |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 const char kFailedToConnect[] = "Connection failed"; |
| 40 |
| 39 // Converts |uuid| to a IOBluetoothSDPUUID instance. | 41 // Converts |uuid| to a IOBluetoothSDPUUID instance. |
| 40 // | 42 // |
| 41 // |uuid| must be in the format of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. | 43 // |uuid| must be in the format of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. |
| 42 IOBluetoothSDPUUID* GetIOBluetoothSDPUUID(const std::string& uuid) { | 44 IOBluetoothSDPUUID* GetIOBluetoothSDPUUID(const std::string& uuid) { |
| 43 DCHECK(uuid.size() == 36); | 45 DCHECK(uuid.size() == 36); |
| 44 DCHECK(uuid[8] == '-'); | 46 DCHECK(uuid[8] == '-'); |
| 45 DCHECK(uuid[13] == '-'); | 47 DCHECK(uuid[13] == '-'); |
| 46 DCHECK(uuid[18] == '-'); | 48 DCHECK(uuid[18] == '-'); |
| 47 DCHECK(uuid[23] == '-'); | 49 DCHECK(uuid[23] == '-'); |
| 48 std::string numbers_only = uuid; | 50 std::string numbers_only = uuid; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 if (record != nil) { | 210 if (record != nil) { |
| 209 BluetoothServiceRecordMac service_record(record); | 211 BluetoothServiceRecordMac service_record(record); |
| 210 scoped_refptr<BluetoothSocket> socket( | 212 scoped_refptr<BluetoothSocket> socket( |
| 211 BluetoothSocketMac::CreateBluetoothSocket(service_record)); | 213 BluetoothSocketMac::CreateBluetoothSocket(service_record)); |
| 212 if (socket.get() != NULL) | 214 if (socket.get() != NULL) |
| 213 callback.Run(socket); | 215 callback.Run(socket); |
| 214 } | 216 } |
| 215 } | 217 } |
| 216 | 218 |
| 217 void BluetoothDeviceMac::ConnectToProfile( | 219 void BluetoothDeviceMac::ConnectToProfile( |
| 218 device::BluetoothProfile* profile, | 220 BluetoothProfile* profile, |
| 219 const base::Closure& callback, | 221 const base::Closure& callback, |
| 220 const ErrorCallback& error_callback) { | 222 const ConnectToProfileErrorCallback& error_callback) { |
| 221 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) | 223 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) |
| 222 callback.Run(); | 224 callback.Run(); |
| 223 else | 225 else |
| 224 error_callback.Run(); | 226 error_callback.Run(kFailedToConnect); |
| 225 } | 227 } |
| 226 | 228 |
| 227 void BluetoothDeviceMac::SetOutOfBandPairingData( | 229 void BluetoothDeviceMac::SetOutOfBandPairingData( |
| 228 const BluetoothOutOfBandPairingData& data, | 230 const BluetoothOutOfBandPairingData& data, |
| 229 const base::Closure& callback, | 231 const base::Closure& callback, |
| 230 const ErrorCallback& error_callback) { | 232 const ErrorCallback& error_callback) { |
| 231 NOTIMPLEMENTED(); | 233 NOTIMPLEMENTED(); |
| 232 } | 234 } |
| 233 | 235 |
| 234 void BluetoothDeviceMac::ClearOutOfBandPairingData( | 236 void BluetoothDeviceMac::ClearOutOfBandPairingData( |
| 235 const base::Closure& callback, | 237 const base::Closure& callback, |
| 236 const ErrorCallback& error_callback) { | 238 const ErrorCallback& error_callback) { |
| 237 NOTIMPLEMENTED(); | 239 NOTIMPLEMENTED(); |
| 238 } | 240 } |
| 239 | 241 |
| 240 } // namespace device | 242 } // namespace device |
| OLD | NEW |