1 // Copyright 2015 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 // The <code>chrome.networkingPrivate</code> API is used for configuring
6 // network connections (Cellular, Ethernet, VPN, WiFi or WiMAX). This private
7 // API is only valid if called from a browser or app associated with the
8 // primary user. See the Open Network Configuration (ONC) documentation for
9 // descriptions of properties:
10 // <a href="https://code.google.com/p/chromium/codesearch#chromium/src/components/onc/docs/onc_spec.html">
11 // src/components/onc/docs/onc_spec.html</a>, or the
12 // <a href="http://www.chromium.org/chromium-os/chromiumos-design-docs/open-network-configuration">
13 // Open Network Configuration</a> page at chromium.org.
15 // NOTE: Most dictionary properties and enum values use UpperCamelCase to match
16 // the ONC spec instead of the JavaScript lowerCamelCase convention.
18 // "State" properties describe just the ONC properties returned by
19 // $(ref:networkingPrivate.getState) and $(ref:networkingPrivate.getNetworks).
21 // "Config" properties describe just the ONC properties that can be configured
22 // through this API. NOTE: Not all configuration properties are exposed at this
23 // time, only those currently required by the Chrome Settings UI.
24 // TODO(stevenjb): Provide all configuration properties and types,
27 // TODO(stevenjb/pneubeck): Merge the ONC documentation with this document and
28 // use it as the ONC specification.
30 namespace networkingPrivate
{
31 enum ActivationStateType
{
32 Activated
, Activating
, NotActivated
, PartiallyActivated
35 enum CaptivePortalStatus
{
36 Unknown
, Offline
, Online
, Portal
, ProxyAuthRequired
39 enum ConnectionStateType
{
40 Connected
, Connecting
, NotConnected
43 enum DeviceStateType
{
44 // Device is available but not initialized.
46 // Device is intialized but not enabled.
48 // Enabled state has been requested but has not completed.
59 All
, Cellular
, Ethernet
, VPN
, Wireless
, WiFi
, WiMAX
62 enum ProxySettingsType
{
63 Direct
, Manual
, PAC
, WPAD
66 dictionary APNProperties
{
67 DOMString AccessPointName
;
69 DOMString? LocalizedName
;
75 dictionary CellularConfigProperties
{
79 // Specifies which carrier to use for Cellular configurations that support
80 // multiple carriers. May be set with $(ref:setProperties), but will be
81 // ignored by $(ref:createConfiguration).
85 dictionary CellularStateProperties
{
86 ActivationStateType? ActivationState
;
87 DOMString? NetworkTechnology
;
88 DOMString? RoamingState
;
93 dictionary DeviceStateProperties
{
94 // Set if the device is enabled. True if the device is currently scanning.
97 // The current state of the device.
98 DeviceStateType State
;
100 // The network type associated with the device (Cellular, Ethernet, WiFi, or
105 dictionary EthernetStateProperties
{
106 DOMString Authentication
;
109 dictionary IPConfigProperties
{
111 DOMString? IPAddress
;
112 DOMString
[]? NameServers
;
115 DOMString? WebProxyAutoDiscoveryUrl
;
118 dictionary IPSecProperties
{
119 DOMString AuthenticationType
;
122 dictionary ProxyLocation
{
127 dictionary ManualProxySettings
{
128 ProxyLocation? HTTPProxy
;
129 ProxyLocation? SecureHTTPProxy
;
130 ProxyLocation? FTPProxy
;
131 ProxyLocation? SOCKS
;
134 dictionary ProxySettings
{
135 ProxySettingsType Type
;
136 ManualProxySettings? Manual
;
137 DOMString
[]? ExcludeDomains
;
141 dictionary OpenVPNProperties
{
144 DOMString? UserAuthenticationType
;
148 dictionary ThirdPartyVPNProperties
{
149 DOMString ExtensionID
;
152 dictionary VPNConfigProperties
{
153 boolean? AutoConnect
;
155 OpenVPNProperties? OpenVPN
;
156 ThirdPartyVPNProperties? ThirdPartyVPN
;
160 dictionary VPNStateProperties
{
162 IPSecProperties? IPsec
;
163 ThirdPartyVPNProperties? ThirdPartyVPN
;
166 dictionary WiFiConfigProperties
{
167 boolean? AutoConnect
;
170 DOMString? Passphrase
;
175 dictionary WiFiStateProperties
{
177 long? SignalStrength
;
180 dictionary WiMaxConfigProperties
{
181 boolean? AutoConnect
;
184 dictionary WiMAXStateProperties
{
185 long? SignalStrength
;
188 dictionary NetworkConfigProperties
{
189 CellularConfigProperties? Cellular
;
191 IPConfigType? IPAddressConfigType
;
193 IPConfigType? NameServersConfigType
;
195 ProxySettings? ProxySettings
;
196 IPConfigProperties? StaticIPConfig
;
198 VPNConfigProperties? VPN
;
199 WiFiConfigProperties? WiFi
;
200 WiMaxConfigProperties? WiMAX
;
203 dictionary NetworkStateProperties
{
204 CellularStateProperties? Cellular
;
205 boolean? Connectable
;
206 ConnectionStateType? ConnectionState
;
207 EthernetStateProperties? Ethernet
;
208 DOMString? ErrorState
;
214 VPNStateProperties? VPN
;
215 WiFiStateProperties? WiFi
;
216 WiMAXStateProperties? WiMAX
;
219 dictionary VerificationProperties
{
220 // A string containing a PEM-encoded (including the 'BEGIN CERTIFICATE'
221 // header and 'END CERTIFICATE' footer) X.509 certificate for use in
222 // verifying the signed data.
223 DOMString certificate
;
225 // An array of PEM-encoded X.509 intermediate certificate authority
226 // certificates. Each PEM-encoded certificate is expected to have the
227 // 'BEGIN CERTIFICATE' header and 'END CERTIFICATE' footer.
228 DOMString
[]? intermediateCertificates
;
230 // A string containing a base64-encoded RSAPublicKey ASN.1 structure,
231 // representing the public key to be used by
232 // $(ref:verifyAndEncryptCredentials) and $(ref:verifyAndEncryptData)
236 // A string containing a base64-encoded random binary data for use in
237 // verifying the signed data.
240 // A string containing the identifying data string signed by the device.
241 DOMString signedData
;
243 // A string containing the serial number of the device.
244 DOMString deviceSerial
;
246 // A string containing the SSID of the device. Should be empty for new
248 DOMString deviceSsid
;
250 // A string containing the BSSID of the device. Should be empty for new
252 DOMString deviceBssid
;
255 dictionary NetworkFilter
{
256 // The type of networks to return.
257 NetworkType networkType
;
259 // If true, only include visible (physically connected or in-range)
260 // networks. Defaults to 'false'.
263 // If true, only include configured (saved) networks. Defaults to 'false'.
266 // Maximum number of networks to return. Defaults to 1000 if unspecified.
267 // Use 0 for no limit.
271 callback VoidCallback
= void();
272 callback BooleanCallback
= void(boolean result
);
273 callback StringCallback
= void(DOMString result
);
274 // TODO(stevenjb): Use NetworkProperties for |result| once defined.
275 callback GetPropertiesCallback
= void(object result
);
276 // TODO(stevenjb): Use ManagedNetworkProperties for |result| once defined.
277 callback GetManagedPropertiesCallback
= void(object result
);
278 callback GetStatePropertiesCallback
= void(NetworkStateProperties result
);
279 callback GetNetworksCallback
= void(NetworkStateProperties
[] result
);
280 callback GetDeviceStatesCallback
= void(DeviceStateProperties
[] result
);
281 callback GetEnabledNetworkTypesCallback
= void(NetworkType
[] result
);
282 callback CaptivePortalStatusCallback
= void(CaptivePortalStatus result
);
284 // These functions all report failures via chrome.runtime.lastError.
285 interface Functions
{
286 // Gets all the properties of the network with id networkGuid. Includes all
287 // properties of the network (read-only and read/write values).
288 // |networkGuid|: The GUID of the network to get properties for.
289 // |callback|: Called with the network properties when received.
290 static
void getProperties
(DOMString networkGuid
,
291 GetPropertiesCallback
callback);
293 // Gets the merged properties of the network with id networkGuid from the
294 // sources: User settings, shared settings, user policy, device policy and
295 // the currently active settings.
296 // |networkGuid|: The GUID of the network to get properties for.
297 // |callback|: Called with the managed network properties when received.
298 static
void getManagedProperties
(DOMString networkGuid
,
299 GetManagedPropertiesCallback
callback);
301 // Gets the cached read-only properties of the network with id networkGuid.
302 // This is meant to be a higher performance function than
303 // $(ref:getProperties), which requires a round trip to query the networking
304 // subsystem. The following properties are returned for all networks: GUID,
305 // Type, Name, WiFi.Security. Additional properties are provided for visible
306 // networks: ConnectionState, ErrorState, WiFi.SignalStrength,
307 // Cellular.NetworkTechnology, Cellular.ActivationState,
308 // Cellular.RoamingState.
309 // |networkGuid|: The GUID of the network to get properties for.
310 // |callback|: Called immediately with the network state properties.
311 static
void getState
(DOMString networkGuid
,
312 GetStatePropertiesCallback
callback);
314 // Sets the properties of the network with id networkGuid.
315 // |networkGuid|: The GUID of the network to set properties for.
316 // |properties|: The properties to set.
317 // |callback|: Called when the operation has completed.
318 static
void setProperties
(DOMString networkGuid
,
319 NetworkConfigProperties properties
,
320 optional VoidCallback
callback);
322 // Creates a new network configuration from properties. If a matching
323 // configured network already exists, this will fail. Otherwise returns the
324 // guid of the new network.
325 // |shared|: If true, share this network configuration with other users.
326 // |properties|: The properties to configure the new network with.
327 // |callback|: Called with the GUID for the new network configuration once
328 // the network has been created.
329 static
void createNetwork
(boolean shared
,
330 NetworkConfigProperties properties
,
331 optional StringCallback
callback);
333 // Forgets a network configuration by clearing any configured properties for
334 // the network with GUID 'networkGuid'. This may also include any other
335 // networks with matching identifiers (e.g. WiFi SSID and Security). If no
336 // such configuration exists, an error will be set and the operation will
338 // |networkGuid|: The GUID of the network to forget.
339 // |callback|: Called when the operation has completed.
340 static
void forgetNetwork
(DOMString networkGuid
,
341 optional VoidCallback
callback);
343 // Returns a list of network objects with the same properties provided by
344 // $(ref:networkingPrivate.getState). A filter is provided to specify the
345 // type of networks returned and to limit the number of networks. Networks
346 // are ordered by the system based on their priority, with connected or
347 // connecting networks listed first.
348 // |filter|: Describes which networks to return.
349 // |callback|: Called with a dictionary of networks and their state
350 // properties when received.
351 static
void getNetworks
(NetworkFilter filter
,
352 GetNetworksCallback
callback);
354 // Deprecated. Please use $(ref:networkingPrivate.getNetworks) with
355 // filter.visible = true instead.
356 [deprecated
="Use getNetworks."] static
void getVisibleNetworks
(
357 NetworkType networkType
,
358 GetNetworksCallback
callback);
360 // Deprecated. Please use $(ref:networkingPrivate.getDeviceStates) instead.
361 [deprecated
="Use getDeviceStates."] static
void getEnabledNetworkTypes
(
362 GetEnabledNetworkTypesCallback
callback);
364 // Returns a list of $(ref:networkingPrivate.DeviceStateProperties) objects.
365 // |callback|: Called with a list of devices and their state.
366 static
void getDeviceStates
(GetDeviceStatesCallback
callback);
368 // Enables any devices matching the specified network type. Note, the type
369 // might represent multiple network types (e.g. 'Wireless').
370 // |networkType|: The type of network to enable.
371 static
void enableNetworkType
(NetworkType networkType
);
373 // Disables any devices matching the specified network type. See note for
374 // $(ref:networkingPrivate.enableNetworkType).
375 // |networkType|: The type of network to disable.
376 static
void disableNetworkType
(NetworkType networkType
);
378 // Requests that the networking subsystem scan for new networks and
379 // update the list returned by $(ref:getVisibleNetworks). This is only a
380 // request: the network subsystem can choose to ignore it. If the list
381 // is updated, then the $(ref:onNetworkListChanged) event will be fired.
382 static
void requestNetworkScan
();
384 // Starts a connection to the network with networkGuid.
385 // |networkGuid|: The GUID of the network to connect to.
386 // |callback|: Called when the connect request has been sent. Note: the
387 // connection may not have completed. Observe $(ref:onNetworksChanged)
388 // to be notified when a network state changes.
389 static
void startConnect
(DOMString networkGuid
,
390 optional VoidCallback
callback);
392 // Starts a disconnect from the network with networkGuid.
393 // |networkGuid|: The GUID of the network to disconnect from.
394 // |callback|: Called when the disconnect request has been sent. See note
395 // for $(ref:startConnect).
396 static
void startDisconnect
(DOMString networkGuid
,
397 optional VoidCallback
callback);
399 // Starts activation of the Cellular network with networkGuid.
400 // |networkGuid|: The GUID of the Cellular network to activate.
401 // |carrier|: Optional name of carrier to activate.
402 // |callback|: Called when the activation request has been sent. See note
403 // for $(ref:startConnect).
404 static
void startActivate
(DOMString networkGuid
,
405 optional DOMString carrier
,
406 optional VoidCallback
callback);
408 // Verifies that the device is a trusted device.
409 // |properties|: Properties of the destination to use in verifying that it
410 // is a trusted device.
411 // |callback|: A callback function that indicates whether or not the device
412 // is a trusted device.
413 static
void verifyDestination
(VerificationProperties properties
,
414 BooleanCallback
callback);
416 // Verifies that the device is a trusted device and retrieves encrypted
417 // network credentials.
418 // |properties|: Properties of the destination to use in verifying that it
419 // is a trusted device.
420 // |networkGuid|: The GUID of the Cellular network to activate.
421 // |callback|: A callback function that receives base64-encoded encrypted
422 // credential data to send to a trusted device.
423 static
void verifyAndEncryptCredentials
(VerificationProperties properties
,
424 DOMString networkGuid
,
425 StringCallback
callback);
427 // Verifies that the device is a trusted device and encrypts supplied
428 // data with device public key.
429 // |properties|: Properties of the destination to use in verifying that it
430 // is a trusted device.
431 // |data|: A string containing the base64-encoded data to encrypt.
432 // |callback|: A callback function that receives base64-encoded encrypted
433 // data to send to a trusted device.
434 static
void verifyAndEncryptData
(VerificationProperties properties
,
436 StringCallback
callback);
438 // Enables TDLS for WiFi traffic with a specified peer if available.
439 // |ip_or_mac_address|: The IP or MAC address of the peer with which to
440 // enable a TDLS connection.
441 // |enabled| If true, enable TDLS, otherwise disable TDLS.
442 // |callback|: A callback function that receives a string with an error or
443 // the current TDLS status. 'Failed' indicates that the request failed
444 // (e.g. MAC address lookup failed). 'Timeout' indicates that the lookup
445 // timed out. Otherwise a valid status is returned (see
446 // $(ref:getWifiTDLSStatus)).
447 static
void setWifiTDLSEnabledState
(DOMString ip_or_mac_address
,
449 optional StringCallback
callback);
451 // Returns the current TDLS status for the specified peer.
452 // |ip_or_mac_address|: The IP or MAC address of the peer.
453 // |callback|: A callback function that receives a string with the current
454 // TDLS status which can be 'Connected', 'Disabled', 'Disconnected',
455 // 'Nonexistent', or 'Unknown'.
456 static
void getWifiTDLSStatus
(DOMString ip_or_mac_address
,
457 StringCallback
callback);
459 // Returns captive portal status for the network matching 'networkGuid'.
460 // |networkGuid|: The GUID of the network to get captive portal status for.
461 // |callback|: A callback function that returns the results of the query for
462 // network captive portal status.
463 static
void getCaptivePortalStatus
(DOMString networkGuid
,
464 CaptivePortalStatusCallback
callback);
468 // Fired when the properties change on any of the networks. Sends a list of
469 // GUIDs for networks whose properties have changed.
470 static
void onNetworksChanged
(DOMString
[] changes
);
472 // Fired when the list of networks has changed. Sends a complete list of
473 // GUIDs for all the current networks.
474 static
void onNetworkListChanged
(DOMString
[] changes
);
476 // Fired when the list of devices has changed or any device state properties
478 static
void onDeviceStateListChanged
();
480 // Fired when a portal detection for a network completes. Sends the guid of
481 // the network and the corresponding captive portal status.
482 static
void onPortalDetectionCompleted
(DOMString networkGuid
,
483 CaptivePortalStatus status
);