1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h"
13 #include "extensions/browser/extension_function.h"
15 namespace extensions
{
17 namespace networking_private
{
19 extern const char kErrorInvalidNetworkGuid
[];
20 extern const char kErrorInvalidNetworkOperation
[];
21 extern const char kErrorNetworkUnavailable
[];
22 extern const char kErrorEncryptionError
[];
23 extern const char kErrorNotReady
[];
24 extern const char kErrorNotSupported
[];
25 extern const char kErrorSimLocked
[];
27 } // namespace networking_private
29 // Implements the chrome.networkingPrivate.getProperties method.
30 class NetworkingPrivateGetPropertiesFunction
: public AsyncExtensionFunction
{
32 NetworkingPrivateGetPropertiesFunction() {}
33 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getProperties",
34 NETWORKINGPRIVATE_GETPROPERTIES
);
37 ~NetworkingPrivateGetPropertiesFunction() override
;
39 // AsyncExtensionFunction overrides.
40 bool RunAsync() override
;
43 void Success(scoped_ptr
<base::DictionaryValue
> result
);
44 void Failure(const std::string
& error_name
);
46 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetPropertiesFunction
);
49 // Implements the chrome.networkingPrivate.getManagedProperties method.
50 class NetworkingPrivateGetManagedPropertiesFunction
51 : public AsyncExtensionFunction
{
53 NetworkingPrivateGetManagedPropertiesFunction() {}
54 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getManagedProperties",
55 NETWORKINGPRIVATE_GETMANAGEDPROPERTIES
);
58 ~NetworkingPrivateGetManagedPropertiesFunction() override
;
60 // AsyncExtensionFunction overrides.
61 bool RunAsync() override
;
64 void Success(scoped_ptr
<base::DictionaryValue
> result
);
65 void Failure(const std::string
& error
);
67 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetManagedPropertiesFunction
);
70 // Implements the chrome.networkingPrivate.getState method.
71 class NetworkingPrivateGetStateFunction
: public AsyncExtensionFunction
{
73 NetworkingPrivateGetStateFunction() {}
74 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getState",
75 NETWORKINGPRIVATE_GETSTATE
);
78 ~NetworkingPrivateGetStateFunction() override
;
80 // AsyncExtensionFunction overrides.
81 bool RunAsync() override
;
84 void Success(scoped_ptr
<base::DictionaryValue
> result
);
85 void Failure(const std::string
& error
);
87 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetStateFunction
);
90 // Implements the chrome.networkingPrivate.setProperties method.
91 class NetworkingPrivateSetPropertiesFunction
: public AsyncExtensionFunction
{
93 NetworkingPrivateSetPropertiesFunction() {}
94 DECLARE_EXTENSION_FUNCTION("networkingPrivate.setProperties",
95 NETWORKINGPRIVATE_SETPROPERTIES
);
98 ~NetworkingPrivateSetPropertiesFunction() override
;
100 // AsyncExtensionFunction overrides.
101 bool RunAsync() override
;
105 void Failure(const std::string
& error
);
107 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateSetPropertiesFunction
);
110 // Implements the chrome.networkingPrivate.createNetwork method.
111 class NetworkingPrivateCreateNetworkFunction
: public AsyncExtensionFunction
{
113 NetworkingPrivateCreateNetworkFunction() {}
114 DECLARE_EXTENSION_FUNCTION("networkingPrivate.createNetwork",
115 NETWORKINGPRIVATE_CREATENETWORK
);
118 ~NetworkingPrivateCreateNetworkFunction() override
;
120 // AsyncExtensionFunction overrides.
121 bool RunAsync() override
;
124 void Success(const std::string
& guid
);
125 void Failure(const std::string
& error
);
127 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateCreateNetworkFunction
);
130 // Implements the chrome.networkingPrivate.createNetwork method.
131 class NetworkingPrivateForgetNetworkFunction
: public AsyncExtensionFunction
{
133 NetworkingPrivateForgetNetworkFunction() {}
134 DECLARE_EXTENSION_FUNCTION("networkingPrivate.forgetNetwork",
135 NETWORKINGPRIVATE_FORGETNETWORK
);
138 ~NetworkingPrivateForgetNetworkFunction() override
;
140 // AsyncExtensionFunction overrides.
141 bool RunAsync() override
;
145 void Failure(const std::string
& error
);
147 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateForgetNetworkFunction
);
150 // Implements the chrome.networkingPrivate.getNetworks method.
151 class NetworkingPrivateGetNetworksFunction
: public AsyncExtensionFunction
{
153 NetworkingPrivateGetNetworksFunction() {}
154 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getNetworks",
155 NETWORKINGPRIVATE_GETNETWORKS
);
158 ~NetworkingPrivateGetNetworksFunction() override
;
160 // AsyncExtensionFunction overrides.
161 bool RunAsync() override
;
164 void Success(scoped_ptr
<base::ListValue
> network_list
);
165 void Failure(const std::string
& error
);
167 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetNetworksFunction
);
170 // Implements the chrome.networkingPrivate.getVisibleNetworks method.
171 class NetworkingPrivateGetVisibleNetworksFunction
172 : public AsyncExtensionFunction
{
174 NetworkingPrivateGetVisibleNetworksFunction() {}
175 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getVisibleNetworks",
176 NETWORKINGPRIVATE_GETVISIBLENETWORKS
);
179 ~NetworkingPrivateGetVisibleNetworksFunction() override
;
181 // AsyncExtensionFunction overrides.
182 bool RunAsync() override
;
185 void Success(scoped_ptr
<base::ListValue
> network_list
);
186 void Failure(const std::string
& error
);
188 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetVisibleNetworksFunction
);
191 // Implements the chrome.networkingPrivate.getEnabledNetworkTypes method.
192 class NetworkingPrivateGetEnabledNetworkTypesFunction
193 : public SyncExtensionFunction
{
195 NetworkingPrivateGetEnabledNetworkTypesFunction() {}
196 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getEnabledNetworkTypes",
197 NETWORKINGPRIVATE_GETENABLEDNETWORKTYPES
);
200 ~NetworkingPrivateGetEnabledNetworkTypesFunction() override
;
202 // SyncExtensionFunction overrides.
203 bool RunSync() override
;
206 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetEnabledNetworkTypesFunction
);
209 // Implements the chrome.networkingPrivate.getDeviceStates method.
210 class NetworkingPrivateGetDeviceStatesFunction
: public SyncExtensionFunction
{
212 NetworkingPrivateGetDeviceStatesFunction() {}
213 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getDeviceStates",
214 NETWORKINGPRIVATE_GETDEVICESTATES
);
217 ~NetworkingPrivateGetDeviceStatesFunction() override
;
219 // SyncExtensionFunction overrides.
220 bool RunSync() override
;
223 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetDeviceStatesFunction
);
226 // Implements the chrome.networkingPrivate.enableNetworkType method.
227 class NetworkingPrivateEnableNetworkTypeFunction
228 : public SyncExtensionFunction
{
230 NetworkingPrivateEnableNetworkTypeFunction() {}
231 DECLARE_EXTENSION_FUNCTION("networkingPrivate.enableNetworkType",
232 NETWORKINGPRIVATE_ENABLENETWORKTYPE
);
235 ~NetworkingPrivateEnableNetworkTypeFunction() override
;
237 // SyncExtensionFunction overrides.
238 bool RunSync() override
;
241 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateEnableNetworkTypeFunction
);
244 // Implements the chrome.networkingPrivate.disableNetworkType method.
245 class NetworkingPrivateDisableNetworkTypeFunction
246 : public SyncExtensionFunction
{
248 NetworkingPrivateDisableNetworkTypeFunction() {}
249 DECLARE_EXTENSION_FUNCTION("networkingPrivate.disableNetworkType",
250 NETWORKINGPRIVATE_DISABLENETWORKTYPE
);
253 ~NetworkingPrivateDisableNetworkTypeFunction() override
;
255 // SyncExtensionFunction overrides.
256 bool RunSync() override
;
259 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDisableNetworkTypeFunction
);
262 // Implements the chrome.networkingPrivate.requestNetworkScan method.
263 class NetworkingPrivateRequestNetworkScanFunction
264 : public SyncExtensionFunction
{
266 NetworkingPrivateRequestNetworkScanFunction() {}
267 DECLARE_EXTENSION_FUNCTION("networkingPrivate.requestNetworkScan",
268 NETWORKINGPRIVATE_REQUESTNETWORKSCAN
);
271 ~NetworkingPrivateRequestNetworkScanFunction() override
;
273 // SyncExtensionFunction overrides.
274 bool RunSync() override
;
277 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateRequestNetworkScanFunction
);
280 // Implements the chrome.networkingPrivate.startConnect method.
281 class NetworkingPrivateStartConnectFunction
: public AsyncExtensionFunction
{
283 NetworkingPrivateStartConnectFunction() {}
284 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startConnect",
285 NETWORKINGPRIVATE_STARTCONNECT
);
288 ~NetworkingPrivateStartConnectFunction() override
;
290 // AsyncExtensionFunction overrides.
291 bool RunAsync() override
;
295 void Failure(const std::string
& error
);
297 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartConnectFunction
);
300 // Implements the chrome.networkingPrivate.startDisconnect method.
301 class NetworkingPrivateStartDisconnectFunction
: public AsyncExtensionFunction
{
303 NetworkingPrivateStartDisconnectFunction() {}
304 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startDisconnect",
305 NETWORKINGPRIVATE_STARTDISCONNECT
);
308 ~NetworkingPrivateStartDisconnectFunction() override
;
310 // AsyncExtensionFunction overrides.
311 bool RunAsync() override
;
315 void Failure(const std::string
& error
);
317 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartDisconnectFunction
);
320 // Implements the chrome.networkingPrivate.startActivate method.
321 class NetworkingPrivateStartActivateFunction
: public AsyncExtensionFunction
{
323 NetworkingPrivateStartActivateFunction() {}
324 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startActivate",
325 NETWORKINGPRIVATE_STARTACTIVATE
);
328 ~NetworkingPrivateStartActivateFunction() override
;
330 // AsyncExtensionFunction overrides.
331 bool RunAsync() override
;
335 void Failure(const std::string
& error
);
337 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartActivateFunction
);
340 // Implements the chrome.networkingPrivate.verifyDestination method.
341 class NetworkingPrivateVerifyDestinationFunction
342 : public AsyncExtensionFunction
{
344 NetworkingPrivateVerifyDestinationFunction() {}
345 DECLARE_EXTENSION_FUNCTION("networkingPrivate.verifyDestination",
346 NETWORKINGPRIVATE_VERIFYDESTINATION
);
349 ~NetworkingPrivateVerifyDestinationFunction() override
;
351 // AsyncExtensionFunction overrides.
352 bool RunAsync() override
;
354 void Success(bool result
);
355 void Failure(const std::string
& error
);
358 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateVerifyDestinationFunction
);
361 // Implements the chrome.networkingPrivate.verifyAndEncryptCredentials method.
362 class NetworkingPrivateVerifyAndEncryptCredentialsFunction
363 : public AsyncExtensionFunction
{
365 NetworkingPrivateVerifyAndEncryptCredentialsFunction() {}
366 DECLARE_EXTENSION_FUNCTION("networkingPrivate.verifyAndEncryptCredentials",
367 NETWORKINGPRIVATE_VERIFYANDENCRYPTCREDENTIALS
);
370 ~NetworkingPrivateVerifyAndEncryptCredentialsFunction() override
;
372 // AsyncExtensionFunction overrides.
373 bool RunAsync() override
;
375 void Success(const std::string
& result
);
376 void Failure(const std::string
& error
);
379 DISALLOW_COPY_AND_ASSIGN(
380 NetworkingPrivateVerifyAndEncryptCredentialsFunction
);
383 // Implements the chrome.networkingPrivate.verifyAndEncryptData method.
384 class NetworkingPrivateVerifyAndEncryptDataFunction
385 : public AsyncExtensionFunction
{
387 NetworkingPrivateVerifyAndEncryptDataFunction() {}
388 DECLARE_EXTENSION_FUNCTION("networkingPrivate.verifyAndEncryptData",
389 NETWORKINGPRIVATE_VERIFYANDENCRYPTDATA
);
392 ~NetworkingPrivateVerifyAndEncryptDataFunction() override
;
394 // AsyncExtensionFunction overrides.
395 bool RunAsync() override
;
397 void Success(const std::string
& result
);
398 void Failure(const std::string
& error
);
401 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateVerifyAndEncryptDataFunction
);
404 // Implements the chrome.networkingPrivate.setWifiTDLSEnabledState method.
405 class NetworkingPrivateSetWifiTDLSEnabledStateFunction
406 : public AsyncExtensionFunction
{
408 NetworkingPrivateSetWifiTDLSEnabledStateFunction() {}
409 DECLARE_EXTENSION_FUNCTION("networkingPrivate.setWifiTDLSEnabledState",
410 NETWORKINGPRIVATE_SETWIFITDLSENABLEDSTATE
);
413 ~NetworkingPrivateSetWifiTDLSEnabledStateFunction() override
;
415 // AsyncExtensionFunction overrides.
416 bool RunAsync() override
;
418 void Success(const std::string
& result
);
419 void Failure(const std::string
& error
);
422 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateSetWifiTDLSEnabledStateFunction
);
425 // Implements the chrome.networkingPrivate.getWifiTDLSStatus method.
426 class NetworkingPrivateGetWifiTDLSStatusFunction
427 : public AsyncExtensionFunction
{
429 NetworkingPrivateGetWifiTDLSStatusFunction() {}
430 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getWifiTDLSStatus",
431 NETWORKINGPRIVATE_GETWIFITDLSSTATUS
);
434 ~NetworkingPrivateGetWifiTDLSStatusFunction() override
;
436 // AsyncExtensionFunction overrides.
437 bool RunAsync() override
;
439 void Success(const std::string
& result
);
440 void Failure(const std::string
& error
);
443 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetWifiTDLSStatusFunction
);
446 class NetworkingPrivateGetCaptivePortalStatusFunction
447 : public AsyncExtensionFunction
{
449 NetworkingPrivateGetCaptivePortalStatusFunction() {}
450 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getCaptivePortalStatus",
451 NETWORKINGPRIVATE_GETCAPTIVEPORTALSTATUS
);
453 // AsyncExtensionFunction overrides.
454 bool RunAsync() override
;
457 ~NetworkingPrivateGetCaptivePortalStatusFunction() override
;
460 void Success(const std::string
& result
);
461 void Failure(const std::string
& error
);
463 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetCaptivePortalStatusFunction
);
466 class NetworkingPrivateUnlockCellularSimFunction
467 : public AsyncExtensionFunction
{
469 NetworkingPrivateUnlockCellularSimFunction() {}
470 DECLARE_EXTENSION_FUNCTION("networkingPrivate.unlockCellularSim",
471 NETWORKINGPRIVATE_UNLOCKCELLULARSIM
);
473 // AsyncExtensionFunction overrides.
474 bool RunAsync() override
;
477 ~NetworkingPrivateUnlockCellularSimFunction() override
;
481 void Failure(const std::string
& error
);
483 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateUnlockCellularSimFunction
);
486 class NetworkingPrivateSetCellularSimStateFunction
487 : public AsyncExtensionFunction
{
489 NetworkingPrivateSetCellularSimStateFunction() {}
490 DECLARE_EXTENSION_FUNCTION("networkingPrivate.setCellularSimState",
491 NETWORKINGPRIVATE_SETCELLULARSIMSTATE
);
493 // AsyncExtensionFunction overrides.
494 bool RunAsync() override
;
497 ~NetworkingPrivateSetCellularSimStateFunction() override
;
501 void Failure(const std::string
& error
);
503 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateSetCellularSimStateFunction
);
506 } // namespace extensions
508 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_