| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 | 10 |
| 11 #if defined(OS_CHROMEOS) | 11 #if defined(OS_CHROMEOS) |
| 12 #include "base/memory/ref_counted.h" |
| 13 |
| 12 namespace chromeos { | 14 namespace chromeos { |
| 13 | 15 |
| 14 class BluetoothAdapter; | 16 class BluetoothAdapter; |
| 15 class BluetoothDevice; | 17 class BluetoothDevice; |
| 18 class BluetoothSocket; |
| 19 class ExtensionBluetoothEventRouter; |
| 16 | 20 |
| 17 } // namespace chromeos | 21 } // namespace chromeos |
| 18 #endif | 22 #endif |
| 19 | 23 |
| 20 namespace extensions { | 24 namespace extensions { |
| 21 namespace api { | 25 namespace api { |
| 22 | 26 |
| 23 class BluetoothExtensionFunction : public SyncExtensionFunction { | 27 class BluetoothExtensionFunction : public SyncExtensionFunction { |
| 24 protected: | 28 protected: |
| 25 virtual ~BluetoothExtensionFunction() {} | 29 virtual ~BluetoothExtensionFunction() {} |
| 26 | 30 |
| 27 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
| 32 chromeos::ExtensionBluetoothEventRouter* event_router(); |
| 28 const chromeos::BluetoothAdapter* adapter() const; | 33 const chromeos::BluetoothAdapter* adapter() const; |
| 29 chromeos::BluetoothAdapter* GetMutableAdapter(); | 34 chromeos::BluetoothAdapter* GetMutableAdapter(); |
| 30 #endif | 35 #endif |
| 31 }; | 36 }; |
| 32 | 37 |
| 33 class AsyncBluetoothExtensionFunction : public AsyncExtensionFunction { | 38 class AsyncBluetoothExtensionFunction : public AsyncExtensionFunction { |
| 34 protected: | 39 protected: |
| 35 virtual ~AsyncBluetoothExtensionFunction() {} | 40 virtual ~AsyncBluetoothExtensionFunction() {} |
| 36 | 41 |
| 37 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 chromeos::ExtensionBluetoothEventRouter* event_router(); |
| 38 const chromeos::BluetoothAdapter* adapter() const; | 44 const chromeos::BluetoothAdapter* adapter() const; |
| 39 chromeos::BluetoothAdapter* GetMutableAdapter(); | 45 chromeos::BluetoothAdapter* GetMutableAdapter(); |
| 40 #endif | 46 #endif |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 class BluetoothIsAvailableFunction : public BluetoothExtensionFunction { | 49 class BluetoothIsAvailableFunction : public BluetoothExtensionFunction { |
| 44 public: | 50 public: |
| 45 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") | 51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") |
| 46 | 52 |
| 47 protected: | 53 protected: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 110 |
| 105 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
| 106 private: | 112 private: |
| 107 void AddDeviceIfTrue( | 113 void AddDeviceIfTrue( |
| 108 ListValue* list, const chromeos::BluetoothDevice* device, bool result); | 114 ListValue* list, const chromeos::BluetoothDevice* device, bool result); |
| 109 | 115 |
| 110 int callbacks_pending_; | 116 int callbacks_pending_; |
| 111 #endif | 117 #endif |
| 112 }; | 118 }; |
| 113 | 119 |
| 120 class BluetoothConnectFunction : public AsyncBluetoothExtensionFunction { |
| 121 public: |
| 122 virtual bool RunImpl() OVERRIDE; |
| 123 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") |
| 124 |
| 125 private: |
| 126 #if defined(OS_CHROMEOS) |
| 127 void ConnectToServiceCallback( |
| 128 const chromeos::BluetoothDevice* device, |
| 129 const std::string& service_uuid, |
| 130 scoped_refptr<chromeos::BluetoothSocket> socket); |
| 131 #endif |
| 132 }; |
| 133 |
| 114 class BluetoothDisconnectFunction : public BluetoothExtensionFunction { | 134 class BluetoothDisconnectFunction : public BluetoothExtensionFunction { |
| 115 public: | 135 public: |
| 116 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") | 136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") |
| 117 | 137 |
| 118 protected: | 138 protected: |
| 119 virtual ~BluetoothDisconnectFunction() {} | 139 virtual ~BluetoothDisconnectFunction() {} |
| 120 | 140 |
| 121 // ExtensionFunction: | 141 // ExtensionFunction: |
| 122 virtual bool RunImpl() OVERRIDE; | 142 virtual bool RunImpl() OVERRIDE; |
| 123 }; | 143 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 public: | 183 public: |
| 164 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") | 184 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") |
| 165 | 185 |
| 166 private: | 186 private: |
| 167 virtual ~BluetoothWriteFunction() {} | 187 virtual ~BluetoothWriteFunction() {} |
| 168 | 188 |
| 169 // ExtensionFunction: | 189 // ExtensionFunction: |
| 170 virtual bool RunImpl() OVERRIDE; | 190 virtual bool RunImpl() OVERRIDE; |
| 171 }; | 191 }; |
| 172 | 192 |
| 173 class BluetoothConnectFunction : public BluetoothExtensionFunction { | |
| 174 public: | |
| 175 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") | |
| 176 | |
| 177 protected: | |
| 178 virtual ~BluetoothConnectFunction() {} | |
| 179 | |
| 180 // ExtensionFunction: | |
| 181 virtual bool RunImpl() OVERRIDE; | |
| 182 }; | |
| 183 | |
| 184 } // namespace api | 193 } // namespace api |
| 185 } // namespace extensions | 194 } // namespace extensions |
| 186 | 195 |
| 187 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 196 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
| OLD | NEW |