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_adapter_chromeos.h" | 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.h" | |
14 #include "chromeos/dbus/bluetooth_adapter_client.h" | 13 #include "chromeos/dbus/bluetooth_adapter_client.h" |
15 #include "chromeos/dbus/bluetooth_device_client.h" | 14 #include "chromeos/dbus/bluetooth_device_client.h" |
16 #include "chromeos/dbus/bluetooth_manager_client.h" | 15 #include "chromeos/dbus/bluetooth_manager_client.h" |
17 #include "chromeos/dbus/bluetooth_out_of_band_client.h" | 16 #include "chromeos/dbus/bluetooth_out_of_band_client.h" |
18 #include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h" | |
19 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
20 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
| 19 #include "device/bluetooth/bluetooth_device_chromeos.h" |
| 20 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
| 21 |
| 22 using device::BluetoothAdapter; |
| 23 using device::BluetoothDevice; |
| 24 using device::BluetoothOutOfBandPairingData; |
21 | 25 |
22 namespace chromeos { | 26 namespace chromeos { |
23 | 27 |
24 BluetoothAdapterChromeOs::BluetoothAdapterChromeOs() : track_default_(false), | 28 BluetoothAdapterChromeOs::BluetoothAdapterChromeOs() : track_default_(false), |
25 powered_(false), | 29 powered_(false), |
26 discovering_(false), | 30 discovering_(false), |
27 weak_ptr_factory_(this) { | 31 weak_ptr_factory_(this) { |
28 DBusThreadManager::Get()->GetBluetoothManagerClient()-> | 32 DBusThreadManager::Get()->GetBluetoothManagerClient()-> |
29 AddObserver(this); | 33 AddObserver(this); |
30 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> | 34 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 const BluetoothDevice* BluetoothAdapterChromeOs::GetDevice( | 124 const BluetoothDevice* BluetoothAdapterChromeOs::GetDevice( |
121 const std::string& address) const { | 125 const std::string& address) const { |
122 DevicesMap::const_iterator iter = devices_.find(address); | 126 DevicesMap::const_iterator iter = devices_.find(address); |
123 if (iter != devices_.end()) | 127 if (iter != devices_.end()) |
124 return iter->second; | 128 return iter->second; |
125 | 129 |
126 return NULL; | 130 return NULL; |
127 } | 131 } |
128 | 132 |
129 void BluetoothAdapterChromeOs::ReadLocalOutOfBandPairingData( | 133 void BluetoothAdapterChromeOs::ReadLocalOutOfBandPairingData( |
130 const BluetoothOutOfBandPairingDataCallback& callback, | 134 const BluetoothAdapter::BluetoothOutOfBandPairingDataCallback& callback, |
131 const ErrorCallback& error_callback) { | 135 const ErrorCallback& error_callback) { |
132 DBusThreadManager::Get()->GetBluetoothOutOfBandClient()-> | 136 DBusThreadManager::Get()->GetBluetoothOutOfBandClient()-> |
133 ReadLocalData(object_path_, | 137 ReadLocalData(object_path_, |
134 base::Bind(&BluetoothAdapterChromeOs::OnReadLocalData, | 138 base::Bind(&BluetoothAdapterChromeOs::OnReadLocalData, |
135 weak_ptr_factory_.GetWeakPtr(), | 139 weak_ptr_factory_.GetWeakPtr(), |
136 callback, | 140 callback, |
137 error_callback)); | 141 error_callback)); |
138 } | 142 } |
139 | 143 |
140 void BluetoothAdapterChromeOs::TrackDefaultAdapter() { | 144 void BluetoothAdapterChromeOs::TrackDefaultAdapter() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 if (discovering == discovering_) | 291 if (discovering == discovering_) |
288 return; | 292 return; |
289 | 293 |
290 discovering_ = discovering; | 294 discovering_ = discovering; |
291 | 295 |
292 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | 296 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, |
293 AdapterDiscoveringChanged(this, discovering_)); | 297 AdapterDiscoveringChanged(this, discovering_)); |
294 } | 298 } |
295 | 299 |
296 void BluetoothAdapterChromeOs::OnReadLocalData( | 300 void BluetoothAdapterChromeOs::OnReadLocalData( |
297 const BluetoothOutOfBandPairingDataCallback& callback, | 301 const BluetoothAdapter::BluetoothOutOfBandPairingDataCallback& callback, |
298 const ErrorCallback& error_callback, | 302 const ErrorCallback& error_callback, |
299 const BluetoothOutOfBandPairingData& data, | 303 const BluetoothOutOfBandPairingData& data, |
300 bool success) { | 304 bool success) { |
301 if (success) | 305 if (success) |
302 callback.Run(data); | 306 callback.Run(data); |
303 else | 307 else |
304 error_callback.Run(); | 308 error_callback.Run(); |
305 } | 309 } |
306 | 310 |
307 void BluetoothAdapterChromeOs::AdapterPropertyChanged( | 311 void BluetoothAdapterChromeOs::AdapterPropertyChanged( |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 DVLOG(1) << "Paired device " << device->address() | 530 DVLOG(1) << "Paired device " << device->address() |
527 << " is no longer visible to the adapter"; | 531 << " is no longer visible to the adapter"; |
528 device->SetVisible(false); | 532 device->SetVisible(false); |
529 | 533 |
530 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | 534 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, |
531 DeviceChanged(this, device)); | 535 DeviceChanged(this, device)); |
532 } | 536 } |
533 } | 537 } |
534 | 538 |
535 } // namespace chromeos | 539 } // namespace chromeos |
OLD | NEW |