| 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 "chrome/browser/extensions/api/api_function.h" | 10 #include "chrome/browser/extensions/api/api_function.h" |
| 11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
| 12 | 12 |
| 13 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | 15 #include "chrome/browser/chromeos/bluetooth/bluetooth_device_interface.h" |
| 16 #include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h" | 16 #include "chrome/browser/chromeos/bluetooth/bluetooth_socket_posix.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 class BluetoothSocket; | 20 class BluetoothSocketPosix; |
| 21 struct BluetoothOutOfBandPairingData; | 21 struct BluetoothOutOfBandPairingData; |
| 22 | 22 |
| 23 } // namespace chromeos | 23 } // namespace chromeos |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 namespace api { | 27 namespace api { |
| 28 | 28 |
| 29 class BluetoothIsAvailableFunction : public SyncExtensionFunction { | 29 class BluetoothIsAvailableFunction : public SyncExtensionFunction { |
| 30 public: | 30 public: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 protected: | 81 protected: |
| 82 virtual ~BluetoothGetDevicesFunction() {} | 82 virtual ~BluetoothGetDevicesFunction() {} |
| 83 | 83 |
| 84 // ExtensionFunction: | 84 // ExtensionFunction: |
| 85 virtual bool RunImpl() OVERRIDE; | 85 virtual bool RunImpl() OVERRIDE; |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
| 89 void AddDeviceIfTrueCallback(ListValue* list, | 89 void AddDeviceIfTrueCallback(ListValue* list, |
| 90 const chromeos::BluetoothDevice* device, | 90 const chromeos::BluetoothDeviceInterface* device, |
| 91 bool shouldAdd); | 91 bool shouldAdd); |
| 92 | 92 |
| 93 int callbacks_pending_; | 93 int callbacks_pending_; |
| 94 #endif | 94 #endif |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class BluetoothGetServicesFunction : public AsyncExtensionFunction { | 97 class BluetoothGetServicesFunction : public AsyncExtensionFunction { |
| 98 public: | 98 public: |
| 99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getServices") | 99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getServices") |
| 100 | 100 |
| 101 protected: | 101 protected: |
| 102 virtual ~BluetoothGetServicesFunction() {} | 102 virtual ~BluetoothGetServicesFunction() {} |
| 103 | 103 |
| 104 // ExtensionFunction: | 104 // ExtensionFunction: |
| 105 virtual bool RunImpl() OVERRIDE; | 105 virtual bool RunImpl() OVERRIDE; |
| 106 | 106 |
| 107 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
| 108 private: | 108 private: |
| 109 void GetServiceRecordsCallback( | 109 void GetServiceRecordsCallback( |
| 110 base::ListValue* services, | 110 base::ListValue* services, |
| 111 const chromeos::BluetoothDevice::ServiceRecordList& records); | 111 const chromeos::BluetoothDeviceInterface::ServiceRecordList& records); |
| 112 void OnErrorCallback(); | 112 void OnErrorCallback(); |
| 113 #endif | 113 #endif |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 class BluetoothConnectFunction : public AsyncExtensionFunction { | 116 class BluetoothConnectFunction : public AsyncExtensionFunction { |
| 117 public: | 117 public: |
| 118 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") | 118 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") |
| 119 | 119 |
| 120 protected: | 120 protected: |
| 121 virtual ~BluetoothConnectFunction() {} | 121 virtual ~BluetoothConnectFunction() {} |
| 122 | 122 |
| 123 virtual bool RunImpl() OVERRIDE; | 123 virtual bool RunImpl() OVERRIDE; |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 #if defined(OS_CHROMEOS) | 126 #if defined(OS_CHROMEOS) |
| 127 void ConnectToServiceCallback( | 127 void ConnectToServiceCallback( |
| 128 const chromeos::BluetoothDevice* device, | 128 const chromeos::BluetoothDeviceInterface* device, |
| 129 const std::string& service_uuid, | 129 const std::string& service_uuid, |
| 130 scoped_refptr<chromeos::BluetoothSocket> socket); | 130 scoped_refptr<chromeos::BluetoothSocketPosix> socket); |
| 131 #endif | 131 #endif |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 class BluetoothDisconnectFunction : public SyncExtensionFunction { | 134 class BluetoothDisconnectFunction : public SyncExtensionFunction { |
| 135 public: | 135 public: |
| 136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") | 136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") |
| 137 | 137 |
| 138 protected: | 138 protected: |
| 139 virtual ~BluetoothDisconnectFunction() {} | 139 virtual ~BluetoothDisconnectFunction() {} |
| 140 | 140 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 151 virtual ~BluetoothReadFunction(); | 151 virtual ~BluetoothReadFunction(); |
| 152 | 152 |
| 153 // AsyncApiFunction: | 153 // AsyncApiFunction: |
| 154 virtual bool Prepare() OVERRIDE; | 154 virtual bool Prepare() OVERRIDE; |
| 155 virtual bool Respond() OVERRIDE; | 155 virtual bool Respond() OVERRIDE; |
| 156 virtual void Work() OVERRIDE; | 156 virtual void Work() OVERRIDE; |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
| 160 bool success_; | 160 bool success_; |
| 161 scoped_refptr<chromeos::BluetoothSocket> socket_; | 161 scoped_refptr<chromeos::BluetoothSocketPosix> socket_; |
| 162 #endif | 162 #endif |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 class BluetoothWriteFunction : public AsyncApiFunction { | 165 class BluetoothWriteFunction : public AsyncApiFunction { |
| 166 public: | 166 public: |
| 167 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") | 167 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") |
| 168 BluetoothWriteFunction(); | 168 BluetoothWriteFunction(); |
| 169 | 169 |
| 170 protected: | 170 protected: |
| 171 virtual ~BluetoothWriteFunction(); | 171 virtual ~BluetoothWriteFunction(); |
| 172 | 172 |
| 173 // AsyncApiFunction: | 173 // AsyncApiFunction: |
| 174 virtual bool Prepare() OVERRIDE; | 174 virtual bool Prepare() OVERRIDE; |
| 175 virtual bool Respond() OVERRIDE; | 175 virtual bool Respond() OVERRIDE; |
| 176 virtual void Work() OVERRIDE; | 176 virtual void Work() OVERRIDE; |
| 177 | 177 |
| 178 private: | 178 private: |
| 179 #if defined(OS_CHROMEOS) | 179 #if defined(OS_CHROMEOS) |
| 180 bool success_; | 180 bool success_; |
| 181 const base::BinaryValue* data_to_write_; // memory is owned by args_ | 181 const base::BinaryValue* data_to_write_; // memory is owned by args_ |
| 182 scoped_refptr<chromeos::BluetoothSocket> socket_; | 182 scoped_refptr<chromeos::BluetoothSocketPosix> socket_; |
| 183 #endif | 183 #endif |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 class BluetoothSetOutOfBandPairingDataFunction | 186 class BluetoothSetOutOfBandPairingDataFunction |
| 187 : public AsyncExtensionFunction { | 187 : public AsyncExtensionFunction { |
| 188 public: | 188 public: |
| 189 DECLARE_EXTENSION_FUNCTION_NAME( | 189 DECLARE_EXTENSION_FUNCTION_NAME( |
| 190 "experimental.bluetooth.setOutOfBandPairingData") | 190 "experimental.bluetooth.setOutOfBandPairingData") |
| 191 | 191 |
| 192 protected: | 192 protected: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 private: | 250 private: |
| 251 void OnSuccessCallback(); | 251 void OnSuccessCallback(); |
| 252 void OnErrorCallback(); | 252 void OnErrorCallback(); |
| 253 #endif | 253 #endif |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 } // namespace api | 256 } // namespace api |
| 257 } // namespace extensions | 257 } // namespace extensions |
| 258 | 258 |
| 259 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 259 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
| OLD | NEW |