OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" |
| 6 |
| 7 #include "base/memory/ref_counted.h" |
| 8 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
| 9 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "device/bluetooth/bluetooth_adapter.h" |
| 12 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 13 |
| 14 namespace { |
| 15 |
| 16 const char kPlatformNotSupported[] = |
| 17 "This operation is not supported on your platform"; |
| 18 |
| 19 scoped_refptr<device::BluetoothAdapter> GetAdapter(Profile* profile) { |
| 20 extensions::ExtensionBluetoothEventRouter* event_router = |
| 21 extensions::BluetoothAPI::Get(profile)->bluetooth_event_router(); |
| 22 return event_router->GetAdapter(); |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 namespace extensions { |
| 28 |
| 29 namespace api { |
| 30 |
| 31 BluetoothExtensionFunction::BluetoothExtensionFunction() { |
| 32 } |
| 33 |
| 34 BluetoothExtensionFunction::~BluetoothExtensionFunction() { |
| 35 } |
| 36 |
| 37 bool BluetoothExtensionFunction::RunImpl() { |
| 38 scoped_refptr<device::BluetoothAdapter> adapter = GetAdapter(profile()); |
| 39 if (!adapter) { |
| 40 SetError(kPlatformNotSupported); |
| 41 return false; |
| 42 } |
| 43 DoWork(adapter); |
| 44 return true; |
| 45 } |
| 46 |
| 47 } // namespace api |
| 48 |
| 49 } // namespace extensions |
OLD | NEW |