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 // These classes implement the chrome.networkingPrivate JavaScript extension
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
9 #define CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
13 #include "base/memory/ref_counted.h"
14 #include "base/values.h"
15 #include "chrome/browser/extensions/chrome_extension_function.h"
16 #include "chromeos/dbus/dbus_method_call_status.h"
17 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
19 // Implements the chrome.networkingPrivate.getProperties method.
20 class NetworkingPrivateGetPropertiesFunction
21 : public ChromeAsyncExtensionFunction {
23 NetworkingPrivateGetPropertiesFunction() {}
24 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getProperties",
25 NETWORKINGPRIVATE_GETPROPERTIES);
28 virtual ~NetworkingPrivateGetPropertiesFunction();
30 // AsyncExtensionFunction overrides.
31 virtual bool RunImpl() OVERRIDE;
34 void GetPropertiesSuccess(const std::string& service_path,
35 const base::DictionaryValue& result);
36 void GetPropertiesFailed(const std::string& error_name,
37 scoped_ptr<base::DictionaryValue> error_data);
38 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetPropertiesFunction);
41 // Implements the chrome.networkingPrivate.getManagedProperties method.
42 class NetworkingPrivateGetManagedPropertiesFunction
43 : public ChromeAsyncExtensionFunction {
45 NetworkingPrivateGetManagedPropertiesFunction() {}
46 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getManagedProperties",
47 NETWORKINGPRIVATE_GETMANAGEDPROPERTIES);
50 virtual ~NetworkingPrivateGetManagedPropertiesFunction();
52 // AsyncExtensionFunction overrides.
53 virtual bool RunImpl() OVERRIDE;
56 // Callbacks for ManagedNetworkConfigurationHandler::GetManagedProperties.
57 void Success(const std::string& service_path,
58 const base::DictionaryValue& result);
59 void Failure(const std::string& error_name,
60 scoped_ptr<base::DictionaryValue> error_data);
62 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetManagedPropertiesFunction);
65 // Implements the chrome.networkingPrivate.getState method.
66 class NetworkingPrivateGetStateFunction : public ChromeAsyncExtensionFunction {
68 NetworkingPrivateGetStateFunction() {}
69 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getState",
70 NETWORKINGPRIVATE_GETSTATE);
73 virtual ~NetworkingPrivateGetStateFunction();
75 // AsyncExtensionFunction overrides.
76 virtual bool RunImpl() OVERRIDE;
79 void Success(const std::string& service_path,
80 const base::DictionaryValue& result);
81 void Failure(const std::string& error_name,
82 scoped_ptr<base::DictionaryValue> error_data);
84 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetStateFunction);
87 // Implements the chrome.networkingPrivate.setProperties method.
88 class NetworkingPrivateSetPropertiesFunction
89 : public ChromeAsyncExtensionFunction {
91 NetworkingPrivateSetPropertiesFunction() {}
92 DECLARE_EXTENSION_FUNCTION("networkingPrivate.setProperties",
93 NETWORKINGPRIVATE_SETPROPERTIES);
96 virtual ~NetworkingPrivateSetPropertiesFunction();
98 // AsyncExtensionFunction overrides.
99 virtual bool RunImpl() OVERRIDE;
102 void ErrorCallback(const std::string& error_name,
103 const scoped_ptr<base::DictionaryValue> error_data);
104 void ResultCallback();
105 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateSetPropertiesFunction);
108 // Implements the chrome.networkingPrivate.createNetwork method.
109 class NetworkingPrivateCreateNetworkFunction
110 : public ChromeAsyncExtensionFunction {
112 NetworkingPrivateCreateNetworkFunction() {}
113 DECLARE_EXTENSION_FUNCTION("networkingPrivate.createNetwork",
114 NETWORKINGPRIVATE_CREATENETWORK);
117 virtual ~NetworkingPrivateCreateNetworkFunction();
119 // AsyncExtensionFunction overrides.
120 virtual bool RunImpl() OVERRIDE;
123 void ErrorCallback(const std::string& error_name,
124 const scoped_ptr<base::DictionaryValue> error_data);
125 void ResultCallback(const std::string& guid);
126 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateCreateNetworkFunction);
129 // Implements the chrome.networkingPrivate.getVisibleNetworks method.
130 class NetworkingPrivateGetVisibleNetworksFunction
131 : public ChromeAsyncExtensionFunction {
133 NetworkingPrivateGetVisibleNetworksFunction() {}
134 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getVisibleNetworks",
135 NETWORKINGPRIVATE_GETVISIBLENETWORKS);
138 virtual ~NetworkingPrivateGetVisibleNetworksFunction();
140 // AsyncExtensionFunction overrides.
141 virtual bool RunImpl() OVERRIDE;
144 void ResultCallback(const base::ListValue& network_list);
146 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetVisibleNetworksFunction);
149 // Implements the chrome.networkingPrivate.getEnabledNetworkTypes method.
150 class NetworkingPrivateGetEnabledNetworkTypesFunction
151 : public ChromeSyncExtensionFunction {
153 NetworkingPrivateGetEnabledNetworkTypesFunction() {}
154 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getEnabledNetworkTypes",
155 NETWORKINGPRIVATE_GETENABLEDNETWORKTYPES);
158 virtual ~NetworkingPrivateGetEnabledNetworkTypesFunction();
160 // SyncExtensionFunction overrides.
161 virtual bool RunImpl() OVERRIDE;
164 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetEnabledNetworkTypesFunction);
167 // Implements the chrome.networkingPrivate.enableNetworkType method.
168 class NetworkingPrivateEnableNetworkTypeFunction
169 : public ChromeSyncExtensionFunction {
171 NetworkingPrivateEnableNetworkTypeFunction() {}
172 DECLARE_EXTENSION_FUNCTION("networkingPrivate.enableNetworkType",
173 NETWORKINGPRIVATE_ENABLENETWORKTYPE);
176 virtual ~NetworkingPrivateEnableNetworkTypeFunction();
178 // SyncExtensionFunction overrides.
179 virtual bool RunImpl() OVERRIDE;
182 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateEnableNetworkTypeFunction);
185 // Implements the chrome.networkingPrivate.disableNetworkType method.
186 class NetworkingPrivateDisableNetworkTypeFunction
187 : public ChromeSyncExtensionFunction {
189 NetworkingPrivateDisableNetworkTypeFunction() {}
190 DECLARE_EXTENSION_FUNCTION("networkingPrivate.disableNetworkType",
191 NETWORKINGPRIVATE_DISABLENETWORKTYPE);
194 virtual ~NetworkingPrivateDisableNetworkTypeFunction();
196 // SyncExtensionFunction overrides.
197 virtual bool RunImpl() OVERRIDE;
200 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDisableNetworkTypeFunction);
203 // Implements the chrome.networkingPrivate.requestNetworkScan method.
204 class NetworkingPrivateRequestNetworkScanFunction
205 : public ChromeSyncExtensionFunction {
207 NetworkingPrivateRequestNetworkScanFunction() {}
208 DECLARE_EXTENSION_FUNCTION("networkingPrivate.requestNetworkScan",
209 NETWORKINGPRIVATE_REQUESTNETWORKSCAN);
212 virtual ~NetworkingPrivateRequestNetworkScanFunction();
214 // SyncExtensionFunction overrides.
215 virtual bool RunImpl() OVERRIDE;
218 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateRequestNetworkScanFunction);
222 // Implements the chrome.networkingPrivate.startConnect method.
223 class NetworkingPrivateStartConnectFunction
224 : public ChromeAsyncExtensionFunction {
226 NetworkingPrivateStartConnectFunction() {}
227 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startConnect",
228 NETWORKINGPRIVATE_STARTCONNECT);
231 virtual ~NetworkingPrivateStartConnectFunction();
233 // AsyncExtensionFunction overrides.
234 virtual bool RunImpl() OVERRIDE;
237 // Called when the request to connect succeeds. Doesn't mean that the connect
238 // itself succeeded, just that the request did.
239 void ConnectionStartSuccess();
241 void ConnectionStartFailed(
242 const std::string& error_name,
243 const scoped_ptr<base::DictionaryValue> error_data);
245 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartConnectFunction);
248 // Implements the chrome.networkingPrivate.startDisconnect method.
249 class NetworkingPrivateStartDisconnectFunction
250 : public ChromeAsyncExtensionFunction {
252 NetworkingPrivateStartDisconnectFunction() {}
253 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startDisconnect",
254 NETWORKINGPRIVATE_STARTDISCONNECT);
257 virtual ~NetworkingPrivateStartDisconnectFunction();
259 // AsyncExtensionFunction overrides.
260 virtual bool RunImpl() OVERRIDE;
263 // Called when the request to disconnect succeeds. Doesn't mean that the
264 // disconnect itself succeeded, just that the request did.
265 void DisconnectionStartSuccess();
267 void DisconnectionStartFailed(
268 const std::string& error_name,
269 const scoped_ptr<base::DictionaryValue> error_data);
271 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartDisconnectFunction);
274 // Implements the chrome.networkingPrivate.verifyDestination method.
275 class NetworkingPrivateVerifyDestinationFunction
276 : public ChromeAsyncExtensionFunction {
278 NetworkingPrivateVerifyDestinationFunction() {}
279 DECLARE_EXTENSION_FUNCTION("networkingPrivate.verifyDestination",
280 NETWORKINGPRIVATE_VERIFYDESTINATION);
283 virtual ~NetworkingPrivateVerifyDestinationFunction();
285 // AsyncExtensionFunction overrides.
286 virtual bool RunImpl() OVERRIDE;
288 void ResultCallback(bool result);
289 void ErrorCallback(const std::string& error_name, const std::string& error);
292 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateVerifyDestinationFunction);
295 // Implements the chrome.networkingPrivate.verifyAndEncryptCredentials method.
296 class NetworkingPrivateVerifyAndEncryptCredentialsFunction
297 : public ChromeAsyncExtensionFunction {
299 NetworkingPrivateVerifyAndEncryptCredentialsFunction() {}
300 DECLARE_EXTENSION_FUNCTION("networkingPrivate.verifyAndEncryptCredentials",
301 NETWORKINGPRIVATE_VERIFYANDENCRYPTCREDENTIALS);
304 virtual ~NetworkingPrivateVerifyAndEncryptCredentialsFunction();
306 // AsyncExtensionFunction overrides.
307 virtual bool RunImpl() OVERRIDE;
309 void ResultCallback(const std::string& result);
310 void ErrorCallback(const std::string& error_name, const std::string& error);
313 DISALLOW_COPY_AND_ASSIGN(
314 NetworkingPrivateVerifyAndEncryptCredentialsFunction);
317 // Implements the chrome.networkingPrivate.verifyAndEncryptData method.
318 class NetworkingPrivateVerifyAndEncryptDataFunction
319 : public ChromeAsyncExtensionFunction {
321 NetworkingPrivateVerifyAndEncryptDataFunction() {}
322 DECLARE_EXTENSION_FUNCTION("networkingPrivate.verifyAndEncryptData",
323 NETWORKINGPRIVATE_VERIFYANDENCRYPTDATA);
326 virtual ~NetworkingPrivateVerifyAndEncryptDataFunction();
328 // AsyncExtensionFunction overrides.
329 virtual bool RunImpl() OVERRIDE;
331 void ResultCallback(const std::string& result);
332 void ErrorCallback(const std::string& error_name, const std::string& error);
335 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateVerifyAndEncryptDataFunction);
338 // Implements the chrome.networkingPrivate.setWifiTDLSEnabledState method.
339 class NetworkingPrivateSetWifiTDLSEnabledStateFunction
340 : public ChromeAsyncExtensionFunction {
342 NetworkingPrivateSetWifiTDLSEnabledStateFunction() {}
343 DECLARE_EXTENSION_FUNCTION("networkingPrivate.setWifiTDLSEnabledState",
344 NETWORKINGPRIVATE_SETWIFITDLSENABLEDSTATE);
347 virtual ~NetworkingPrivateSetWifiTDLSEnabledStateFunction();
349 // AsyncExtensionFunction overrides.
350 virtual bool RunImpl() OVERRIDE;
352 void Success(const std::string& result);
353 void Failure(const std::string& error_name,
354 scoped_ptr<base::DictionaryValue> error_data);
357 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateSetWifiTDLSEnabledStateFunction);
360 // Implements the chrome.networkingPrivate.getWifiTDLSStatus method.
361 class NetworkingPrivateGetWifiTDLSStatusFunction
362 : public ChromeAsyncExtensionFunction {
364 NetworkingPrivateGetWifiTDLSStatusFunction() {}
365 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getWifiTDLSStatus",
366 NETWORKINGPRIVATE_GETWIFITDLSSTATUS);
369 virtual ~NetworkingPrivateGetWifiTDLSStatusFunction();
371 // AsyncExtensionFunction overrides.
372 virtual bool RunImpl() OVERRIDE;
374 void Success(const std::string& result);
375 void Failure(const std::string& error_name,
376 scoped_ptr<base::DictionaryValue> error_data);
379 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetWifiTDLSStatusFunction);
382 #endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_