OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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/component
s/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-netw
ork-configuration"> |
| 13 // Open Network Configuration</a> page at chromium.org. |
| 14 // |
| 15 // TODO(stevenjb/pneubeck): Merge the ONC documentation with this document and |
| 16 // use it as the ONC specification. |
| 17 |
| 18 namespace networkingPrivate { |
| 19 enum CaptivePortalStatus { |
| 20 Unknown, Offline, Online, Portal, ProxyAuthRequired |
| 21 }; |
| 22 |
| 23 enum NetworkType { |
| 24 All, Bluetooth, Cellular, Ethernet, VPN, Wireless, WiFi, WiMAX |
| 25 }; |
| 26 |
| 27 dictionary VerificationProperties { |
| 28 // A string containing a PEM-encoded (including the 'BEGIN CERTIFICATE' |
| 29 // header and 'END CERTIFICATE' footer) X.509 certificate for use in |
| 30 // verifying the signed data. |
| 31 DOMString certificate; |
| 32 |
| 33 // An array of PEM-encoded X.509 intermediate certificate authority |
| 34 // certificates. Each PEM-encoded certificate is expected to have the |
| 35 // 'BEGIN CERTIFICATE' header and 'END CERTIFICATE' footer. |
| 36 DOMString[]? intermediateCertificates; |
| 37 |
| 38 // A string containing a base64-encoded RSAPublicKey ASN.1 structure, |
| 39 // representing the public key to be used by |
| 40 // $(ref:verifyAndEncryptCredentials) and $(ref:verifyAndEncryptData) |
| 41 // methods. |
| 42 DOMString publicKey; |
| 43 |
| 44 // A string containing a base64-encoded random binary data for use in |
| 45 // verifying the signed data. |
| 46 DOMString nonce; |
| 47 |
| 48 // A string containing the identifying data string signed by the device. |
| 49 DOMString signedData; |
| 50 |
| 51 // A string containing the serial number of the device. |
| 52 DOMString deviceSerial; |
| 53 |
| 54 // A string containing the SSID of the device. Should be empty for new |
| 55 // configurations. |
| 56 DOMString deviceSsid; |
| 57 |
| 58 // A string containing the BSSID of the device. Should be empty for new |
| 59 // configurations. |
| 60 DOMString deviceBssid; |
| 61 }; |
| 62 |
| 63 dictionary NetworkFilter { |
| 64 // The type of networks to return. |
| 65 NetworkType networkType; |
| 66 |
| 67 // If true, only include visible (physically connected or in-range) |
| 68 // networks. Defaults to 'false'. |
| 69 boolean? visible; |
| 70 |
| 71 // If true, only include configured (saved) networks. Defaults to 'false'. |
| 72 boolean? configured; |
| 73 |
| 74 // Maximum number of networks to return. Defaults to 1000 if unspecified. |
| 75 // Use 0 for no limit. |
| 76 long? limit; |
| 77 }; |
| 78 |
| 79 callback VoidCallback = void(); |
| 80 callback BooleanCallback = void(boolean result); |
| 81 callback StringCallback = void(DOMString result); |
| 82 // TODO(stevenjb): Use NetworkProperties for |result| once defined. |
| 83 callback GetPropertiesCallback = void(object result); |
| 84 // TODO(stevenjb): Use ManagedNetworkProperties for |result| once defined. |
| 85 callback GetManagedPropertiesCallback = void(object result); |
| 86 callback GetStatePropertiesCallback = void(object result); |
| 87 callback GetNetworksCallback = void(object[] result); |
| 88 callback GetEnabledNetworkTypesCallback = void(NetworkType[] result); |
| 89 callback CaptivePortalStatusCallback = void(CaptivePortalStatus result); |
| 90 |
| 91 // These functions all report failures via chrome.runtime.lastError. |
| 92 interface Functions { |
| 93 // Gets all the properties of the network with id networkGuid. Includes all |
| 94 // properties of the network (read-only and read/write values). |
| 95 // |networkGuid|: The GUID of the network to get properties for. |
| 96 // |callback|: Called with the network properties when received. |
| 97 static void getProperties(DOMString networkGuid, |
| 98 GetPropertiesCallback callback); |
| 99 |
| 100 // Gets the merged properties of the network with id networkGuid from the |
| 101 // sources: User settings, shared settings, user policy, device policy and |
| 102 // the currently active settings. |
| 103 // |networkGuid|: The GUID of the network to get properties for. |
| 104 // |callback|: Called with the managed network properties when received. |
| 105 static void getManagedProperties(DOMString networkGuid, |
| 106 GetManagedPropertiesCallback callback); |
| 107 |
| 108 // Gets the cached read-only properties of the network with id networkGuid. |
| 109 // This is meant to be a higher performance function than |
| 110 // $(ref:getProperties), which requires a round trip to query the networking |
| 111 // subsystem. The following properties are returned for all networks: GUID, |
| 112 // Type, Name, WiFi.Security. Additional properties are provided for visible |
| 113 // networks: ConnectionState, ErrorState, WiFi.SignalStrength, |
| 114 // Cellular.NetworkTechnology, Cellular.ActivationState, |
| 115 // Cellular.RoamingState, Cellular.OutOfCredits. |
| 116 // |networkGuid|: The GUID of the network to get properties for. |
| 117 // |callback|: Called immediately with the network state properties. |
| 118 static void getState(DOMString networkGuid, |
| 119 GetStatePropertiesCallback callback); |
| 120 |
| 121 // Sets the properties of the network with id networkGuid. |
| 122 // |networkGuid|: The GUID of the network to set properties for. |
| 123 // |properties|: The properties to set. |
| 124 // |callback|: Called when the operation has completed. |
| 125 static void setProperties(DOMString networkGuid, |
| 126 object properties, |
| 127 optional VoidCallback callback); |
| 128 |
| 129 // Creates a new network configuration from properties. If a matching |
| 130 // configured network already exists, this will fail. Otherwise returns the |
| 131 // guid of the new network. |
| 132 // |shared|: If true, share this network configuration with other users. |
| 133 // |properties|: The properties to configure the new network with. |
| 134 // |callback|: Called with the GUID for the new network configuration once |
| 135 // the network has been created. |
| 136 static void createNetwork(boolean shared, |
| 137 object properties, |
| 138 optional StringCallback callback); |
| 139 |
| 140 // Forgets a network configuration by clearing any configured properties for |
| 141 // the network with GUID 'networkGuid'. This may also include any other |
| 142 // networks with matching identifiers (e.g. WiFi SSID and Security). If no |
| 143 // such configuration exists, an error will be set and the operation will |
| 144 // fail. |
| 145 // |networkGuid|: The GUID of the network to forget. |
| 146 // |callback|: Called when the operation has completed. |
| 147 static void forgetNetwork(DOMString networkGuid, |
| 148 optional VoidCallback callback); |
| 149 |
| 150 // Returns a list of network objects with the same properties provided by |
| 151 // $(ref:networkingPrivate.getState). A filter is provided to specify the |
| 152 // type of networks returned and to limit the number of networks. Networks |
| 153 // are ordered by the system based on their priority, with connected or |
| 154 // connecting networks listed first. |
| 155 // |filter|: Describes which networks to return. |
| 156 // |callback|: Called with a dictionary of networks and their state |
| 157 // properties when received. |
| 158 static void getNetworks(NetworkFilter filter, |
| 159 GetNetworksCallback callback); |
| 160 |
| 161 // Deprecated. Please use $(ref:networkingPrivate.getNetworks) with |
| 162 // filter.visible = true instead. |
| 163 [deprecated="Use getNetworks."] static void getVisibleNetworks( |
| 164 NetworkType networkType, |
| 165 GetNetworksCallback callback); |
| 166 |
| 167 // Returns a list of the enabled network types. Note: this only returns |
| 168 // discrete types that can be enabled or disabled: Cellular, Ethernet, WiFi, |
| 169 // Wimax. |
| 170 // |callback|: Called immediately with the enabled network types. |
| 171 static void getEnabledNetworkTypes(GetEnabledNetworkTypesCallback callback); |
| 172 |
| 173 // Enable the specified network type. Note, the type might represent |
| 174 // multiple network types (e.g. 'Wireless'). |
| 175 // |networkType|: The type of network to enable. |
| 176 static void enableNetworkType(NetworkType networkType); |
| 177 |
| 178 // Disable the specified network type. See note for |
| 179 // $(ref:networkingPrivate.enableNetworkType). |
| 180 // |networkType|: The type of network to disable. |
| 181 static void disableNetworkType(NetworkType networkType); |
| 182 |
| 183 // Requests that the networking subsystem scan for new networks and |
| 184 // update the list returned by $(ref:getVisibleNetworks). This is only a |
| 185 // request: the network subsystem can choose to ignore it. If the list |
| 186 // is updated, then the $(ref:onNetworkListChanged) event will be fired. |
| 187 static void requestNetworkScan(); |
| 188 |
| 189 // Starts a connection to the network with networkGuid. |
| 190 // |networkGuid|: The GUID of the network to connect to. |
| 191 // |callback|: Called when the connect request has been sent. Note: the |
| 192 // connection may not have completed. Observe $(ref:onNetworksChanged) |
| 193 // to be notified when a network state changes. |
| 194 static void startConnect(DOMString networkGuid, |
| 195 optional VoidCallback callback); |
| 196 |
| 197 // Starts a disconnect from the network with networkGuid. |
| 198 // |networkGuid|: The GUID of the network to disconnect from. |
| 199 // |callback|: Called when the disconnect request has been sent. See note |
| 200 // for $(ref:startConnect). |
| 201 static void startDisconnect(DOMString networkGuid, |
| 202 optional VoidCallback callback); |
| 203 |
| 204 // Starts activation of the Cellular network with networkGuid. |
| 205 // |networkGuid|: The GUID of the Cellular network to activate. |
| 206 // |carrier|: Optional name of carrier to activate. |
| 207 // |callback|: Called when the activation request has been sent. See note |
| 208 // for $(ref:startConnect). |
| 209 static void startActivate(DOMString networkGuid, |
| 210 optional DOMString carrier, |
| 211 optional VoidCallback callback); |
| 212 |
| 213 // Verifies that the device is a trusted device. |
| 214 // |properties|: Properties of the destination to use in verifying that it |
| 215 // is a trusted device. |
| 216 // |callback|: A callback function that indicates whether or not the device |
| 217 // is a trusted device. |
| 218 static void verifyDestination(VerificationProperties properties, |
| 219 BooleanCallback callback); |
| 220 |
| 221 // Verifies that the device is a trusted device and retrieves encrypted |
| 222 // network credentials. |
| 223 // |properties|: Properties of the destination to use in verifying that it |
| 224 // is a trusted device. |
| 225 // |networkGuid|: The GUID of the Cellular network to activate. |
| 226 // |callback|: A callback function that receives base64-encoded encrypted |
| 227 // credential data to send to a trusted device. |
| 228 static void verifyAndEncryptCredentials(VerificationProperties properties, |
| 229 DOMString networkGuid, |
| 230 StringCallback callback); |
| 231 |
| 232 // Verifies that the device is a trusted device and encrypts supplied |
| 233 // data with device public key. |
| 234 // |properties|: Properties of the destination to use in verifying that it |
| 235 // is a trusted device. |
| 236 // |data|: A string containing the base64-encoded data to encrypt. |
| 237 // |callback|: A callback function that receives base64-encoded encrypted |
| 238 // data to send to a trusted device. |
| 239 static void verifyAndEncryptData(VerificationProperties properties, |
| 240 DOMString data, |
| 241 StringCallback callback); |
| 242 |
| 243 // Enables TDLS for WiFi traffic with a specified peer if available. |
| 244 // |ip_or_mac_address|: The IP or MAC address of the peer with which to |
| 245 // enable a TDLS connection. |
| 246 // |enabled| If true, enable TDLS, otherwise disable TDLS. |
| 247 // |callback|: A callback function that receives a string with an error or |
| 248 // the current TDLS status. 'Failed' indicates that the request failed |
| 249 // (e.g. MAC address lookup failed). 'Timeout' indicates that the lookup |
| 250 // timed out. Otherwise a valid status is returned (see |
| 251 // $(ref:getWifiTDLSStatus)). |
| 252 static void setWifiTDLSEnabledState(DOMString ip_or_mac_address, |
| 253 boolean enabled, |
| 254 optional StringCallback callback); |
| 255 |
| 256 // Returns the current TDLS status for the specified peer. |
| 257 // |ip_or_mac_address|: The IP or MAC address of the peer. |
| 258 // |callback|: A callback function that receives a string with the current |
| 259 // TDLS status which can be 'Connected', 'Disabled', 'Disconnected', |
| 260 // 'Nonexistent', or 'Unknown'. |
| 261 static void getWifiTDLSStatus(DOMString ip_or_mac_address, |
| 262 StringCallback callback); |
| 263 |
| 264 // Returns captive portal status for the network matching 'networkGuid'. |
| 265 // |networkGuid|: The GUID of the network to get captive portal status for. |
| 266 // |callback|: A callback function that returns the results of the query for |
| 267 // network captive portal status. |
| 268 static void getCaptivePortalStatus(DOMString networkGuid, |
| 269 CaptivePortalStatusCallback callback); |
| 270 }; |
| 271 |
| 272 interface Events { |
| 273 // Fired when the properties change on any of the networks. Sends a list of |
| 274 // GUIDs for networks whose properties have changed. |
| 275 static void onNetworksChanged(DOMString[] changes); |
| 276 |
| 277 // Fired when the list of networks has changed. Sends a complete list of |
| 278 // GUIDs for all the current networks. |
| 279 static void onNetworkListChanged(DOMString[] changes); |
| 280 |
| 281 // Fired when a portal detection for a network completes. Sends the guid of |
| 282 // the network and the corresponding captive portal status. |
| 283 static void onPortalDetectionCompleted(DOMString networkGuid, |
| 284 CaptivePortalStatus status); |
| 285 }; |
| 286 }; |
OLD | NEW |