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 dictionary APNProperties
{
63 DOMString? AccessPointName
;
65 DOMString? LocalizedName
;
71 dictionary CellularConfigProperties
{
75 // Specifies which carrier to use for Cellular configurations that support
76 // multiple carriers. May be set with $(ref:setProperties), but will be
77 // ignored by $(ref:createConfiguration).
81 dictionary CellularStateProperties
{
82 ActivationStateType? ActivationState
;
83 DOMString? NetworkTechnology
;
84 DOMString? RoamingState
;
89 dictionary DeviceStateProperties
{
90 // Set if the device is enabled. True if the device is currently scanning.
93 // The current state of the device.
94 DeviceStateType State
;
96 // The network type associated with the device (Cellular, Ethernet, WiFi, or
101 dictionary EthernetStateProperties
{
102 DOMString Authentication
;
105 dictionary IPConfigProperties
{
107 DOMString? IPAddress
;
108 DOMString
[]? NameServers
;
111 DOMString? WebProxyAutoDiscoveryUrl
;
114 dictionary IPSecProperties
{
115 DOMString AuthenticationType
;
118 dictionary ThirdPartyVPNProperties
{
119 DOMString ExtensionID
;
122 dictionary VPNConfigProperties
{
123 boolean? AutoConnect
;
125 ThirdPartyVPNProperties? ThirdPartyVPN
;
129 dictionary VPNStateProperties
{
131 IPSecProperties? IPsec
;
132 ThirdPartyVPNProperties? ThirdPartyVPN
;
135 dictionary WiFiConfigProperties
{
136 boolean? AutoConnect
;
139 DOMString? Passphrase
;
144 dictionary WiFiStateProperties
{
146 long? SignalStrength
;
149 dictionary WiMaxConfigProperties
{
150 boolean? AutoConnect
;
153 dictionary WiMAXStateProperties
{
154 long? SignalStrength
;
157 dictionary NetworkConfigProperties
{
158 CellularConfigProperties? Cellular
;
160 IPConfigType? IPAddressConfigType
;
162 IPConfigType? NameServersConfigType
;
164 IPConfigProperties? StaticIPConfig
;
166 VPNConfigProperties? VPN
;
167 WiFiConfigProperties? WiFi
;
168 WiMaxConfigProperties? WiMAX
;
171 dictionary NetworkStateProperties
{
172 CellularStateProperties? Cellular
;
173 boolean? Connectable
;
174 ConnectionStateType? ConnectionState
;
175 EthernetStateProperties? Ethernet
;
176 DOMString? ErrorState
;
182 VPNStateProperties? VPN
;
183 WiFiStateProperties? WiFi
;
184 WiMAXStateProperties? WiMAX
;
187 dictionary VerificationProperties
{
188 // A string containing a PEM-encoded (including the 'BEGIN CERTIFICATE'
189 // header and 'END CERTIFICATE' footer) X.509 certificate for use in
190 // verifying the signed data.
191 DOMString certificate
;
193 // An array of PEM-encoded X.509 intermediate certificate authority
194 // certificates. Each PEM-encoded certificate is expected to have the
195 // 'BEGIN CERTIFICATE' header and 'END CERTIFICATE' footer.
196 DOMString
[]? intermediateCertificates
;
198 // A string containing a base64-encoded RSAPublicKey ASN.1 structure,
199 // representing the public key to be used by
200 // $(ref:verifyAndEncryptCredentials) and $(ref:verifyAndEncryptData)
204 // A string containing a base64-encoded random binary data for use in
205 // verifying the signed data.
208 // A string containing the identifying data string signed by the device.
209 DOMString signedData
;
211 // A string containing the serial number of the device.
212 DOMString deviceSerial
;
214 // A string containing the SSID of the device. Should be empty for new
216 DOMString deviceSsid
;
218 // A string containing the BSSID of the device. Should be empty for new
220 DOMString deviceBssid
;
223 dictionary NetworkFilter
{
224 // The type of networks to return.
225 NetworkType networkType
;
227 // If true, only include visible (physically connected or in-range)
228 // networks. Defaults to 'false'.
231 // If true, only include configured (saved) networks. Defaults to 'false'.
234 // Maximum number of networks to return. Defaults to 1000 if unspecified.
235 // Use 0 for no limit.
239 callback VoidCallback
= void();
240 callback BooleanCallback
= void(boolean result
);
241 callback StringCallback
= void(DOMString result
);
242 // TODO(stevenjb): Use NetworkProperties for |result| once defined.
243 callback GetPropertiesCallback
= void(object result
);
244 // TODO(stevenjb): Use ManagedNetworkProperties for |result| once defined.
245 callback GetManagedPropertiesCallback
= void(object result
);
246 callback GetStatePropertiesCallback
= void(NetworkStateProperties result
);
247 callback GetNetworksCallback
= void(NetworkStateProperties
[] result
);
248 callback GetDeviceStatesCallback
= void(DeviceStateProperties
[] result
);
249 callback GetEnabledNetworkTypesCallback
= void(NetworkType
[] result
);
250 callback CaptivePortalStatusCallback
= void(CaptivePortalStatus result
);
252 // These functions all report failures via chrome.runtime.lastError.
253 interface Functions
{
254 // Gets all the properties of the network with id networkGuid. Includes all
255 // properties of the network (read-only and read/write values).
256 // |networkGuid|: The GUID of the network to get properties for.
257 // |callback|: Called with the network properties when received.
258 static
void getProperties
(DOMString networkGuid
,
259 GetPropertiesCallback
callback);
261 // Gets the merged properties of the network with id networkGuid from the
262 // sources: User settings, shared settings, user policy, device policy and
263 // the currently active settings.
264 // |networkGuid|: The GUID of the network to get properties for.
265 // |callback|: Called with the managed network properties when received.
266 static
void getManagedProperties
(DOMString networkGuid
,
267 GetManagedPropertiesCallback
callback);
269 // Gets the cached read-only properties of the network with id networkGuid.
270 // This is meant to be a higher performance function than
271 // $(ref:getProperties), which requires a round trip to query the networking
272 // subsystem. The following properties are returned for all networks: GUID,
273 // Type, Name, WiFi.Security. Additional properties are provided for visible
274 // networks: ConnectionState, ErrorState, WiFi.SignalStrength,
275 // Cellular.NetworkTechnology, Cellular.ActivationState,
276 // Cellular.RoamingState.
277 // |networkGuid|: The GUID of the network to get properties for.
278 // |callback|: Called immediately with the network state properties.
279 static
void getState
(DOMString networkGuid
,
280 GetStatePropertiesCallback
callback);
282 // Sets the properties of the network with id networkGuid.
283 // |networkGuid|: The GUID of the network to set properties for.
284 // |properties|: The properties to set.
285 // |callback|: Called when the operation has completed.
286 static
void setProperties
(DOMString networkGuid
,
287 NetworkConfigProperties properties
,
288 optional VoidCallback
callback);
290 // Creates a new network configuration from properties. If a matching
291 // configured network already exists, this will fail. Otherwise returns the
292 // guid of the new network.
293 // |shared|: If true, share this network configuration with other users.
294 // |properties|: The properties to configure the new network with.
295 // |callback|: Called with the GUID for the new network configuration once
296 // the network has been created.
297 static
void createNetwork
(boolean shared
,
298 NetworkConfigProperties properties
,
299 optional StringCallback
callback);
301 // Forgets a network configuration by clearing any configured properties for
302 // the network with GUID 'networkGuid'. This may also include any other
303 // networks with matching identifiers (e.g. WiFi SSID and Security). If no
304 // such configuration exists, an error will be set and the operation will
306 // |networkGuid|: The GUID of the network to forget.
307 // |callback|: Called when the operation has completed.
308 static
void forgetNetwork
(DOMString networkGuid
,
309 optional VoidCallback
callback);
311 // Returns a list of network objects with the same properties provided by
312 // $(ref:networkingPrivate.getState). A filter is provided to specify the
313 // type of networks returned and to limit the number of networks. Networks
314 // are ordered by the system based on their priority, with connected or
315 // connecting networks listed first.
316 // |filter|: Describes which networks to return.
317 // |callback|: Called with a dictionary of networks and their state
318 // properties when received.
319 static
void getNetworks
(NetworkFilter filter
,
320 GetNetworksCallback
callback);
322 // Deprecated. Please use $(ref:networkingPrivate.getNetworks) with
323 // filter.visible = true instead.
324 [deprecated
="Use getNetworks."] static
void getVisibleNetworks
(
325 NetworkType networkType
,
326 GetNetworksCallback
callback);
328 // Deprecated. Please use $(ref:networkingPrivate.getDeviceStates) instead.
329 [deprecated
="Use getDeviceStates."] static
void getEnabledNetworkTypes
(
330 GetEnabledNetworkTypesCallback
callback);
332 // Returns a list of $(ref:networkingPrivate.DeviceStateProperties) objects.
333 // |callback|: Called with a list of devices and their state.
334 static
void getDeviceStates
(GetDeviceStatesCallback
callback);
336 // Enables any devices matching the specified network type. Note, the type
337 // might represent multiple network types (e.g. 'Wireless').
338 // |networkType|: The type of network to enable.
339 static
void enableNetworkType
(NetworkType networkType
);
341 // Disables any devices matching the specified network type. See note for
342 // $(ref:networkingPrivate.enableNetworkType).
343 // |networkType|: The type of network to disable.
344 static
void disableNetworkType
(NetworkType networkType
);
346 // Requests that the networking subsystem scan for new networks and
347 // update the list returned by $(ref:getVisibleNetworks). This is only a
348 // request: the network subsystem can choose to ignore it. If the list
349 // is updated, then the $(ref:onNetworkListChanged) event will be fired.
350 static
void requestNetworkScan
();
352 // Starts a connection to the network with networkGuid.
353 // |networkGuid|: The GUID of the network to connect to.
354 // |callback|: Called when the connect request has been sent. Note: the
355 // connection may not have completed. Observe $(ref:onNetworksChanged)
356 // to be notified when a network state changes.
357 static
void startConnect
(DOMString networkGuid
,
358 optional VoidCallback
callback);
360 // Starts a disconnect from the network with networkGuid.
361 // |networkGuid|: The GUID of the network to disconnect from.
362 // |callback|: Called when the disconnect request has been sent. See note
363 // for $(ref:startConnect).
364 static
void startDisconnect
(DOMString networkGuid
,
365 optional VoidCallback
callback);
367 // Starts activation of the Cellular network with networkGuid.
368 // |networkGuid|: The GUID of the Cellular network to activate.
369 // |carrier|: Optional name of carrier to activate.
370 // |callback|: Called when the activation request has been sent. See note
371 // for $(ref:startConnect).
372 static
void startActivate
(DOMString networkGuid
,
373 optional DOMString carrier
,
374 optional VoidCallback
callback);
376 // Verifies that the device is a trusted device.
377 // |properties|: Properties of the destination to use in verifying that it
378 // is a trusted device.
379 // |callback|: A callback function that indicates whether or not the device
380 // is a trusted device.
381 static
void verifyDestination
(VerificationProperties properties
,
382 BooleanCallback
callback);
384 // Verifies that the device is a trusted device and retrieves encrypted
385 // network credentials.
386 // |properties|: Properties of the destination to use in verifying that it
387 // is a trusted device.
388 // |networkGuid|: The GUID of the Cellular network to activate.
389 // |callback|: A callback function that receives base64-encoded encrypted
390 // credential data to send to a trusted device.
391 static
void verifyAndEncryptCredentials
(VerificationProperties properties
,
392 DOMString networkGuid
,
393 StringCallback
callback);
395 // Verifies that the device is a trusted device and encrypts supplied
396 // data with device public key.
397 // |properties|: Properties of the destination to use in verifying that it
398 // is a trusted device.
399 // |data|: A string containing the base64-encoded data to encrypt.
400 // |callback|: A callback function that receives base64-encoded encrypted
401 // data to send to a trusted device.
402 static
void verifyAndEncryptData
(VerificationProperties properties
,
404 StringCallback
callback);
406 // Enables TDLS for WiFi traffic with a specified peer if available.
407 // |ip_or_mac_address|: The IP or MAC address of the peer with which to
408 // enable a TDLS connection.
409 // |enabled| If true, enable TDLS, otherwise disable TDLS.
410 // |callback|: A callback function that receives a string with an error or
411 // the current TDLS status. 'Failed' indicates that the request failed
412 // (e.g. MAC address lookup failed). 'Timeout' indicates that the lookup
413 // timed out. Otherwise a valid status is returned (see
414 // $(ref:getWifiTDLSStatus)).
415 static
void setWifiTDLSEnabledState
(DOMString ip_or_mac_address
,
417 optional StringCallback
callback);
419 // Returns the current TDLS status for the specified peer.
420 // |ip_or_mac_address|: The IP or MAC address of the peer.
421 // |callback|: A callback function that receives a string with the current
422 // TDLS status which can be 'Connected', 'Disabled', 'Disconnected',
423 // 'Nonexistent', or 'Unknown'.
424 static
void getWifiTDLSStatus
(DOMString ip_or_mac_address
,
425 StringCallback
callback);
427 // Returns captive portal status for the network matching 'networkGuid'.
428 // |networkGuid|: The GUID of the network to get captive portal status for.
429 // |callback|: A callback function that returns the results of the query for
430 // network captive portal status.
431 static
void getCaptivePortalStatus
(DOMString networkGuid
,
432 CaptivePortalStatusCallback
callback);
436 // Fired when the properties change on any of the networks. Sends a list of
437 // GUIDs for networks whose properties have changed.
438 static
void onNetworksChanged
(DOMString
[] changes
);
440 // Fired when the list of networks has changed. Sends a complete list of
441 // GUIDs for all the current networks.
442 static
void onNetworkListChanged
(DOMString
[] changes
);
444 // Fired when the list of devices has changed or any device state properties
446 static
void onDeviceStateListChanged
();
448 // Fired when a portal detection for a network completes. Sends the guid of
449 // the network and the corresponding captive portal status.
450 static
void onPortalDetectionCompleted
(DOMString networkGuid
,
451 CaptivePortalStatus status
);