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" | 12 #include "base/memory/ref_counted.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
16 class BluetoothAdapter; | 16 class BluetoothAdapter; |
17 class BluetoothDevice; | 17 class BluetoothDevice; |
18 class BluetoothSocket; | 18 class BluetoothSocket; |
19 class ExtensionBluetoothEventRouter; | 19 class ExtensionBluetoothEventRouter; |
asargent_no_longer_on_chrome
2012/05/15 22:01:47
nit: can you get rid of any of these forward decla
bryeung
2012/05/15 23:24:15
Good catch. Done.
| |
20 | 20 |
21 } // namespace chromeos | 21 } // namespace chromeos |
22 #endif | 22 #endif |
23 | 23 |
24 namespace extensions { | 24 namespace extensions { |
25 namespace api { | 25 namespace api { |
26 | 26 |
27 class BluetoothExtensionFunction : public SyncExtensionFunction { | 27 class BluetoothIsAvailableFunction : public SyncExtensionFunction { |
28 protected: | |
29 virtual ~BluetoothExtensionFunction() {} | |
30 | |
31 #if defined(OS_CHROMEOS) | |
32 chromeos::ExtensionBluetoothEventRouter* event_router(); | |
33 const chromeos::BluetoothAdapter* adapter() const; | |
34 chromeos::BluetoothAdapter* GetMutableAdapter(); | |
35 #endif | |
36 }; | |
37 | |
38 class AsyncBluetoothExtensionFunction : public AsyncExtensionFunction { | |
39 protected: | |
40 virtual ~AsyncBluetoothExtensionFunction() {} | |
41 | |
42 #if defined(OS_CHROMEOS) | |
43 chromeos::ExtensionBluetoothEventRouter* event_router(); | |
44 const chromeos::BluetoothAdapter* adapter() const; | |
45 chromeos::BluetoothAdapter* GetMutableAdapter(); | |
46 #endif | |
47 }; | |
48 | |
49 class BluetoothIsAvailableFunction : public BluetoothExtensionFunction { | |
50 public: | 28 public: |
51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") | 29 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") |
52 | 30 |
53 protected: | 31 protected: |
54 virtual ~BluetoothIsAvailableFunction() {} | 32 virtual ~BluetoothIsAvailableFunction() {} |
55 | 33 |
56 // ExtensionFunction: | 34 // ExtensionFunction: |
57 virtual bool RunImpl() OVERRIDE; | 35 virtual bool RunImpl() OVERRIDE; |
58 }; | 36 }; |
59 | 37 |
60 class BluetoothIsPoweredFunction : public BluetoothExtensionFunction { | 38 class BluetoothIsPoweredFunction : public SyncExtensionFunction { |
61 public: | 39 public: |
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isPowered") | 40 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isPowered") |
63 | 41 |
64 protected: | 42 protected: |
65 virtual ~BluetoothIsPoweredFunction() {} | 43 virtual ~BluetoothIsPoweredFunction() {} |
66 | 44 |
67 // ExtensionFunction: | 45 // ExtensionFunction: |
68 virtual bool RunImpl() OVERRIDE; | 46 virtual bool RunImpl() OVERRIDE; |
69 }; | 47 }; |
70 | 48 |
71 class BluetoothGetAddressFunction : public BluetoothExtensionFunction { | 49 class BluetoothGetAddressFunction : public SyncExtensionFunction { |
72 public: | 50 public: |
73 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getAddress") | 51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getAddress") |
74 | 52 |
75 protected: | 53 protected: |
76 virtual ~BluetoothGetAddressFunction() {} | 54 virtual ~BluetoothGetAddressFunction() {} |
77 | 55 |
78 // ExtensionFunction: | 56 // ExtensionFunction: |
79 virtual bool RunImpl() OVERRIDE; | 57 virtual bool RunImpl() OVERRIDE; |
80 }; | 58 }; |
81 | 59 |
82 class BluetoothGetDevicesWithServiceUUIDFunction | 60 class BluetoothGetDevicesWithServiceUUIDFunction |
83 : public BluetoothExtensionFunction { | 61 : public SyncExtensionFunction { |
84 public: | 62 public: |
85 DECLARE_EXTENSION_FUNCTION_NAME( | 63 DECLARE_EXTENSION_FUNCTION_NAME( |
86 "experimental.bluetooth.getDevicesWithServiceUUID") | 64 "experimental.bluetooth.getDevicesWithServiceUUID") |
87 | 65 |
88 protected: | 66 protected: |
89 virtual ~BluetoothGetDevicesWithServiceUUIDFunction() {} | 67 virtual ~BluetoothGetDevicesWithServiceUUIDFunction() {} |
90 | 68 |
91 // ExtensionFunction: | 69 // ExtensionFunction: |
92 virtual bool RunImpl() OVERRIDE; | 70 virtual bool RunImpl() OVERRIDE; |
93 }; | 71 }; |
94 | 72 |
95 class BluetoothGetDevicesWithServiceNameFunction | 73 class BluetoothGetDevicesWithServiceNameFunction |
96 : public AsyncBluetoothExtensionFunction { | 74 : public AsyncExtensionFunction { |
97 public: | 75 public: |
98 DECLARE_EXTENSION_FUNCTION_NAME( | 76 DECLARE_EXTENSION_FUNCTION_NAME( |
99 "experimental.bluetooth.getDevicesWithServiceName") | 77 "experimental.bluetooth.getDevicesWithServiceName") |
100 | 78 |
101 #if defined(OS_CHROMEOS) | 79 #if defined(OS_CHROMEOS) |
102 BluetoothGetDevicesWithServiceNameFunction(); | 80 BluetoothGetDevicesWithServiceNameFunction(); |
103 #endif | 81 #endif |
104 | 82 |
105 protected: | 83 protected: |
106 virtual ~BluetoothGetDevicesWithServiceNameFunction() {} | 84 virtual ~BluetoothGetDevicesWithServiceNameFunction() {} |
107 | 85 |
108 // ExtensionFunction: | 86 // ExtensionFunction: |
109 virtual bool RunImpl() OVERRIDE; | 87 virtual bool RunImpl() OVERRIDE; |
110 | 88 |
89 private: | |
111 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
112 private: | |
113 void AddDeviceIfTrue( | 91 void AddDeviceIfTrue( |
114 ListValue* list, const chromeos::BluetoothDevice* device, bool result); | 92 ListValue* list, const chromeos::BluetoothDevice* device, bool result); |
115 | 93 |
116 int callbacks_pending_; | 94 int callbacks_pending_; |
117 #endif | 95 #endif |
118 }; | 96 }; |
119 | 97 |
120 class BluetoothConnectFunction : public AsyncBluetoothExtensionFunction { | 98 class BluetoothConnectFunction : public AsyncExtensionFunction { |
121 public: | 99 public: |
122 virtual bool RunImpl() OVERRIDE; | 100 virtual bool RunImpl() OVERRIDE; |
123 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") | 101 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") |
124 | 102 |
125 private: | 103 private: |
126 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
127 void ConnectToServiceCallback( | 105 void ConnectToServiceCallback( |
128 const chromeos::BluetoothDevice* device, | 106 const chromeos::BluetoothDevice* device, |
129 const std::string& service_uuid, | 107 const std::string& service_uuid, |
130 scoped_refptr<chromeos::BluetoothSocket> socket); | 108 scoped_refptr<chromeos::BluetoothSocket> socket); |
131 #endif | 109 #endif |
132 }; | 110 }; |
133 | 111 |
134 class BluetoothDisconnectFunction : public BluetoothExtensionFunction { | 112 class BluetoothDisconnectFunction : public SyncExtensionFunction { |
135 public: | 113 public: |
136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") | 114 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") |
137 | 115 |
138 protected: | 116 protected: |
139 virtual ~BluetoothDisconnectFunction() {} | 117 virtual ~BluetoothDisconnectFunction() {} |
140 | 118 |
141 // ExtensionFunction: | 119 // ExtensionFunction: |
142 virtual bool RunImpl() OVERRIDE; | 120 virtual bool RunImpl() OVERRIDE; |
143 }; | 121 }; |
144 | 122 |
145 class BluetoothReadFunction : public BluetoothExtensionFunction { | 123 class BluetoothReadFunction : public SyncExtensionFunction { |
146 public: | 124 public: |
147 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.read") | 125 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.read") |
148 | 126 |
149 protected: | 127 protected: |
150 virtual ~BluetoothReadFunction() {} | 128 virtual ~BluetoothReadFunction() {} |
151 | 129 |
152 // ExtensionFunction: | 130 // ExtensionFunction: |
153 virtual bool RunImpl() OVERRIDE; | 131 virtual bool RunImpl() OVERRIDE; |
154 }; | 132 }; |
155 | 133 |
156 class BluetoothSetOutOfBandPairingDataFunction | 134 class BluetoothSetOutOfBandPairingDataFunction |
157 : public BluetoothExtensionFunction { | 135 : public SyncExtensionFunction { |
158 public: | 136 public: |
159 DECLARE_EXTENSION_FUNCTION_NAME( | 137 DECLARE_EXTENSION_FUNCTION_NAME( |
160 "experimental.bluetooth.setOutOfBandPairingData") | 138 "experimental.bluetooth.setOutOfBandPairingData") |
161 | 139 |
162 protected: | 140 protected: |
163 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} | 141 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} |
164 | 142 |
165 // ExtensionFunction: | 143 // ExtensionFunction: |
166 virtual bool RunImpl() OVERRIDE; | 144 virtual bool RunImpl() OVERRIDE; |
167 }; | 145 }; |
168 | 146 |
169 class BluetoothGetOutOfBandPairingDataFunction | 147 class BluetoothGetOutOfBandPairingDataFunction |
170 : public BluetoothExtensionFunction { | 148 : public SyncExtensionFunction { |
171 public: | 149 public: |
172 DECLARE_EXTENSION_FUNCTION_NAME( | 150 DECLARE_EXTENSION_FUNCTION_NAME( |
173 "experimental.bluetooth.getOutOfBandPairingData") | 151 "experimental.bluetooth.getOutOfBandPairingData") |
174 | 152 |
175 protected: | 153 protected: |
176 virtual ~BluetoothGetOutOfBandPairingDataFunction() {} | 154 virtual ~BluetoothGetOutOfBandPairingDataFunction() {} |
177 | 155 |
178 // ExtensionFunction: | 156 // ExtensionFunction: |
179 virtual bool RunImpl() OVERRIDE; | 157 virtual bool RunImpl() OVERRIDE; |
180 }; | 158 }; |
181 | 159 |
182 class BluetoothWriteFunction : public BluetoothExtensionFunction { | 160 class BluetoothWriteFunction : public SyncExtensionFunction { |
183 public: | 161 public: |
184 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") | 162 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") |
185 | 163 |
186 private: | 164 private: |
187 virtual ~BluetoothWriteFunction() {} | 165 virtual ~BluetoothWriteFunction() {} |
188 | 166 |
189 // ExtensionFunction: | 167 // ExtensionFunction: |
190 virtual bool RunImpl() OVERRIDE; | 168 virtual bool RunImpl() OVERRIDE; |
191 }; | 169 }; |
192 | 170 |
193 } // namespace api | 171 } // namespace api |
194 } // namespace extensions | 172 } // namespace extensions |
195 | 173 |
196 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 174 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
OLD | NEW |