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/extensions/api/bluetooth/bluetooth_api.h" | 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 BluetoothGetDeviceFunction::~BluetoothGetDeviceFunction() {} | 291 BluetoothGetDeviceFunction::~BluetoothGetDeviceFunction() {} |
292 | 292 |
293 bool BluetoothGetDeviceFunction::DoWork( | 293 bool BluetoothGetDeviceFunction::DoWork( |
294 scoped_refptr<BluetoothAdapter> adapter) { | 294 scoped_refptr<BluetoothAdapter> adapter) { |
295 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 295 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
296 | 296 |
297 scoped_ptr<GetDevice::Params> params(GetDevice::Params::Create(*args_)); | 297 scoped_ptr<GetDevice::Params> params(GetDevice::Params::Create(*args_)); |
298 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 298 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
299 const std::string& device_address = params->device_address; | |
300 | 299 |
301 BluetoothDevice* device = adapter->GetDevice(device_address); | 300 BluetoothDevice* device = adapter->GetDevice(params->device_address); |
302 if (device) { | 301 if (device) { |
303 bluetooth::Device extension_device; | 302 bluetooth::Device extension_device; |
304 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device); | 303 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device); |
305 SetResult(extension_device.ToValue().release()); | 304 SetResult(extension_device.ToValue().release()); |
306 SendResponse(true); | 305 SendResponse(true); |
307 } else { | 306 } else { |
308 SetError(kInvalidDevice); | 307 SetError(kInvalidDevice); |
309 SendResponse(false); | 308 SendResponse(false); |
310 } | 309 } |
311 | 310 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 adapter, | 667 adapter, |
669 extension_id(), | 668 extension_id(), |
670 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), | 669 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
671 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); | 670 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
672 | 671 |
673 return true; | 672 return true; |
674 } | 673 } |
675 | 674 |
676 } // namespace api | 675 } // namespace api |
677 } // namespace extensions | 676 } // namespace extensions |
OLD | NEW |