| 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/api_function.h" | |
| 13 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" | 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" |
| 14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 15 #include "device/bluetooth/bluetooth_device.h" | 14 #include "device/bluetooth/bluetooth_device.h" |
| 16 #include "device/bluetooth/bluetooth_profile.h" | 15 #include "device/bluetooth/bluetooth_profile.h" |
| 16 #include "extensions/browser/api/async_api_function.h" |
| 17 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 18 #include "extensions/browser/extension_function.h" |
| 19 |
| 20 namespace content { |
| 21 class BrowserContext; |
| 22 } |
| 18 | 23 |
| 19 namespace device { | 24 namespace device { |
| 20 | 25 |
| 21 class BluetoothAdapter; | 26 class BluetoothAdapter; |
| 22 class BluetoothDevice; | 27 class BluetoothDevice; |
| 23 class BluetoothSocket; | 28 class BluetoothSocket; |
| 24 struct BluetoothOutOfBandPairingData; | 29 struct BluetoothOutOfBandPairingData; |
| 25 | 30 |
| 26 } // namespace device | 31 } // namespace device |
| 27 | 32 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 55 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
| 51 | 56 |
| 52 private: | 57 private: |
| 53 friend class ProfileKeyedAPIFactory<BluetoothAPI>; | 58 friend class ProfileKeyedAPIFactory<BluetoothAPI>; |
| 54 | 59 |
| 55 // ProfileKeyedAPI implementation. | 60 // ProfileKeyedAPI implementation. |
| 56 static const char* service_name() { return "BluetoothAPI"; } | 61 static const char* service_name() { return "BluetoothAPI"; } |
| 57 static const bool kServiceRedirectedInIncognito = true; | 62 static const bool kServiceRedirectedInIncognito = true; |
| 58 static const bool kServiceIsNULLWhileTesting = true; | 63 static const bool kServiceIsNULLWhileTesting = true; |
| 59 | 64 |
| 60 Profile* profile_; | 65 content::BrowserContext* browser_context_; |
| 61 | 66 |
| 62 // Created lazily on first access. | 67 // Created lazily on first access. |
| 63 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; | 68 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; |
| 64 }; | 69 }; |
| 65 | 70 |
| 66 namespace api { | 71 namespace api { |
| 67 | 72 |
| 68 class BluetoothAddProfileFunction : public ChromeAsyncExtensionFunction { | 73 class BluetoothAddProfileFunction : public UIThreadExtensionFunction { |
| 69 public: | 74 public: |
| 70 DECLARE_EXTENSION_FUNCTION("bluetooth.addProfile", BLUETOOTH_ADDPROFILE) | 75 DECLARE_EXTENSION_FUNCTION("bluetooth.addProfile", BLUETOOTH_ADDPROFILE) |
| 71 | 76 |
| 72 BluetoothAddProfileFunction(); | 77 BluetoothAddProfileFunction(); |
| 73 | 78 |
| 74 protected: | 79 protected: |
| 75 virtual ~BluetoothAddProfileFunction() {} | 80 virtual ~BluetoothAddProfileFunction() {} |
| 76 virtual bool RunImpl() OVERRIDE; | 81 virtual bool RunImpl() OVERRIDE; |
| 77 | 82 |
| 78 virtual void RegisterProfile( | 83 virtual void RegisterProfile( |
| 79 const device::BluetoothProfile::Options& options, | 84 const device::BluetoothProfile::Options& options, |
| 80 const device::BluetoothProfile::ProfileCallback& callback); | 85 const device::BluetoothProfile::ProfileCallback& callback); |
| 81 | 86 |
| 82 private: | 87 private: |
| 83 void OnProfileRegistered(device::BluetoothProfile* bluetooth_profile); | 88 void OnProfileRegistered(device::BluetoothProfile* bluetooth_profile); |
| 84 | 89 |
| 85 std::string uuid_; | 90 std::string uuid_; |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 class BluetoothRemoveProfileFunction : public ChromeSyncExtensionFunction { | 93 class BluetoothRemoveProfileFunction : public SyncExtensionFunction { |
| 89 public: | 94 public: |
| 90 DECLARE_EXTENSION_FUNCTION("bluetooth.removeProfile", | 95 DECLARE_EXTENSION_FUNCTION("bluetooth.removeProfile", |
| 91 BLUETOOTH_REMOVEPROFILE) | 96 BLUETOOTH_REMOVEPROFILE) |
| 92 | 97 |
| 93 protected: | 98 protected: |
| 94 virtual ~BluetoothRemoveProfileFunction() {} | 99 virtual ~BluetoothRemoveProfileFunction() {} |
| 95 virtual bool RunImpl() OVERRIDE; | 100 virtual bool RunImpl() OVERRIDE; |
| 96 }; | 101 }; |
| 97 | 102 |
| 98 class BluetoothGetProfilesFunction : public BluetoothExtensionFunction { | 103 class BluetoothGetProfilesFunction : public BluetoothExtensionFunction { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 virtual ~BluetoothConnectFunction() {} | 167 virtual ~BluetoothConnectFunction() {} |
| 163 | 168 |
| 164 // BluetoothExtensionFunction: | 169 // BluetoothExtensionFunction: |
| 165 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 170 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 166 | 171 |
| 167 private: | 172 private: |
| 168 void OnSuccessCallback(); | 173 void OnSuccessCallback(); |
| 169 void OnErrorCallback(); | 174 void OnErrorCallback(); |
| 170 }; | 175 }; |
| 171 | 176 |
| 172 class BluetoothDisconnectFunction : public ChromeSyncExtensionFunction { | 177 class BluetoothDisconnectFunction : public SyncExtensionFunction { |
| 173 public: | 178 public: |
| 174 DECLARE_EXTENSION_FUNCTION("bluetooth.disconnect", BLUETOOTH_DISCONNECT) | 179 DECLARE_EXTENSION_FUNCTION("bluetooth.disconnect", BLUETOOTH_DISCONNECT) |
| 175 | 180 |
| 176 protected: | 181 protected: |
| 177 virtual ~BluetoothDisconnectFunction() {} | 182 virtual ~BluetoothDisconnectFunction() {} |
| 178 | 183 |
| 179 // ExtensionFunction: | 184 // ExtensionFunction: |
| 180 virtual bool RunImpl() OVERRIDE; | 185 virtual bool RunImpl() OVERRIDE; |
| 181 }; | 186 }; |
| 182 | 187 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 283 |
| 279 private: | 284 private: |
| 280 void OnSuccessCallback(); | 285 void OnSuccessCallback(); |
| 281 void OnErrorCallback(); | 286 void OnErrorCallback(); |
| 282 }; | 287 }; |
| 283 | 288 |
| 284 } // namespace api | 289 } // namespace api |
| 285 } // namespace extensions | 290 } // namespace extensions |
| 286 | 291 |
| 287 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 292 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
| OLD | NEW |