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 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/extensions/api/api_function.h" | 12 #include "chrome/browser/extensions/api/api_function.h" |
| 13 #include "chrome/browser/extensions/event_router.h" |
12 #include "chrome/browser/extensions/extension_function.h" | 14 #include "chrome/browser/extensions/extension_function.h" |
| 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
13 #include "device/bluetooth/bluetooth_device.h" | 16 #include "device/bluetooth/bluetooth_device.h" |
14 | 17 |
15 namespace device { | 18 namespace device { |
16 | 19 |
17 class BluetoothSocket; | 20 class BluetoothSocket; |
18 struct BluetoothOutOfBandPairingData; | 21 struct BluetoothOutOfBandPairingData; |
19 | 22 |
20 } // namespace device | 23 } // namespace device |
21 | 24 |
22 namespace extensions { | 25 namespace extensions { |
| 26 |
| 27 class ExtensionBluetoothEventRouter; |
| 28 |
| 29 // The profile-keyed service that manages the bluetooth extension API. |
| 30 class BluetoothAPI : public ProfileKeyedService, |
| 31 public EventRouter::Observer { |
| 32 public: |
| 33 // Convenience method to get the BluetoothAPI for a profile. |
| 34 static BluetoothAPI* Get(Profile* profile); |
| 35 |
| 36 explicit BluetoothAPI(Profile* profile); |
| 37 virtual ~BluetoothAPI(); |
| 38 |
| 39 ExtensionBluetoothEventRouter* bluetooth_event_router(); |
| 40 |
| 41 // ProfileKeyedService implementation. |
| 42 virtual void Shutdown() OVERRIDE; |
| 43 |
| 44 // EventRouter::Observer implementation. |
| 45 virtual void OnListenerAdded(const std::string& event_name) OVERRIDE; |
| 46 virtual void OnListenerRemoved(const std::string& event_name) OVERRIDE; |
| 47 |
| 48 private: |
| 49 Profile* profile_; |
| 50 |
| 51 // Created lazily on first access. |
| 52 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; |
| 53 }; |
| 54 |
23 namespace api { | 55 namespace api { |
24 | 56 |
25 class BluetoothIsAvailableFunction : public SyncExtensionFunction { | 57 class BluetoothIsAvailableFunction : public SyncExtensionFunction { |
26 public: | 58 public: |
27 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.isAvailable") | 59 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.isAvailable") |
28 | 60 |
29 protected: | 61 protected: |
30 virtual ~BluetoothIsAvailableFunction() {} | 62 virtual ~BluetoothIsAvailableFunction() {} |
31 | 63 |
32 // ExtensionFunction: | 64 // ExtensionFunction: |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 259 |
228 private: | 260 private: |
229 void OnSuccessCallback(); | 261 void OnSuccessCallback(); |
230 void OnErrorCallback(); | 262 void OnErrorCallback(); |
231 }; | 263 }; |
232 | 264 |
233 } // namespace api | 265 } // namespace api |
234 } // namespace extensions | 266 } // namespace extensions |
235 | 267 |
236 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 268 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
OLD | NEW |