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 "chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.h" | 5 #include "device/bluetooth/bluetooth_device_chromeos.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_chromeos.h" | |
20 #include "chrome/browser/chromeos/bluetooth/bluetooth_service_record.h" | |
21 #include "chrome/browser/chromeos/bluetooth/bluetooth_socket_chromeos.h" | |
22 #include "chrome/browser/chromeos/bluetooth/bluetooth_utils.h" | |
23 #include "chromeos/dbus/bluetooth_adapter_client.h" | 19 #include "chromeos/dbus/bluetooth_adapter_client.h" |
24 #include "chromeos/dbus/bluetooth_agent_service_provider.h" | 20 #include "chromeos/dbus/bluetooth_agent_service_provider.h" |
25 #include "chromeos/dbus/bluetooth_device_client.h" | 21 #include "chromeos/dbus/bluetooth_device_client.h" |
26 #include "chromeos/dbus/bluetooth_input_client.h" | 22 #include "chromeos/dbus/bluetooth_input_client.h" |
27 #include "chromeos/dbus/bluetooth_out_of_band_client.h" | 23 #include "chromeos/dbus/bluetooth_out_of_band_client.h" |
28 #include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h" | |
29 #include "chromeos/dbus/dbus_thread_manager.h" | 24 #include "chromeos/dbus/dbus_thread_manager.h" |
30 #include "chromeos/dbus/introspectable_client.h" | 25 #include "chromeos/dbus/introspectable_client.h" |
31 #include "dbus/bus.h" | 26 #include "dbus/bus.h" |
32 #include "dbus/object_path.h" | 27 #include "dbus/object_path.h" |
| 28 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
| 29 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
| 30 #include "device/bluetooth/bluetooth_service_record.h" |
| 31 #include "device/bluetooth/bluetooth_socket_chromeos.h" |
| 32 #include "device/bluetooth/bluetooth_utils.h" |
33 #include "third_party/cros_system_api/dbus/service_constants.h" | 33 #include "third_party/cros_system_api/dbus/service_constants.h" |
34 | 34 |
| 35 using device::BluetoothDevice; |
| 36 using device::BluetoothOutOfBandPairingData; |
| 37 using device::BluetoothServiceRecord; |
| 38 using device::BluetoothSocket; |
| 39 |
35 namespace chromeos { | 40 namespace chromeos { |
36 | 41 |
37 BluetoothDeviceChromeOs::BluetoothDeviceChromeOs( | 42 BluetoothDeviceChromeOs::BluetoothDeviceChromeOs( |
38 BluetoothAdapterChromeOs* adapter) | 43 BluetoothAdapterChromeOs* adapter) |
39 : BluetoothDevice(), | 44 : BluetoothDevice(), |
40 adapter_(adapter), | 45 adapter_(adapter), |
41 pairing_delegate_(NULL), | 46 pairing_delegate_(NULL), |
42 connecting_applications_counter_(0), | 47 connecting_applications_counter_(0), |
43 weak_ptr_factory_(this) { | 48 weak_ptr_factory_(this) { |
44 } | 49 } |
(...skipping 22 matching lines...) Expand all Loading... |
67 callback, | 72 callback, |
68 error_callback)); | 73 error_callback)); |
69 } | 74 } |
70 | 75 |
71 bool BluetoothDeviceChromeOs::ProvidesServiceWithUUID( | 76 bool BluetoothDeviceChromeOs::ProvidesServiceWithUUID( |
72 const std::string& uuid) const { | 77 const std::string& uuid) const { |
73 const BluetoothDevice::ServiceList& services = GetServices(); | 78 const BluetoothDevice::ServiceList& services = GetServices(); |
74 for (BluetoothDevice::ServiceList::const_iterator iter = services.begin(); | 79 for (BluetoothDevice::ServiceList::const_iterator iter = services.begin(); |
75 iter != services.end(); | 80 iter != services.end(); |
76 ++iter) { | 81 ++iter) { |
77 if (bluetooth_utils::CanonicalUuid(*iter) == uuid) | 82 if (device::bluetooth_utils::CanonicalUuid(*iter) == uuid) |
78 return true; | 83 return true; |
79 } | 84 } |
80 return false; | 85 return false; |
81 } | 86 } |
82 | 87 |
83 void BluetoothDeviceChromeOs::ProvidesServiceWithName( | 88 void BluetoothDeviceChromeOs::ProvidesServiceWithName( |
84 const std::string& name, | 89 const std::string& name, |
85 const ProvidesServiceCallback& callback) { | 90 const ProvidesServiceCallback& callback) { |
86 GetServiceRecords( | 91 GetServiceRecords( |
87 base::Bind(&BluetoothDeviceChromeOs::SearchServicesForNameCallback, | 92 base::Bind(&BluetoothDeviceChromeOs::SearchServicesForNameCallback, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 weak_ptr_factory_.GetWeakPtr(), | 257 weak_ptr_factory_.GetWeakPtr(), |
253 service_uuid, | 258 service_uuid, |
254 callback), | 259 callback), |
255 base::Bind( | 260 base::Bind( |
256 &BluetoothDeviceChromeOs::GetServiceRecordsForConnectErrorCallback, | 261 &BluetoothDeviceChromeOs::GetServiceRecordsForConnectErrorCallback, |
257 weak_ptr_factory_.GetWeakPtr(), | 262 weak_ptr_factory_.GetWeakPtr(), |
258 callback)); | 263 callback)); |
259 } | 264 } |
260 | 265 |
261 void BluetoothDeviceChromeOs::SetOutOfBandPairingData( | 266 void BluetoothDeviceChromeOs::SetOutOfBandPairingData( |
262 const chromeos::BluetoothOutOfBandPairingData& data, | 267 const BluetoothOutOfBandPairingData& data, |
263 const base::Closure& callback, | 268 const base::Closure& callback, |
264 const ErrorCallback& error_callback) { | 269 const ErrorCallback& error_callback) { |
265 DBusThreadManager::Get()->GetBluetoothOutOfBandClient()-> | 270 DBusThreadManager::Get()->GetBluetoothOutOfBandClient()-> |
266 AddRemoteData( | 271 AddRemoteData( |
267 object_path_, | 272 object_path_, |
268 address(), | 273 address(), |
269 data, | 274 data, |
270 base::Bind(&BluetoothDeviceChromeOs::OnRemoteDataCallback, | 275 base::Bind(&BluetoothDeviceChromeOs::OnRemoteDataCallback, |
271 weak_ptr_factory_.GetWeakPtr(), | 276 weak_ptr_factory_.GetWeakPtr(), |
272 callback, | 277 callback, |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } | 681 } |
677 | 682 |
678 | 683 |
679 // static | 684 // static |
680 BluetoothDeviceChromeOs* BluetoothDeviceChromeOs::Create( | 685 BluetoothDeviceChromeOs* BluetoothDeviceChromeOs::Create( |
681 BluetoothAdapterChromeOs* adapter) { | 686 BluetoothAdapterChromeOs* adapter) { |
682 return new BluetoothDeviceChromeOs(adapter); | 687 return new BluetoothDeviceChromeOs(adapter); |
683 } | 688 } |
684 | 689 |
685 } // namespace chromeos | 690 } // namespace chromeos |
OLD | NEW |