| 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 "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" | 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" |
| 13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 14 #include "device/bluetooth/bluetooth_device.h" | 13 #include "device/bluetooth/bluetooth_device.h" |
| 15 #include "device/bluetooth/bluetooth_profile.h" | 14 #include "device/bluetooth/bluetooth_profile.h" |
| 16 #include "extensions/browser/api/async_api_function.h" | 15 #include "extensions/browser/api/async_api_function.h" |
| 16 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 17 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 18 #include "extensions/browser/extension_function.h" | 18 #include "extensions/browser/extension_function.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 class BrowserContext; | 21 class BrowserContext; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace device { | 24 namespace device { |
| 25 | 25 |
| 26 class BluetoothAdapter; | 26 class BluetoothAdapter; |
| 27 class BluetoothDevice; | 27 class BluetoothDevice; |
| 28 class BluetoothSocket; | 28 class BluetoothSocket; |
| 29 struct BluetoothOutOfBandPairingData; | 29 struct BluetoothOutOfBandPairingData; |
| 30 | 30 |
| 31 } // namespace device | 31 } // namespace device |
| 32 | 32 |
| 33 namespace extensions { | 33 namespace extensions { |
| 34 | 34 |
| 35 class ExtensionBluetoothEventRouter; | 35 class ExtensionBluetoothEventRouter; |
| 36 | 36 |
| 37 // The profile-keyed service that manages the bluetooth extension API. | 37 // The profile-keyed service that manages the bluetooth extension API. |
| 38 class BluetoothAPI : public ProfileKeyedAPI, public EventRouter::Observer { | 38 class BluetoothAPI : public BrowserContextKeyedAPI, |
| 39 public EventRouter::Observer { |
| 39 public: | 40 public: |
| 40 // Convenience method to get the BluetoothAPI for a profile. | 41 // Convenience method to get the BluetoothAPI for a profile. |
| 41 static BluetoothAPI* Get(content::BrowserContext* context); | 42 static BluetoothAPI* Get(content::BrowserContext* context); |
| 42 | 43 |
| 43 static ProfileKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance(); | 44 static BrowserContextKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance(); |
| 44 | 45 |
| 45 explicit BluetoothAPI(content::BrowserContext* context); | 46 explicit BluetoothAPI(content::BrowserContext* context); |
| 46 virtual ~BluetoothAPI(); | 47 virtual ~BluetoothAPI(); |
| 47 | 48 |
| 48 ExtensionBluetoothEventRouter* bluetooth_event_router(); | 49 ExtensionBluetoothEventRouter* bluetooth_event_router(); |
| 49 | 50 |
| 50 // BrowserContextKeyedService implementation. | 51 // BrowserContextKeyedService implementation. |
| 51 virtual void Shutdown() OVERRIDE; | 52 virtual void Shutdown() OVERRIDE; |
| 52 | 53 |
| 53 // EventRouter::Observer implementation. | 54 // EventRouter::Observer implementation. |
| 54 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 55 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
| 55 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 56 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 friend class ProfileKeyedAPIFactory<BluetoothAPI>; | 59 friend class BrowserContextKeyedAPIFactory<BluetoothAPI>; |
| 59 | 60 |
| 60 // ProfileKeyedAPI implementation. | 61 // BrowserContextKeyedAPI implementation. |
| 61 static const char* service_name() { return "BluetoothAPI"; } | 62 static const char* service_name() { return "BluetoothAPI"; } |
| 62 static const bool kServiceRedirectedInIncognito = true; | 63 static const bool kServiceRedirectedInIncognito = true; |
| 63 static const bool kServiceIsNULLWhileTesting = true; | 64 static const bool kServiceIsNULLWhileTesting = true; |
| 64 | 65 |
| 65 content::BrowserContext* browser_context_; | 66 content::BrowserContext* browser_context_; |
| 66 | 67 |
| 67 // Created lazily on first access. | 68 // Created lazily on first access. |
| 68 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; | 69 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; |
| 69 }; | 70 }; |
| 70 | 71 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 284 |
| 284 private: | 285 private: |
| 285 void OnSuccessCallback(); | 286 void OnSuccessCallback(); |
| 286 void OnErrorCallback(); | 287 void OnErrorCallback(); |
| 287 }; | 288 }; |
| 288 | 289 |
| 289 } // namespace api | 290 } // namespace api |
| 290 } // namespace extensions | 291 } // namespace extensions |
| 291 | 292 |
| 292 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 293 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
| OLD | NEW |