diff options
author | stevenjb <stevenjb@chromium.org> | 2015-09-28 19:19:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-29 02:22:30 +0000 |
commit | 85e48f8d7662016fc1bb53dcbcf22167b6d74a6b (patch) | |
tree | c83b73c110bd6a07653343e3f3ea665d1197e8b1 | |
parent | 7ccad76381159347a94d636d573ad35c0a51cba7 (diff) | |
download | chromium_src-85e48f8d7662016fc1bb53dcbcf22167b6d74a6b.zip chromium_src-85e48f8d7662016fc1bb53dcbcf22167b6d74a6b.tar.gz chromium_src-85e48f8d7662016fc1bb53dcbcf22167b6d74a6b.tar.bz2 |
Update networkingPrivate IDL
This CL:
* Adds NetworkProperties to networking_private.idl for
the getProperties callback.
* Updates networking_private.js externs.
* Updates cr_onc_types.js:
** CrOnc.getProperty is removed (properties.foo.bar is used instead)
** CrOnc.getActiveValue(state, key) is removed and
CrOnc.getActivePropertyValue is renamed to getActiveValue. Calls
to CrOnc.getActiveValue(state, key) become
CrOnc.getActiveValue(state.key) (except for dictionary properties
which can not be managed, in which case state.key is used
directly).
* Updates md-settings/internet JS to use NetworkProperties for
getNetworks() instead of the NetworkStateProperties subset.
** All references to networkState that are actually
NetworkProperties are renamed to networkProperties to make it
easier to distinguish between "state" property dictionaries and
full property dictionaries.
** (Apologies for the additional renaming diffs that generates)
BUG=535270
For third_party/closure_compiler/externs/networking_private.js:
TBR=jlklein@chromium.org
Review URL: https://codereview.chromium.org/1366243002
Cr-Commit-Position: refs/heads/master@{#351232}
23 files changed, 839 insertions, 465 deletions
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc index f08ef79..e8336cc 100644 --- a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc +++ b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc @@ -223,6 +223,7 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest { base::StringValue("Cellular1_Carrier")); base::DictionaryValue home_provider; home_provider.SetString("name", "Cellular1_Provider"); + home_provider.SetString("code", "000000"); home_provider.SetString("country", "us"); device_test_->SetDeviceProperty( kCellularDevicePath, shill::kHomeProviderProperty, home_provider); diff --git a/chrome/browser/resources/settings/internet_page/internet_detail_page.html b/chrome/browser/resources/settings/internet_page/internet_detail_page.html index bc7d19a..21e95a5 100644 --- a/chrome/browser/resources/settings/internet_page/internet_detail_page.html +++ b/chrome/browser/resources/settings/internet_page/internet_detail_page.html @@ -22,20 +22,20 @@ <div class="layout vertical"> <!-- Title section: Icon + name + connection state. --> <div id="titleDiv" class="layout horizontal center"> - <cr-network-icon id="networkIcon" network-state="[[networkState]]"> + <cr-network-icon id="networkIcon" network-state="[[networkProperties]]"> </cr-network-icon> - <span id="networkName">[[getStateName_(networkState)]]</span> + <span id="networkName">[[getStateName_(networkProperties)]]</span> <span id="networkState" - connected$="[[isConnectedState_(networkState)]]" - >[[getStateText_(networkState)]]</span> + connected$="[[isConnectedState_(networkProperties)]]" + >[[getStateText_(networkProperties)]]</span> </div> <div id="outerDiv" class="layout vertical"> <!-- For Cellular, show SIM info first. --> <div id="simInfoDiv" class="layout vertical"> <network-siminfo editable - hidden$="[[!showCellularSim_(networkState)]]" - network-state="[[networkState]]" + hidden$="[[!showCellularSim_(networkProperties)]]" + network-properties="[[networkProperties]]" on-siminfo-change="onNetworkPropertyChange_"> </network-siminfo> </div> @@ -46,11 +46,11 @@ <span>IP Address:</span> <span>[[IPAddress]]</span> </div> - <span hidden$="[[!showShared_(networkState)]]"> + <span hidden$="[[!showShared_(networkProperties)]]"> This network is shared with other users. </span> <div class="layout horizontal center" - hidden$="[[!showPreferNetwork_(networkState)]]"> + hidden$="[[!showPreferNetwork_(networkProperties)]]"> <paper-icon-button id="preferButton" toggles active="{{preferNetwork}}" icon="[[getPreferredIcon_(preferNetwork)]]"> @@ -58,38 +58,38 @@ <span>Prefer this network</span> </div> <paper-checkbox checked="{{autoConnect}}" - hidden$="[[!showAutoConnect_(networkState)]]"> + hidden$="[[!showAutoConnect_(networkProperties)]]"> Automatically connect to this network </paper-checkbox> <!-- Properties to always show if present. --> <network-property-list - fields="[[getInfoFields_(networkState)]]" - network-state="[[networkState]]"> + fields="[[getInfoFields_(networkProperties)]]" + property-dict="[[networkProperties]]"> </network-property-list> </div> <!-- Button row: Advanced + Disconnect | Connect. --> <div class="layout horizontal center"> <paper-button toggles noink active="{{advancedExpanded}}" - hidden$="[[!hasAdvancedOrDeviceFields_(networkState)]]"> + hidden$="[[!hasAdvancedOrDeviceFields_(networkProperties)]]"> Advanced </paper-button> <span class="flex"></span> - <paper-button hidden$="[[!showViewAccount_(networkState)]]" + <paper-button hidden$="[[!showViewAccount_(networkProperties)]]" on-tap="onViewAccountClicked_"> View Account </paper-button> - <paper-button hidden$="[[!showActivate_(networkState)]]" + <paper-button hidden$="[[!showActivate_(networkProperties)]]" on-tap="onActivateClicked_"> Activate </paper-button> - <paper-button hidden$="[[!showConnect_(networkState)]]" - disabled="[[!enableConnect_(networkState)]]" + <paper-button hidden$="[[!showConnect_(networkProperties)]]" + disabled="[[!enableConnect_(networkProperties)]]" on-tap="onConnectClicked_"> Connect </paper-button> - <paper-button hidden$="[[!showDisconnect_(networkState)]]" + <paper-button hidden$="[[!showDisconnect_(networkProperties)]]" on-tap="onDisconnectClicked_"> Disconnect </paper-button> @@ -97,36 +97,36 @@ <!-- Advanced section --> <div id="advancedDiv" class="layout vertical" - hidden$="[[!hasAdvancedOrDeviceFields_(networkState)]]"> + hidden$="[[!hasAdvancedOrDeviceFields_(networkProperties)]]"> <cr-collapse opened="[[advancedExpanded]]"> <!-- Advanced properties --> <div id="advancedInfoDiv" class="layout vertical"> <network-property-list - fields="[[getAdvancedFields_(networkState)]]" - network-state="[[networkState]]"> + fields="[[getAdvancedFields_(networkProperties)]]" + property-dict="[[networkProperties]]"> </network-property-list> </div> <!-- Network (APN, address, nameservers) --> <div id="addressDiv" class="layout vertical" - hidden$="[[!hasNetworkSection_(networkState)]]"> + hidden$="[[!hasNetworkSection_(networkProperties)]]"> <paper-button toggles noink active="{{addressExpanded}}"> Network </paper-button> <cr-collapse opened="[[addressExpanded]]"> <div class="layout vertical flex"> <network-apnlist editable - hidden$="[[!isType_(networkState, NetworkType.CELLULAR)]]" - network-state="[[networkState]]" - apnlist="[[networkState.Cellular.APNList]]" + hidden$="[[!isType_(networkProperties, NetworkType.CELLULAR)]]" + network-properties="[[networkProperties]]" + apnlist="[[networkProperties.Cellular.APNList]]" on-apn-change="onNetworkPropertyChange_"> </network-apnlist> <network-ip-config editable - network-state="[[networkState]]" + network-properties="[[networkProperties]]" on-ip-change="onIPConfigChange_"> </network-ip-config> <network-nameservers editable - network-state="[[networkState]]" + network-properties="[[networkProperties]]" on-nameservers-change="onIPConfigChange_"> </network-nameservers> </div> @@ -135,14 +135,14 @@ <!-- Proxy --> <div class="layout vertical" - hidden$="[[!hasNetworkSection_(networkState)]]"> + hidden$="[[!hasNetworkSection_(networkProperties)]]"> <paper-button toggles noink active="{{proxyExpanded}}"> Proxy </paper-button> <cr-collapse opened="[[proxyExpanded]]"> <div id="proxyDiv" class="layout vertical flex"> <network-proxy editable - network-state="[[networkState]]" + network-properties="[[networkProperties]]" on-proxy-change="onProxyChange_"> </network-proxy> </div> @@ -151,14 +151,14 @@ <!-- Device properties --> <div class="layout vertical" - hidden$="[[!hasDeviceFields_(networkState)]]"> + hidden$="[[!hasDeviceFields_(networkProperties)]]"> <paper-button toggles noink active="{{deviceExpanded}}"> Device </paper-button> <cr-collapse opened="[[deviceExpanded]]"> <network-property-list - fields="[[getDeviceFields_(networkState)]]" - network-state="[[networkState]]"> + fields="[[getDeviceFields_(networkProperties)]]" + property-dict="[[networkProperties]]"> </network-property-list> <!-- TODO(stevenjb): Cellular SIM --> </cr-collapse> diff --git a/chrome/browser/resources/settings/internet_page/internet_detail_page.js b/chrome/browser/resources/settings/internet_page/internet_detail_page.js index a59a4d7..f2bb1bb16 100644 --- a/chrome/browser/resources/settings/internet_page/internet_detail_page.js +++ b/chrome/browser/resources/settings/internet_page/internet_detail_page.js @@ -29,17 +29,12 @@ Polymer({ }, /** - * The current state for the network matching |guid|. TODO(stevenjb): Use - * chrome.networkingProperties.NetworkPoperties once it is defined. This - * will be a super-set of NetworkStateProperties. Currently properties that - * are not defined in NetworkStateProperties are accessed through - * CrOnc.getActive* which uses [] to access the property, which avoids any - * type checking (see CrOnc.getProperty for more info). - * @type {CrOnc.NetworkStateProperties|undefined} + * The current properties for the network matching |guid|. + * @type {!CrOnc.NetworkProperties|undefined} */ - networkState: { + networkProperties: { type: Object, - observer: 'networkStateChanged_' + observer: 'networkPropertiesChanged_' }, /** @@ -115,25 +110,27 @@ Polymer({ }, /** - * Polymer networkState changed method. + * Polymer networkProperties changed method. */ - networkStateChanged_: function() { - if (!this.networkState) + networkPropertiesChanged_: function() { + if (!this.networkProperties) return; // Update autoConnect if it has changed. Default value is false. var autoConnect = /** @type {boolean} */( - CrOnc.getActiveTypeValue(this.networkState, 'AutoConnect')) || false; + CrOnc.getActiveTypeValue(this.networkProperties, 'AutoConnect')) || + false; if (autoConnect != this.autoConnect) this.autoConnect = autoConnect; // Update preferNetwork if it has changed. Default value is false. - var preferNetwork = this.networkState.Priority > 0; + var preferNetwork = this.networkProperties.Priority > 0; if (preferNetwork != this.preferNetwork) this.preferNetwork = preferNetwork; // Set the IPAddress property to the IPV4 Address. - var ipv4 = CrOnc.getIPConfigForType(this.networkState, CrOnc.IPType.IPV4); + var ipv4 = + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); this.IPAddress = (ipv4 && ipv4.IPAddress) || ''; }, @@ -141,7 +138,7 @@ Polymer({ * Polymer autoConnect changed method. */ autoConnectChanged_: function() { - if (!this.networkState || !this.guid) + if (!this.networkProperties || !this.guid) return; var onc = this.getEmptyNetworkProperties_(); CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect); @@ -152,7 +149,7 @@ Polymer({ * Polymer preferNetwork changed method. */ preferNetworkChanged_: function() { - if (!this.networkState || !this.guid) + if (!this.networkProperties || !this.guid) return; var onc = this.getEmptyNetworkProperties_(); onc.Priority = this.preferNetwork ? 1 : 0; @@ -182,14 +179,14 @@ Polymer({ /** * networkingPrivate.getProperties callback. - * @param {Object} properties The network properties. + * @param {CrOnc.NetworkProperties} properties The network properties. * @private */ getPropertiesCallback_: function(properties) { - this.networkState = /** @type {CrOnc.NetworkStateProperties}*/(properties); + this.networkProperties = properties; if (!properties) { - // If state becomes null (i.e. the network is no longer visible), close - // the page. + // If |properties| becomes null (i.e. the network is no longer visible), + // close the page. this.fire('close'); } }, @@ -218,91 +215,93 @@ Polymer({ * @private */ getEmptyNetworkProperties_: function() { - return {Type: this.networkState.Type}; + return {Type: this.networkProperties.Type}; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {string} The text to display for the network name. * @private */ - getStateName_: function(state) { - return (state && state.Name) || ''; + getStateName_: function(properties) { + return (properties && properties.Name) || ''; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {string} The text to display for the network connection state. * @private */ - getStateText_: function(state) { + getStateText_: function(properties) { // TODO(stevenjb): Localize. - return (state && state.ConnectionState) || ''; + return (properties && properties.ConnectionState) || ''; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. - * @return {boolean} True if the state is connected. + * @param {!CrOnc.NetworkProperties} properties + * @return {boolean} True if the network is connected. * @private */ - isConnectedState_: function(state) { - return !!state && state.ConnectionState == CrOnc.ConnectionState.CONNECTED; + isConnectedState_: function(properties) { + return !!properties && properties.ConnectionState == + CrOnc.ConnectionState.CONNECTED; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} Whether or not to show the 'Connect' button. * @private */ - showConnect_: function(state) { - return !!state && state.Type != CrOnc.Type.ETHERNET && - state.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; + showConnect_: function(properties) { + return !!properties && properties.Type != CrOnc.Type.ETHERNET && + properties.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} Whether or not to show the 'Activate' button. * @private */ - showActivate_: function(state) { - if (!state || state.Type != CrOnc.Type.CELLULAR) + showActivate_: function(properties) { + if (!properties || properties.Type != CrOnc.Type.CELLULAR) return false; - var activation = state.Cellular.ActivationState; + var activation = properties.Cellular.ActivationState; return activation == CrOnc.ActivationState.NOT_ACTIVATED || activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} Whether or not to show the 'View Account' button. * @private */ - showViewAccount_: function(state) { + showViewAccount_: function(properties) { // Show either the 'Activate' or the 'View Account' button. - if (this.showActivate_(state)) + if (this.showActivate_(properties)) return false; - if (!state || state.Type != CrOnc.Type.CELLULAR || !state.Cellular) + if (!properties || properties.Type != CrOnc.Type.CELLULAR || + !properties.Cellular) { return false; + } // Only show if online payment URL is provided or the carrier is Verizon. - var carrier = CrOnc.getActiveValue(state, 'Cellular.Carrier'); + var carrier = CrOnc.getActiveValue(properties.Cellular.Carrier); if (carrier != CARRIER_VERIZON) { - var paymentPortal = /** @type {CrOnc.PaymentPortal|undefined} */( - this.get('state.Cellular.PaymentPortal')); + var paymentPortal = properties.Cellular.PaymentPortal; if (!paymentPortal || !paymentPortal.Url) return false; } // Only show for connected networks or LTE networks with a valid MDN. - if (!this.isConnectedState_(state)) { + if (!this.isConnectedState_(properties)) { var technology = /** @type {CrOnc.NetworkTechnology|undefined} */( - CrOnc.getActiveValue(state, 'Cellular.NetworkTechnology')); + CrOnc.getActiveValue(properties.Cellular.NetworkTechnology)); if (technology != CrOnc.NetworkTechnology.LTE && technology != CrOnc.NetworkTechnology.LTE_ADVANCED) { return false; } - if (!CrOnc.getActiveValue(state, 'Cellular.MDN')) + if (!CrOnc.getActiveValue(properties.Cellular.MDN)) return false; } @@ -313,23 +312,23 @@ Polymer({ * @return {boolean} Whether or not to enable the network connect button. * @private */ - enableConnect_: function(state) { - if (!state || !this.showConnect_(state)) + enableConnect_: function(properties) { + if (!properties || !this.showConnect_(properties)) return false; - if (state.Type == CrOnc.Type.CELLULAR && CrOnc.isSimLocked(state)) + if (properties.Type == CrOnc.Type.CELLULAR && CrOnc.isSimLocked(properties)) return false; // TODO(stevenjb): For VPN, check connected state of any network. return true; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} Whether or not to show the 'Disconnect' button. * @private */ - showDisconnect_: function(state) { - return !!state && state.Type != CrOnc.Type.ETHERNET && - state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED; + showDisconnect_: function(properties) { + return !!properties && properties.Type != CrOnc.Type.ETHERNET && + properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED; }, /** @@ -371,7 +370,7 @@ Polymer({ * @private */ onNetworkPropertyChange_: function(event) { - if (!this.networkState) + if (!this.networkProperties) return; var field = event.detail.field; var value = event.detail.value; @@ -396,7 +395,7 @@ Polymer({ * @private */ onIPConfigChange_: function(event) { - if (!this.networkState) + if (!this.networkProperties) return; var field = event.detail.field; var value = event.detail.value; @@ -405,7 +404,7 @@ Polymer({ var onc = this.getEmptyNetworkProperties_(); var ipConfigType = /** @type {chrome.networkingPrivate.IPConfigType|undefined} */( - CrOnc.getActiveValue(this.networkState, 'IPAddressConfigType')); + CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType)); if (field == 'IPAddressConfigType') { var newIpConfigType = /** @type {chrome.networkingPrivate.IPConfigType} */(value); @@ -415,7 +414,8 @@ Polymer({ } else if (field == 'NameServersConfigType') { var nsConfigType = /** @type {chrome.networkingPrivate.IPConfigType|undefined} */( - CrOnc.getActiveValue(this.networkState, 'NameServersConfigType')); + CrOnc.getActiveValue( + this.networkProperties.NameServersConfigType)); var newNsConfigType = /** @type {chrome.networkingPrivate.IPConfigType} */(value); if (newNsConfigType == nsConfigType) @@ -423,8 +423,7 @@ Polymer({ onc.NameServersConfigType = newNsConfigType; } else if (field == 'StaticIPConfig') { if (ipConfigType == CrOnc.IPConfigType.STATIC) { - var staticIpConfig = /** @type {CrOnc.IPConfigProperties|undefined} */( - this.get('networkState.StaticIPConfig')); + var staticIpConfig = this.networkProperties.StaticIPConfig; if (staticIpConfig && this.allPropertiesMatch_(staticIpConfig, /** @type {!Object} */(value))) { @@ -458,9 +457,9 @@ Polymer({ return; } // setValidStaticIPConfig will fill in any other properties from - // networkState. This is necessary since we update IP Address and + // networkProperties. This is necessary since we update IP Address and // NameServers independently. - CrOnc.setValidStaticIPConfig(onc, this.networkState); + CrOnc.setValidStaticIPConfig(onc, this.networkProperties); this.setNetworkProperties_(onc); }, @@ -471,7 +470,7 @@ Polymer({ * @private */ onProxyChange_: function(event) { - if (!this.networkState) + if (!this.networkProperties) return; var field = event.detail.field; var value = event.detail.value; @@ -483,34 +482,34 @@ Polymer({ }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if the shared message should be shown. * @private */ - showShared_: function(state) { - return !!state && - (state.Source == 'Device' || state.Source == 'DevicePolicy'); + showShared_: function(properties) { + return !!properties && (properties.Source == 'Device' || + properties.Source == 'DevicePolicy'); }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if the AutoConnect checkbox should be shown. * @private */ - showAutoConnect_: function(state) { - return !!state && state.Type != CrOnc.Type.ETHERNET && - state.Source != CrOnc.Source.NONE; + showAutoConnect_: function(properties) { + return !!properties && properties.Type != CrOnc.Type.ETHERNET && + properties.Source != CrOnc.Source.NONE; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if the prefer network checkbox should be shown. * @private */ - showPreferNetwork_: function(state) { + showPreferNetwork_: function(properties) { // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for - // state.Type == CrOnc.Type.ETHERNET. - return !!state && state.Source != CrOnc.Source.NONE; + // properties.Type == CrOnc.Type.ETHERNET. + return !!properties && properties.Source != CrOnc.Source.NONE; }, /** @@ -523,76 +522,76 @@ Polymer({ }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {!Array<string>} The fields to display in the info section. * @private */ - getInfoFields_: function(state) { + getInfoFields_: function(properties) { /** @type {!Array<string>} */ var fields = []; - if (!state) + if (!properties) return fields; - if (state.Type == CrOnc.Type.CELLULAR) { + if (properties.Type == CrOnc.Type.CELLULAR) { fields.push('Cellular.ActivationState', 'Cellular.RoamingState', 'RestrictedConnectivity', 'Cellular.ServingOperator.Name'); } - if (state.Type == CrOnc.Type.VPN) { + if (properties.Type == CrOnc.Type.VPN) { fields.push('VPN.Host', 'VPN.Type'); - if (state.VPN.Type == 'OpenVPN') + if (properties.VPN.Type == 'OpenVPN') fields.push('VPN.OpenVPN.Username'); - else if (state.VPN.Type == 'L2TP-IPsec') + else if (properties.VPN.Type == 'L2TP-IPsec') fields.push('VPN.L2TP.Username'); - else if (state.VPN.Type == 'ThirdPartyVPN') + else if (properties.VPN.Type == 'ThirdPartyVPN') fields.push('VPN.ThirdPartyVPN.ProviderName'); } - if (state.Type == CrOnc.Type.WI_FI) + if (properties.Type == CrOnc.Type.WI_FI) fields.push('RestrictedConnectivity'); - if (state.Type == CrOnc.Type.WI_MAX) { + if (properties.Type == CrOnc.Type.WI_MAX) { fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity'); } return fields; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {!Array<string>} The fields to display in the Advanced section. * @private */ - getAdvancedFields_: function(state) { + getAdvancedFields_: function(properties) { /** @type {!Array<string>} */ var fields = []; - if (!state) + if (!properties) return fields; fields.push('MacAddress'); - if (state.Type == CrOnc.Type.CELLULAR) { + if (properties.Type == CrOnc.Type.CELLULAR) { fields.push('Cellular.Carrier', 'Cellular.Family', 'Cellular.NetworkTechnology', 'Cellular.ServingOperator.Code'); } - if (state.Type == CrOnc.Type.WI_FI) { + if (properties.Type == CrOnc.Type.WI_FI) { fields.push('WiFi.SSID', 'WiFi.BSSID', 'WiFi.Security', 'WiFi.SignalStrength', 'WiFi.Frequency'); } - if (state.Type == CrOnc.Type.WI_MAX) + if (properties.Type == CrOnc.Type.WI_MAX) fields.push('WiFi.SignalStrength'); return fields; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {!Array<string>} The fields to display in the device section. * @private */ - getDeviceFields_: function(state) { + getDeviceFields_: function(properties) { /** @type {!Array<string>} */ var fields = []; - if (!state) + if (!properties) return fields; - if (state.Type == CrOnc.Type.CELLULAR) { + if (properties.Type == CrOnc.Type.CELLULAR) { fields.push('Cellular.HomeProvider.Name', 'Cellular.HomeProvider.Country', 'Cellular.HomeProvider.Code', @@ -613,53 +612,53 @@ Polymer({ }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if there are any advanced fields to display. * @private */ - hasAdvancedOrDeviceFields_: function(state) { - return this.getAdvancedFields_(state).length > 0 || - this.hasDeviceFields_(state); + hasAdvancedOrDeviceFields_: function(properties) { + return this.getAdvancedFields_(properties).length > 0 || + this.hasDeviceFields_(properties); }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if there are any device fields to display. * @private */ - hasDeviceFields_: function(state) { - var fields = this.getDeviceFields_(state); + hasDeviceFields_: function(properties) { + var fields = this.getDeviceFields_(properties); return fields.length > 0; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if the network section should be shown. * @private */ - hasNetworkSection_: function(state) { - return !!state && state.Type != CrOnc.Type.VPN; + hasNetworkSection_: function(properties) { + return !!properties && properties.Type != CrOnc.Type.VPN; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @param {string} type The network type. * @return {boolean} True if the network type matches 'type'. * @private */ - isType_: function(state, type) { - return !!state && state.Type == type; + isType_: function(properties, type) { + return !!properties && properties.Type == type; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!CrOnc.NetworkProperties} properties * @return {boolean} True if the Cellular SIM section should be shown. * @private */ - showCellularSim_: function(state) { - if (!state || state.Type != 'Cellular') + showCellularSim_: function(properties) { + if (!properties || properties.Type != 'Cellular' || !properties.Cellular) return false; - return CrOnc.getActiveValue(state, 'Cellular.Family') == 'GSM'; + return CrOnc.getActiveValue(properties.Cellular.Family) == 'GSM'; }, /** diff --git a/chrome/browser/resources/settings/internet_page/network_apnlist.html b/chrome/browser/resources/settings/internet_page/network_apnlist.html index 332db298..2d53bbe 100644 --- a/chrome/browser/resources/settings/internet_page/network_apnlist.html +++ b/chrome/browser/resources/settings/internet_page/network_apnlist.html @@ -19,9 +19,9 @@ </select> </div> <div id="otherDiv" class="layout vertical" - hidden$="[[!isOtherSelected_(networkState, selectedApn)]]"> + hidden$="[[!isOtherSelected_(networkProperties, selectedApn)]]"> <network-property-list - fields="[[otherApnFields_]]" network-state="[[otherApn]]" + fields="[[otherApnFields_]]" property-dict="[[otherApn]]" edit-field-types="[[otherApnEditTypes_]]" on-property-change="onOtherApnChange_"> </network-property-list> diff --git a/chrome/browser/resources/settings/internet_page/network_apnlist.js b/chrome/browser/resources/settings/internet_page/network_apnlist.js index 02cdf8e..71a2adf 100644 --- a/chrome/browser/resources/settings/internet_page/network_apnlist.js +++ b/chrome/browser/resources/settings/internet_page/network_apnlist.js @@ -14,12 +14,12 @@ Polymer({ properties: { /** - * The current state for the network matching |guid|. - * @type {CrOnc.NetworkStateProperties|undefined} + * The current set of properties for the network matching |guid|. + * @type {!CrOnc.NetworkProperties|undefined} */ - networkState: { + networkProperties: { type: Object, - observer: 'networkStateChanged_' + observer: 'networkPropertiesChanged_' }, /** @@ -81,14 +81,14 @@ Polymer({ /** @const */ DefaultAccessPointName: 'none', /** - * Polymer networkState changed method. + * Polymer networkProperties changed method. */ - networkStateChanged_: function() { - if (!this.networkState || !this.networkState.Cellular) + networkPropertiesChanged_: function() { + if (!this.networkProperties || !this.networkProperties.Cellular) return; - var activeApn = null; - var cellular = this.networkState.Cellular; + var activeApn; + var cellular = this.networkProperties.Cellular; if (cellular.APN && cellular.APN.AccessPointName) activeApn = cellular.APN; else if (cellular.LastGoodAPN && cellular.LastGoodAPN.AccessPointName) @@ -99,14 +99,15 @@ Polymer({ /** * Sets the list of selectable APNs for the UI. Appends an 'Other' entry * (see comments for |otherApn| above). - * @param {?CrOnc.APNProperties} activeApn The currently active APN value. + * @param {CrOnc.APNProperties|undefined} activeApn The currently active APN + * properties. * @private */ setApnSelectList_: function(activeApn) { - // Copy the list of APNs from this.networkState. + // Copy the list of APNs from this.networkProperties. var result = this.getApnList_().slice(); - // Test whether |activeApn| is in the current APN list in this.networkState. + // Test whether |activeApn| is in the current APN list in networkProperties. var activeApnInList = activeApn && result.some( function(a) { return a.AccessPointName == activeApn.AccessPointName; }); @@ -137,7 +138,7 @@ Polymer({ }, /** - * @param {?CrOnc.APNProperties=} apnProperties + * @param {!CrOnc.APNProperties|undefined=} apnProperties * @return {!CrOnc.APNProperties} A new APN object with properties from * |apnProperties| if provided. * @private @@ -151,13 +152,13 @@ Polymer({ /** * @return {!Array<!CrOnc.APNProperties>} The list of APN properties in - * |networkState| or an empty list if the property is not set. + * |networkProperties| or an empty list if the property is not set. * @private */ getApnList_: function() { - var apnList = /** @type {Array<!CrOnc.APNProperties>|undefined} */( - this.get('networkState.Cellular.APNList')); - return apnList || []; + if (!this.networkProperties || !this.networkProperties.Cellular) + return []; + return this.networkProperties.Cellular.APNList || []; }, /** @@ -181,7 +182,7 @@ Polymer({ var selectedApn = event.target.value; // When selecting 'Other', don't set a change event unless a valid // non-default value has been set for Other. - if (this.isOtherSelected_(this.networkState, selectedApn) && + if (this.isOtherSelected_(this.networkProperties, selectedApn) && (!this.otherApn || !this.otherApn.AccessPointName || this.otherApn.AccessPointName == this.DefaultAccessPointName)) { return; @@ -228,13 +229,13 @@ Polymer({ }, /** - * @param {CrOnc.NetworkStateProperties|undefined} networkState + * @param {!CrOnc.NetworkProperties|undefined} networkProperties * @param {string} selectedApn * @return {boolean} True if the 'other' APN is currently selected. * @private */ - isOtherSelected_: function(networkState, selectedApn) { - if (!networkState || !networkState.Cellular) + isOtherSelected_: function(networkProperties, selectedApn) { + if (!networkProperties || !networkProperties.Cellular) return false; var apnList = this.getApnList_(); var apn = this.findApnInList(apnList, selectedApn); diff --git a/chrome/browser/resources/settings/internet_page/network_ip_config.html b/chrome/browser/resources/settings/internet_page/network_ip_config.html index 9d4a239..0245787 100644 --- a/chrome/browser/resources/settings/internet_page/network_ip_config.html +++ b/chrome/browser/resources/settings/internet_page/network_ip_config.html @@ -11,7 +11,7 @@ Configure IP Address Automatically </paper-checkbox> <network-property-list - fields="[[ipConfigFields_]]" network-state="[[ipConfig]]" + fields="[[ipConfigFields_]]" property-dict="[[ipConfig]]" edit-field-types="[[getIPEditFields_(ipConfig, editable, automatic)]]" on-property-change="onIPChange_"> </network-property-list> diff --git a/chrome/browser/resources/settings/internet_page/network_ip_config.js b/chrome/browser/resources/settings/internet_page/network_ip_config.js index f883266..a1d10e0 100644 --- a/chrome/browser/resources/settings/internet_page/network_ip_config.js +++ b/chrome/browser/resources/settings/internet_page/network_ip_config.js @@ -15,13 +15,13 @@ Polymer({ properties: { /** - * The current state containing the IP Config properties to display and - * modify. - * @type {CrOnc.NetworkStateProperties|undefined} + * The network properties dictionary containing the IP Config properties to + * display and modify. + * @type {!CrOnc.NetworkProperties|undefined} */ - networkState: { + networkProperties: { type: Object, - observer: 'networkStateChanged_' + observer: 'networkPropertiesChanged_' }, /** @@ -45,13 +45,13 @@ Polymer({ /** * The currently visible IP Config property dictionary. The 'RoutingPrefix' * property is a human-readable mask instead of a prefix length. - * @type {{ + * @type {!{ * ipv4: !CrOnc.IPConfigUIProperties, * ipv6: !CrOnc.IPConfigUIProperties * }|undefined} */ ipConfig: { - type: Object, + type: Object }, /** @@ -74,28 +74,30 @@ Polymer({ /** * Saved static IP configuration properties when switching to 'automatic'. - * @type {?CrOnc.IPConfigUIProperties} + * @type {!CrOnc.IPConfigUIProperties|undefined} */ - savedStaticIp_: null, + savedStaticIp_: undefined, /** - * Polymer networkState changed method. + * Polymer networkProperties changed method. */ - networkStateChanged_: function(newValue, oldValue) { - if (!this.networkState) + networkPropertiesChanged_: function(newValue, oldValue) { + if (!this.networkProperties) return; if (newValue.GUID != (oldValue && oldValue.GUID)) - this.savedStaticIp_ = null; + this.savedStaticIp_ = undefined; // Update the 'automatic' property. var ipConfigType = - CrOnc.getActiveValue(this.networkState, 'IPAddressConfigType'); + CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType); this.automatic = (ipConfigType != CrOnc.IPConfigType.STATIC); // Update the 'ipConfig' property. - var ipv4 = CrOnc.getIPConfigForType(this.networkState, CrOnc.IPType.IPV4); - var ipv6 = CrOnc.getIPConfigForType(this.networkState, CrOnc.IPType.IPV6); + var ipv4 = + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); + var ipv6 = + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV6); this.ipConfig = { ipv4: this.getIPConfigUIProperties_(ipv4), ipv6: this.getIPConfigUIProperties_(ipv6) @@ -133,7 +135,7 @@ Polymer({ }, /** - * @param {?CrOnc.IPConfigProperties} ipconfig The IP Config properties. + * @param {!CrOnc.IPConfigProperties|undefined} ipconfig * @return {!CrOnc.IPConfigUIProperties} A new IPConfigUIProperties object * with RoutingPrefix expressed as a string mask instead of a prefix * length. Returns an empty object if |ipconfig| is undefined. @@ -172,7 +174,7 @@ Polymer({ }, /** - * @param {!CrOnc.IPConfigUIProperties} ipConfig The IP Config properties. + * @param {!CrOnc.IPConfigUIProperties} ipConfig The IP Config UI properties. * @param {boolean} editable The editable property. * @param {boolean} automatic The automatic property. * @return {Object} An object with the edit type for each editable field. diff --git a/chrome/browser/resources/settings/internet_page/network_nameservers.js b/chrome/browser/resources/settings/internet_page/network_nameservers.js index 9dc4478..983c45b 100644 --- a/chrome/browser/resources/settings/internet_page/network_nameservers.js +++ b/chrome/browser/resources/settings/internet_page/network_nameservers.js @@ -13,13 +13,13 @@ Polymer({ properties: { /** - * The current state containing the IP Config properties to display and - * modify. - * @type {CrOnc.NetworkStateProperties|undefined} + * The network properties dictionary containing the nameserver properties to + * display and modify. + * @type {!CrOnc.NetworkProperties|undefined} */ - networkState: { + networkProperties: { type: Object, - observer: 'networkStateChanged_' + observer: 'networkPropertiesChanged_' }, /** @@ -66,10 +66,10 @@ Polymer({ savedNameservers_: [], /** - * Polymer networkState changed method. + * Polymer networkProperties changed method. */ - networkStateChanged_: function(newValue, oldValue) { - if (!this.networkState) + networkPropertiesChanged_: function(newValue, oldValue) { + if (!this.networkProperties) return; if (!oldValue || newValue.GUID != oldValue.GUID) @@ -77,13 +77,14 @@ Polymer({ // Update the 'nameservers' property. var nameservers = []; - var ipv4 = CrOnc.getIPConfigForType(this.networkState, CrOnc.IPType.IPV4); + var ipv4 = + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); if (ipv4 && ipv4.NameServers) nameservers = ipv4.NameServers; // Update the 'nameserversType' property. var configType = - CrOnc.getActiveValue(this.networkState, 'NameServersConfigType'); + CrOnc.getActiveValue(this.networkProperties.NameServersConfigType); var type; if (configType == CrOnc.IPConfigType.STATIC) { if (nameservers.join(',') == this.GoogleNameservers.join(',')) diff --git a/chrome/browser/resources/settings/internet_page/network_property_list.html b/chrome/browser/resources/settings/internet_page/network_property_list.html index 345441bf..79db6d9 100644 --- a/chrome/browser/resources/settings/internet_page/network_property_list.html +++ b/chrome/browser/resources/settings/internet_page/network_property_list.html @@ -10,7 +10,7 @@ <div class="layout vertical"> <template is="dom-repeat" items="[[fields]]"> <div class="layout horizontal" - hidden$="[[!showProperty_(networkState, editFieldTypes, item)]]"> + hidden$="[[!showProperty_(propertyDict, editFieldTypes, item)]]"> <span>[[getPropertyLabel_(item)]]</span> <span class="flex fill"></span> </div> @@ -19,14 +19,14 @@ <div class="layout vertical"> <template is="dom-repeat" items="[[fields]]"> <div class="layout horizontal" - hidden$="[[!showNoEdit_(networkState, editFieldTypes, item)]]"> - <span>[[getPropertyValue_(networkState, item)]]</span> + hidden$="[[!showNoEdit_(propertyDict, editFieldTypes, item)]]"> + <span>[[getPropertyValue_(propertyDict, item)]]</span> </div> <div class="layout horizontal" hidden$= - "[[!showEdit_(networkState, editFieldTypes, item, 'String')]]"> + "[[!showEdit_(propertyDict, editFieldTypes, item, 'String')]]"> <paper-input-container no-label-float> <input id="[[item]]" is="iron-input" - value="[[getPropertyValue_(networkState, item)]]" + value="[[getPropertyValue_(propertyDict, item)]]" on-blur="onValueChange_"> </paper-input-container> </div> diff --git a/chrome/browser/resources/settings/internet_page/network_property_list.js b/chrome/browser/resources/settings/internet_page/network_property_list.js index bc943e5..1483895 100644 --- a/chrome/browser/resources/settings/internet_page/network_property_list.js +++ b/chrome/browser/resources/settings/internet_page/network_property_list.js @@ -3,8 +3,8 @@ // found in the LICENSE file. /** - * @fileoverview Polymer element for displaying a list of network state - * properties in a list in the format: + * @fileoverview Polymer element for displaying a list of network properties + * in a list in the format: * Key1.........Value1 * KeyTwo.......ValueTwo * This also supports editing fields inline for fields listed in editFieldTypes: @@ -16,10 +16,9 @@ Polymer({ properties: { /** - * The network state containing the properties to display. - * @type {CrOnc.NetworkStateProperties|undefined} + * The dictionary containing the properties to display. */ - networkState: { + propertyDict: { type: Object }, @@ -55,10 +54,14 @@ Polymer({ * @private */ onValueChange_: function(event) { - if (!this.networkState) + if (!this.propertyDict) return; var field = event.target.id; - var curValue = CrOnc.getActiveValue(this.networkState, field); + var curValue = this.get(field, this.propertyDict); + if (typeof curValue == 'object') { + // Extract the property from an ONC managed dictionary. + curValue = CrOnc.getActiveValue(/** @type {!Object} */(curValue)); + } var newValue = event.target.value; if (newValue == curValue) return; @@ -76,70 +79,77 @@ Polymer({ }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!Object|undefined} propertyDict * @param {string} key The property key. - * @return {boolean} Whether or not the property exists in |state|. + * @return {boolean} Whether or not the property exists in |propertyDict|. * @private */ - hasPropertyValue_: function(state, key) { - var value = (state && this.get(key, state)) || undefined; + hasPropertyValue_: function(propertyDict, key) { + var value = (propertyDict && this.get(key, propertyDict)) || undefined; return (value !== undefined && value !== ''); }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. - * @param {Object} editFieldTypes The editFieldTypes object. + * @param {!Object|undefined} propertyDict + * @param {!Object} editFieldTypes The editFieldTypes object. * @param {string} key The property key. * @return {boolean} Whether or not to show the property. Editable properties * are always shown. * @private */ - showProperty_: function(state, editFieldTypes, key) { + showProperty_: function(propertyDict, editFieldTypes, key) { if (editFieldTypes.hasOwnProperty(key)) return true; - return this.hasPropertyValue_(state, key); + return this.hasPropertyValue_(propertyDict, key); }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. - * @param {Object} editFieldTypes The editFieldTypes object. + * @param {!Object|undefined} propertyDict + * @param {!Object} editFieldTypes The editFieldTypes object. * @param {string} key The property key. - * @return {boolean} True if |key| exists in |state| and is not editable. + * @return {boolean} True if |key| exists in |propertiesDict| and is not + * editable. * @private */ - showNoEdit_: function(state, editFieldTypes, key) { - if (!this.hasPropertyValue_(state, key)) + showNoEdit_: function(propertyDict, editFieldTypes, key) { + if (!this.hasPropertyValue_(propertyDict, key)) return false; var editType = editFieldTypes[key]; return !editType; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. - * @param {Object} editFieldTypes The editFieldTypes object. + * @param {!Object|undefined} propertyDict + * @param {!Object} editFieldTypes The editFieldTypes object. * @param {string} key The property key. * @param {string} type The field type. - * @return {boolean} True if |key| exists in |state| and is of editable + * @return {boolean} True if |key| exists in |propertyDict| and is of editable * type |type|. * @private */ - showEdit_: function(state, editFieldTypes, key, type) { + showEdit_: function(propertyDict, editFieldTypes, key, type) { return editFieldTypes[key] == type; }, /** - * @param {?CrOnc.NetworkStateProperties} state The network state properties. + * @param {!Object|undefined} propertyDict * @param {string} key The property key. * @return {string} The text to display for the property value. * @private */ - getPropertyValue_: function(state, key) { - if (!state) + getPropertyValue_: function(propertyDict, key) { + if (!propertyDict) return ''; - var value = CrOnc.getActiveValue(state, key); + var value = this.get(key, propertyDict); if (value === undefined) return ''; + if (typeof value == 'object') { + // Extract the property from an ONC managed dictionary + value = CrOnc.getActiveValue(/** @type {!Object} */(value)); + } // TODO(stevenjb): Localize. + if (typeof value == 'number' || typeof value == 'boolean') + return value.toString(); return /** @type {string} */(value); }, }); diff --git a/chrome/browser/resources/settings/internet_page/network_proxy.js b/chrome/browser/resources/settings/internet_page/network_proxy.js index 995ef3e..fc6ff4c 100644 --- a/chrome/browser/resources/settings/internet_page/network_proxy.js +++ b/chrome/browser/resources/settings/internet_page/network_proxy.js @@ -11,13 +11,13 @@ Polymer({ properties: { /** - * The current state containing the IP Config properties to display and - * modify. - * @type {CrOnc.NetworkStateProperties|undefined} + * The network properties dictionary containing the proxy properties to + * display and modify. + * @type {!CrOnc.NetworkProperties|undefined} */ - networkState: { + networkProperties: { type: Object, - observer: 'networkStateChanged_' + observer: 'networkPropertiesChanged_' }, /** @@ -38,7 +38,7 @@ Polymer({ }, /** - * The Web Proxy Auto Discovery URL extracted from networkState. + * The Web Proxy Auto Discovery URL extracted from networkProperties. */ WPAD: { type: String, @@ -102,15 +102,14 @@ Polymer({ savedExcludeDomains_: undefined, /** - * Polymer networkState changed method. + * Polymer networkProperties changed method. */ - networkStateChanged_: function() { - if (!this.networkState) + networkPropertiesChanged_: function() { + if (!this.networkProperties) return; var defaultProxy = this.createDefaultProxySettings_(); - var proxy = /** @type {CrOnc.ProxySettings} */( - this.get('networkState.ProxySettings') || {}); + var proxy = this.networkProperties.ProxySettings || {}; // Ensure that all proxy settings object properties are specified. proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_ || @@ -131,7 +130,8 @@ Polymer({ this.$.selectType.value = proxy.Type; // Set the Web Proxy Auto Discovery URL. - var ipv4 = CrOnc.getIPConfigForType(this.networkState, CrOnc.IPType.IPV4); + var ipv4 = + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); this.WPAD = (ipv4 && ipv4.WebProxyAutoDiscoveryUrl) || ''; }, diff --git a/chrome/browser/resources/settings/internet_page/network_proxy_input.js b/chrome/browser/resources/settings/internet_page/network_proxy_input.js index 480fbba..6093bd4 100644 --- a/chrome/browser/resources/settings/internet_page/network_proxy_input.js +++ b/chrome/browser/resources/settings/internet_page/network_proxy_input.js @@ -30,7 +30,7 @@ Polymer({ /** * The proxy object. - * @type {?CrOnc.ProxyLocation} + * @type {!CrOnc.ProxyLocation} */ value: { type: Object, diff --git a/chrome/browser/resources/settings/internet_page/network_siminfo.html b/chrome/browser/resources/settings/internet_page/network_siminfo.html index dd5477c..03450ad 100644 --- a/chrome/browser/resources/settings/internet_page/network_siminfo.html +++ b/chrome/browser/resources/settings/internet_page/network_siminfo.html @@ -20,22 +20,22 @@ <div class="layout vertical" hidden$="[[!state.Cellular.SIMPresent]]"> <div id="lockedDiv" class="layout horizontal center" - hidden$="[[!isSimLocked_(networkState)]]"> + hidden$="[[!isSimLocked_(networkProperties)]]"> <!-- SIM locked --> <iron-icon icon="lock"></iron-icon> <span>SIM card is locked.</span> <paper-button on-tap="unlockPin_">Unlock</paper-button> </div> <div class="layout vertical" - hidden$="[[isSimLocked_(networkState)]]"> + hidden$="[[isSimLocked_(networkProperties)]]"> <!-- SIM unlocked --> <paper-checkbox - checked="[[networkState.Cellular.SIMLockStatus.LockEnabled]]" + checked="[[networkProperties.Cellular.SIMLockStatus.LockEnabled]]" on-change="onSimLockEnabledChange_"> Enable SIM card locking (require PIN to use mobile data) </paper-checkbox> <div class="layout horizontal center" - hidden$="[[!networkState.Cellular.SIMLockStatus.LockEnabled]]"> + hidden$="[[!networkProperties.Cellular.SIMLockStatus.LockEnabled]]"> <!-- SIM lock enabled --> <paper-button on-tap="onChangePin_">Change PIN</paper-button> </div> @@ -60,7 +60,7 @@ <span class="error" hidden$="[[!showError_(error)]]" >[[getErrorMsg_(error)]] </span> - <span>[[getRetriesLeftMsg_(networkState)]]</span> + <span>[[getRetriesLeftMsg_(networkProperties)]]</span> </div> </div> </paper-dialog> @@ -88,7 +88,7 @@ <span class="error" hidden$="[[!showError_(error)]]" >[[getErrorMsg_(error)]] </span> - <span>[[getRetriesLeftMsg_(networkState)]]</span> + <span>[[getRetriesLeftMsg_(networkProperties)]]</span> </div> </div> </paper-dialog> @@ -108,7 +108,7 @@ <span class="error" hidden$="[[!showError_(error)]]" >[[getErrorMsg_(error)]] </span> - <span>[[getRetriesLeftMsg_(networkState)]]</span> + <span>[[getRetriesLeftMsg_(networkProperties)]]</span> </div> </div> </paper-dialog> @@ -148,7 +148,7 @@ <span class="error" hidden$="[[!showError_(error)]]" >[[getErrorMsg_(error)]] </span> - <span>[[getRetriesLeftMsg_(networkState)]]</span> + <span>[[getRetriesLeftMsg_(networkProperties)]]</span> </div> </div> </paper-dialog> diff --git a/chrome/browser/resources/settings/internet_page/network_siminfo.js b/chrome/browser/resources/settings/internet_page/network_siminfo.js index 69ab211..d93268c 100644 --- a/chrome/browser/resources/settings/internet_page/network_siminfo.js +++ b/chrome/browser/resources/settings/internet_page/network_siminfo.js @@ -26,12 +26,12 @@ Polymer({ properties: { /** - * The network state associated with the element. - * @type {CrOnc.NetworkStateProperties|undefined} + * The network properties associated with the element. + * @type {!CrOnc.NetworkProperties|undefined} */ - networkState: { + networkProperties: { type: Object, - observer: 'networkStateChanged_' + observer: 'networkPropertiesChanged_' }, /** Set to true when a PUK is required to unlock the SIM. */ @@ -53,17 +53,16 @@ Polymer({ sendSimLockEnabled_: false, - /** Polymer networkState changed method. */ - networkStateChanged_: function() { - if (!this.networkState || !this.networkState.Cellular) + /** Polymer networkProperties changed method. */ + networkPropertiesChanged_: function() { + if (!this.networkProperties || !this.networkProperties.Cellular) return; - var simLockStatus = /** @type {CrOnc.SIMLockStatus|undefined} */( - this.get('networkState.Cellular.SIMLockStatus')); + var simLockStatus = this.networkProperties.Cellular.SIMLockStatus; this.pukRequired = !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK; }, - /** Polymer networkState changed method. */ + /** Polymer networkProperties changed method. */ pukRequiredChanged_: function() { if (this.$.unlockPukDialog.opened) { if (this.pukRequired) @@ -99,9 +98,9 @@ Polymer({ this.$.unlockPuk.focus(); }, - /** Polymer networkState changed method. */ + /** Polymer networkProperties changed method. */ onSimLockEnabledChange_: function(event) { - if (!this.networkState || !this.networkState.Cellular) + if (!this.networkProperties || !this.networkProperties.Cellular) return; this.sendSimLockEnabled_ = event.target.checked; this.error = ErrorType.NONE; @@ -124,7 +123,7 @@ Polymer({ * @private */ sendEnterPin_: function(event) { - var guid = this.networkState && this.networkState.GUID; + var guid = this.networkProperties && this.networkProperties.GUID; if (!guid) return; @@ -152,7 +151,7 @@ Polymer({ * @private */ onChangePin_: function(event) { - if (!this.networkState || !this.networkState.Cellular) + if (!this.networkProperties || !this.networkProperties.Cellular) return; this.error = ErrorType.NONE; this.$.changePinDialog.open(); @@ -176,7 +175,7 @@ Polymer({ * @private */ sendChangePin_: function(event) { - var guid = this.networkState && this.networkState.GUID; + var guid = this.networkProperties && this.networkProperties.GUID; if (!guid) return; @@ -225,7 +224,7 @@ Polymer({ * @private */ sendUnlockPin_: function(event) { - var guid = this.networkState && this.networkState.GUID; + var guid = this.networkProperties && this.networkProperties.GUID; if (!guid) return; var pin = this.$.unlockPin.value; @@ -270,7 +269,7 @@ Polymer({ * @private */ sendUnlockPuk_: function(event) { - var guid = this.networkState && this.networkState.GUID; + var guid = this.networkProperties && this.networkProperties.GUID; if (!guid) return; @@ -292,22 +291,22 @@ Polymer({ }, /** - * @param {?CrOnc.NetworkStateProperties} state + * @param {!CrOnc.NetworkProperties|undefined} networkProperties * @return {boolean} True if the Cellular SIM is locked. * @private */ - isSimLocked_: function(state) { - return !!state && CrOnc.isSimLocked(state); + isSimLocked_: function(networkProperties) { + return !!networkProperties && CrOnc.isSimLocked(networkProperties); }, /** - * @param {?CrOnc.NetworkStateProperties} state + * @param {!CrOnc.NetworkProperties|undefined} networkProperties * @return {string} The message for the number of retries left. * @private */ - getRetriesLeftMsg_: function(state) { + getRetriesLeftMsg_: function(networkProperties) { var retriesLeft = - this.get('Cellular.SIMLockStatus.RetriesLeft', state) || 0; + this.get('Cellular.SIMLockStatus.RetriesLeft', networkProperties) || 0; // TODO(stevenjb): Localize return 'Retries left: ' + retriesLeft.toString(); }, diff --git a/chrome/browser/resources/settings/internet_page/network_summary.js b/chrome/browser/resources/settings/internet_page/network_summary.js index f0dc33a..3086221 100644 --- a/chrome/browser/resources/settings/internet_page/network_summary.js +++ b/chrome/browser/resources/settings/internet_page/network_summary.js @@ -23,11 +23,11 @@ var DeviceStateObject; /** * @typedef {{ - * Ethernet: (?CrOnc.NetworkStateProperties|undefined), - * WiFi: (?CrOnc.NetworkStateProperties|undefined), - * Cellular: (?CrOnc.NetworkStateProperties|undefined), - * WiMAX: (?CrOnc.NetworkStateProperties|undefined), - * VPN: (?CrOnc.NetworkStateProperties|undefined) + * Ethernet: (!CrOnc.NetworkStateProperties|undefined), + * WiFi: (!CrOnc.NetworkStateProperties|undefined), + * Cellular: (!CrOnc.NetworkStateProperties|undefined), + * WiMAX: (!CrOnc.NetworkStateProperties|undefined), + * VPN: (!CrOnc.NetworkStateProperties|undefined) * }} */ var NetworkStateObject; @@ -322,10 +322,10 @@ Polymer({ }, this); // Set any types with a deviceState and no network to a default state, - // and any types not found to null. + // and any types not found to undefined. NETWORK_TYPES.forEach(function(type) { if (!foundTypes[type]) { - var defaultState = /** @type {?CrOnc.NetworkStateProperties} */(null); + var defaultState = undefined; if (this.deviceStates[type]) defaultState = {GUID: '', Type: type}; this.updateNetworkState_(type, defaultState); @@ -345,9 +345,9 @@ Polymer({ * Sets 'networkStates[type]' which will update the cr-network-list-item * associated with 'type'. * @param {string} type The network type. - * @param {?CrOnc.NetworkStateProperties} state The state properties for the - * network to associate with |type|. May be null if there are no networks - * matching |type|. + * @param {!CrOnc.NetworkStateProperties|undefined} state The state properties + * for the network to associate with |type|. May be undefined if there are + * no networks matching |type|. * @private */ updateNetworkState_: function(type, state) { diff --git a/chrome/browser/resources/settings/internet_page/network_summary_item.js b/chrome/browser/resources/settings/internet_page/network_summary_item.js index 426f8117..67e7a1b 100644 --- a/chrome/browser/resources/settings/internet_page/network_summary_item.js +++ b/chrome/browser/resources/settings/internet_page/network_summary_item.js @@ -53,7 +53,7 @@ Polymer({ /** * Network state for the active network. - * @type {CrOnc.NetworkStateProperties|undefined} + * @type {!CrOnc.NetworkStateProperties|undefined} */ networkState: { type: Object, @@ -158,7 +158,7 @@ Polymer({ }, /** - * @param {CrOnc.NetworkStateProperties} state + * @param {!CrOnc.NetworkStateProperties} state * @param {boolean} expanded The expanded state. * @return {boolean} True if the 'Known networks' button should be shown. * @private diff --git a/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js b/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js index 33740bf..bcba371 100644 --- a/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js +++ b/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js @@ -483,6 +483,7 @@ var availableTests = [ Carrier: 'Cellular1_Carrier', Family: 'GSM', HomeProvider: { + Code: '000000', Country: 'us', Name: 'Cellular1_Provider' }, diff --git a/components/onc/docs/onc_spec.html b/components/onc/docs/onc_spec.html index f5f342e..df43eb8 100644 --- a/components/onc/docs/onc_spec.html +++ b/components/onc/docs/onc_spec.html @@ -2250,7 +2250,7 @@ <dt class="field">HomeProvider</dt> <dd> <span class="field_meta">(optional, read-only) - <span class="type">array of CellularProvider</span> + <span class="type">CellularProvider</span> </span> Description of the operator that issued the SIM card currently installed in the modem. diff --git a/extensions/common/api/networking_private.idl b/extensions/common/api/networking_private.idl index b813e34..64ef51e 100644 --- a/extensions/common/api/networking_private.idl +++ b/extensions/common/api/networking_private.idl @@ -72,14 +72,10 @@ namespace networkingPrivate { DOMString? Username; }; - dictionary CellularConfigProperties { - boolean? AutoConnect; - APNProperties? APN; - - // Specifies which carrier to use for Cellular configurations that support - // multiple carriers. May be set with $(ref:setProperties), but will be - // ignored by $(ref:createConfiguration). - DOMString? Carrier; + dictionary CellularProviderProperties { + DOMString Name; + DOMString Code; + DOMString? Country; }; dictionary CellularSimState { @@ -93,12 +89,18 @@ namespace networkingPrivate { DOMString? newPin; }; - dictionary CellularStateProperties { - ActivationStateType? ActivationState; - DOMString? NetworkTechnology; - DOMString? RoamingState; - boolean? SIMPresent; - long? SignalStrength; + dictionary IssuerSubjectPattern { + DOMString? CommonName; + DOMString? Locality; + DOMString? Organization; + DOMString? OrganizationalUnit; + }; + + dictionary CertificatePattern { + DOMString[]? EnrollmentURI; + IssuerSubjectPattern? Issuer; + DOMString[]? IssuerCARef; + IssuerSubjectPattern? Subject; }; dictionary DeviceStateProperties { @@ -120,8 +122,27 @@ namespace networkingPrivate { NetworkType Type; }; - dictionary EthernetStateProperties { - DOMString Authentication; + dictionary EAPProperties { + DOMString? AnonymousIdentity; + CertificatePattern? ClientCertPattern; + DOMString? ClientCertRef; + DOMString? ClientCertType; + DOMString? Identity; + DOMString? Inner; + DOMString Outer; + DOMString? Password; + boolean? SaveCredentials; + DOMString[]? ServerCARefs; + boolean? UseProactiveKeyCaching; + boolean? UseSystemCAs; + }; + + dictionary FoundNetworkProperties { + DOMString Status; + DOMString NetworkId; + DOMString Technology; + DOMString? ShortName; + DOMString? LongName; }; dictionary IPConfigProperties { @@ -133,8 +154,37 @@ namespace networkingPrivate { DOMString? WebProxyAutoDiscoveryUrl; }; + dictionary XAUTHProperties { + DOMString? Password; + boolean? SaveCredentials; + DOMString? Username; + }; + dictionary IPSecProperties { DOMString AuthenticationType; + CertificatePattern? ClientCertPattern; + DOMString? ClientCertRef; + DOMString? ClientCertType; + EAPProperties? EAP; + DOMString? Group; + long? IKEVersion; + DOMString? PSK; + boolean? SaveCredentials; + DOMString[]? ServerCARefs; + XAUTHProperties? XAUTH; + }; + + dictionary L2TPProperties { + boolean? LcpEchoDisabled; + DOMString? Password; + boolean? SaveCredentials; + DOMString? Username; + }; + + dictionary PaymentPortal { + DOMString Method; + DOMString? PostData; + DOMString? Url; }; dictionary ProxyLocation { @@ -156,11 +206,52 @@ namespace networkingPrivate { DOMString? PAC; }; + dictionary VerifyX509 { + DOMString? Name; + DOMString? Type; + }; + dictionary OpenVPNProperties { + DOMString? Auth; + DOMString? AuthRetry; + boolean? AuthNoCache; + DOMString? Cipher; + DOMString? ClientCertRef; + CertificatePattern? ClientCertPattern; + DOMString? ClientCertType; + DOMString? CompLZO; + boolean? CompNoAdapt; + boolean? IgnoreDefaultRoute; + DOMString? KeyDirection; + DOMString? NsCertType; DOMString? OTP; DOMString? Password; + long? Port; + DOMString? Proto; + DOMString? PushPeerInfo; + DOMString? RemoteCertEKU; + DOMString[]? RemoteCertKU; + DOMString? RemoteCertTLS; + long? RenegSec; + boolean? SaveCredentials; + DOMString[]? ServerCARefs; + DOMString? ServerCertRef; + long? ServerPollTimeout; + long? Shaper; + DOMString? StaticChallenge; + DOMString? TLSAuthContents; + DOMString? TLSRemote; DOMString? UserAuthenticationType; DOMString? Username; + DOMString? Verb; + DOMString? VerifyHash; + VerifyX509? VerifyX509; + }; + + dictionary SIMLockStatus { + DOMString LockType; // sim-pin, sim-puk, or '' + boolean LockEnabled; + long? RetriesLeft; }; dictionary ThirdPartyVPNProperties { @@ -168,9 +259,61 @@ namespace networkingPrivate { DOMString? ProviderName; }; - dictionary VPNConfigProperties { + dictionary CellularProperties { + boolean? AutoConnect; + APNProperties? APN; + APNProperties[]? APNList; + DOMString? ActivationType; + ActivationStateType? ActivationState; + boolean? AllowRoaming; + DOMString? Carrier; + DOMString? ESN; + DOMString? Family; + DOMString? FirmwareRevision; + FoundNetworkProperties[]? FoundNetworks; + DOMString? HardwareRevision; + CellularProviderProperties? HomeProvider; + DOMString? ICCID; + DOMString? IMEI; + APNProperties? LastGoodAPN; + DOMString? Manufacturer; + DOMString? MDN; + DOMString? MEID; + DOMString? MIN; + DOMString? ModelID; + DOMString? NetworkTechnology; + PaymentPortal? PaymentPortal; + long? PRLVersion; + DOMString? RoamingState; + CellularProviderProperties? ServingOperator; + SIMLockStatus? SIMLockStatus; + boolean? SIMPresent; + boolean? SupportNetworkScan; + DOMString[]? SupportedCarriers; + }; + + dictionary CellularStateProperties { + ActivationStateType? ActivationState; + DOMString? NetworkTechnology; + DOMString? RoamingState; + boolean? SIMPresent; + long? SignalStrength; + }; + + dictionary EthernetProperties { + DOMString? Authentication; + EAPProperties? EAP; + }; + + dictionary EthernetStateProperties { + DOMString Authentication; + }; + + dictionary VPNProperties { boolean? AutoConnect; DOMString? Host; + IPSecProperties? IPsec; + L2TPProperties? L2TP; OpenVPNProperties? OpenVPN; ThirdPartyVPNProperties? ThirdPartyVPN; DOMString? Type; @@ -182,13 +325,20 @@ namespace networkingPrivate { ThirdPartyVPNProperties? ThirdPartyVPN; }; - dictionary WiFiConfigProperties { + dictionary WiFiProperties { + boolean? AllowGatewayARPPolling; boolean? AutoConnect; + DOMString? BSSID; + EAPProperties? EAP; + long? Frequency; + long[]? FrequencyList; DOMString? HexSSID; boolean? HiddenSSID; DOMString? Passphrase; + long? RoamThreshold; DOMString? SSID; DOMString? Security; + long? SignalStrength; }; dictionary WiFiStateProperties { @@ -196,8 +346,10 @@ namespace networkingPrivate { long? SignalStrength; }; - dictionary WiMaxConfigProperties { + dictionary WiMAXProperties { boolean? AutoConnect; + EAPProperties? EAP; + long? SignalStrength; }; dictionary WiMAXStateProperties { @@ -205,7 +357,8 @@ namespace networkingPrivate { }; dictionary NetworkConfigProperties { - CellularConfigProperties? Cellular; + CellularProperties? Cellular; + EthernetProperties? Ethernet; DOMString? GUID; IPConfigType? IPAddressConfigType; DOMString? Name; @@ -214,9 +367,9 @@ namespace networkingPrivate { ProxySettings? ProxySettings; IPConfigProperties? StaticIPConfig; NetworkType? Type; - VPNConfigProperties? VPN; - WiFiConfigProperties? WiFi; - WiMaxConfigProperties? WiMAX; + VPNProperties? VPN; + WiFiProperties? WiFi; + WiMAXProperties? WiMAX; }; dictionary NetworkStateProperties { @@ -235,6 +388,30 @@ namespace networkingPrivate { WiMAXStateProperties? WiMAX; }; + dictionary NetworkProperties { + CellularProperties? Cellular; + boolean? Connectable; + ConnectionStateType? ConnectionState; + DOMString? ErrorState; + EthernetProperties? Ethernet; + DOMString GUID; + IPConfigType? IPAddressConfigType; + IPConfigProperties[]? IPConfigs; + DOMString? MacAddress; + DOMString? Name; + IPConfigType? NameServersConfigType; + long? Priority; + ProxySettings? ProxySettings; + boolean? RestrictedConnectivity; + IPConfigProperties? StaticIPConfig; + IPConfigProperties? SavedIPConfig; + DOMString? Source; + NetworkType Type; + VPNProperties? VPN; + WiFiProperties? WiFi; + WiMAXProperties? WiMAX; + }; + dictionary VerificationProperties { // A string containing a PEM-encoded (including the 'BEGIN CERTIFICATE' // header and 'END CERTIFICATE' footer) X.509 certificate for use in @@ -291,7 +468,7 @@ namespace networkingPrivate { callback BooleanCallback = void(boolean result); callback StringCallback = void(DOMString result); // TODO(stevenjb): Use NetworkProperties for |result| once defined. - callback GetPropertiesCallback = void(object result); + callback GetPropertiesCallback = void(NetworkProperties result); // TODO(stevenjb): Use ManagedNetworkProperties for |result| once defined. callback GetManagedPropertiesCallback = void(object result); callback GetStatePropertiesCallback = void(NetworkStateProperties result); diff --git a/third_party/closure_compiler/externs/networking_private.js b/third_party/closure_compiler/externs/networking_private.js index b1bdc4c..50dc614 100644 --- a/third_party/closure_compiler/externs/networking_private.js +++ b/third_party/closure_compiler/externs/networking_private.js @@ -109,13 +109,13 @@ chrome.networkingPrivate.APNProperties; /** * @typedef {{ - * AutoConnect: (boolean|undefined), - * APN: (!chrome.networkingPrivate.APNProperties|undefined), - * Carrier: (string|undefined) + * Name: string, + * Code: string, + * Country: (string|undefined) * }} - * @see https://developer.chrome.com/extensions/networkingPrivate#type-CellularConfigProperties + * @see https://developer.chrome.com/extensions/networkingPrivate#type-CellularProviderProperties */ -chrome.networkingPrivate.CellularConfigProperties; +chrome.networkingPrivate.CellularProviderProperties; /** * @typedef {{ @@ -129,15 +129,25 @@ chrome.networkingPrivate.CellularSimState; /** * @typedef {{ - * ActivationState: (!chrome.networkingPrivate.ActivationStateType|undefined), - * NetworkTechnology: (string|undefined), - * RoamingState: (string|undefined), - * SIMPresent: (boolean|undefined), - * SignalStrength: (number|undefined) + * CommonName: (string|undefined), + * Locality: (string|undefined), + * Organization: (string|undefined), + * OrganizationalUnit: (string|undefined) * }} - * @see https://developer.chrome.com/extensions/networkingPrivate#type-CellularStateProperties + * @see https://developer.chrome.com/extensions/networkingPrivate#type-IssuerSubjectPattern */ -chrome.networkingPrivate.CellularStateProperties; +chrome.networkingPrivate.IssuerSubjectPattern; + +/** + * @typedef {{ + * EnrollmentURI: (!Array<string>|undefined), + * Issuer: (!chrome.networkingPrivate.IssuerSubjectPattern|undefined), + * IssuerCARef: (!Array<string>|undefined), + * Subject: (!chrome.networkingPrivate.IssuerSubjectPattern|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-CertificatePattern + */ +chrome.networkingPrivate.CertificatePattern; /** * @typedef {{ @@ -153,11 +163,34 @@ chrome.networkingPrivate.DeviceStateProperties; /** * @typedef {{ - * Authentication: string + * AnonymousIdentity: (string|undefined), + * ClientCertPattern: (!chrome.networkingPrivate.CertificatePattern|undefined), + * ClientCertRef: (string|undefined), + * ClientCertType: (string|undefined), + * Identity: (string|undefined), + * Inner: (string|undefined), + * Outer: string, + * Password: (string|undefined), + * SaveCredentials: (boolean|undefined), + * ServerCARefs: (!Array<string>|undefined), + * UseProactiveKeyCaching: (boolean|undefined), + * UseSystemCAs: (boolean|undefined) * }} - * @see https://developer.chrome.com/extensions/networkingPrivate#type-EthernetStateProperties + * @see https://developer.chrome.com/extensions/networkingPrivate#type-EAPProperties */ -chrome.networkingPrivate.EthernetStateProperties; +chrome.networkingPrivate.EAPProperties; + +/** + * @typedef {{ + * Status: string, + * NetworkId: string, + * Technology: string, + * ShortName: (string|undefined), + * LongName: (string|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-FoundNetworkProperties + */ +chrome.networkingPrivate.FoundNetworkProperties; /** * @typedef {{ @@ -174,7 +207,27 @@ chrome.networkingPrivate.IPConfigProperties; /** * @typedef {{ - * AuthenticationType: string + * Password: (string|undefined), + * SaveCredentials: (boolean|undefined), + * Username: (string|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-XAUTHProperties + */ +chrome.networkingPrivate.XAUTHProperties; + +/** + * @typedef {{ + * AuthenticationType: string, + * ClientCertPattern: (!chrome.networkingPrivate.CertificatePattern|undefined), + * ClientCertRef: (string|undefined), + * ClientCertType: (string|undefined), + * EAP: (!chrome.networkingPrivate.EAPProperties|undefined), + * Group: (string|undefined), + * IKEVersion: number, + * PSK: (string|undefined), + * SaveCredentials: (boolean|undefined), + * ServerCARefs: (!Array<string>|undefined), + * XAUTH: (!chrome.networkingPrivate.XAUTHProperties|undefined) * }} * @see https://developer.chrome.com/extensions/networkingPrivate#type-IPSecProperties */ @@ -182,6 +235,27 @@ chrome.networkingPrivate.IPSecProperties; /** * @typedef {{ + * LcpEchoDisabled: (boolean|undefined), + * Password: (string|undefined), + * SaveCredentials: (boolean|undefined), + * Username: (string|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-L2TPProperties + */ +chrome.networkingPrivate.L2TPProperties; + +/** + * @typedef {{ + * Method: string, + * PostData: (string|undefined), + * Url: (string|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-PaymentPortal + */ +chrome.networkingPrivate.PaymentPortal; + +/** + * @typedef {{ * Host: string, * Port: number * }} @@ -213,10 +287,49 @@ chrome.networkingPrivate.ProxySettings; /** * @typedef {{ + * Name: (string|undefined), + * Type: (string|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-VerifyX509 + */ +chrome.networkingPrivate.VerifyX509; + +/** + * @typedef {{ + * Auth: (string|undefined), + * AuthRetry: (string|undefined), + * AuthNoCache: (boolean|undefined), + * Cipher: (string|undefined), + * ClientCertRef: (string|undefined), + * ClientCertPattern: (!chrome.networkingPrivate.CertificatePattern|undefined), + * ClientCertType: (string|undefined), + * CompLZO: (string|undefined), + * CompNoAdapt: (boolean|undefined), + * IgnoreDefaultRoute: (boolean|undefined), + * KeyDirection: (string|undefined), + * NsCertType: (string|undefined), * OTP: (string|undefined), * Password: (string|undefined), + * Port: (number|undefined), + * Proto: (string|undefined), + * PushPeerInfo: (string|undefined), + * RemoteCertEKU: (string|undefined), + * RemoteCertKU: (!Array<string>|undefined), + * RemoteCertTLS: (string|undefined), + * RenegSec: (number|undefined), + * SaveCredentials: (boolean|undefined), + * ServerCARefs: (!Array<string>|undefined), + * ServerCertRef: (string|undefined), + * ServerPollTimeout: (number|undefined), + * Shaper: (number|undefined), + * StaticChallenge: (string|undefined), + * TLSAuthContents: (string|undefined), + * TLSRemote: (string|undefined), * UserAuthenticationType: (string|undefined), - * Username: (string|undefined) + * Username: (string|undefined), + * Verb: (string|undefined), + * VerifyHash: (string|undefined), + * VerifyX509: (!chrome.networkingPrivate.VerifyX509|undefined) * }} * @see https://developer.chrome.com/extensions/networkingPrivate#type-OpenVPNProperties */ @@ -224,6 +337,16 @@ chrome.networkingPrivate.OpenVPNProperties; /** * @typedef {{ + * LockType: string, + * LockEnabled: boolean, + * RetriesLeft: (number|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-SIMLockStatus + */ +chrome.networkingPrivate.SIMLockStatus; + +/** + * @typedef {{ * ExtensionID: string, * ProviderName: (string|undefined) * }} @@ -234,14 +357,82 @@ chrome.networkingPrivate.ThirdPartyVPNProperties; /** * @typedef {{ * AutoConnect: (boolean|undefined), + * APN: (!chrome.networkingPrivate.APNProperties|undefined), + * APNList: (!Array<!chrome.networkingPrivate.APNProperties>|undefined), + * ActivationType: (string|undefined), + * ActivationState: (!chrome.networkingPrivate.ActivationStateType|undefined), + * AllowRoaming: (boolean|undefined), + * Carrier: (string|undefined), + * ESN: (string|undefined), + * Family: (string|undefined), + * FirmwareRevision: (string|undefined), + * FoundNetworks: (!Array<!chrome.networkingPrivate.FoundNetworkProperties>|undefined), + * HardwareRevision: (string|undefined), + * HomeProvider: (!chrome.networkingPrivate.CellularProviderProperties|undefined), + * ICCID: (string|undefined), + * IMEI: (string|undefined), + * LastGoodAPN: (!chrome.networkingPrivate.APNProperties|undefined), + * Manufacturer: (string|undefined), + * MDN: (string|undefined), + * MEID: (string|undefined), + * MIN: (string|undefined), + * ModelID: (string|undefined), + * NetworkTechnology: (string|undefined), + * PaymentPortal: (!chrome.networkingPrivate.PaymentPortal|undefined), + * PRLVersion: (number|undefined), + * RoamingState: (string|undefined), + * ServingOperator: (!chrome.networkingPrivate.CellularProviderProperties|undefined), + * SIMLockStatus: (!chrome.networkingPrivate.SIMLockStatus|undefined), + * SIMPresent: (boolean|undefined), + * SupportNetworkScan: (boolean|undefined), + * SupportedCarriers: (!Array<string>|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-CellularProperties + */ +chrome.networkingPrivate.CellularProperties; + +/** + * @typedef {{ + * ActivationState: (!chrome.networkingPrivate.ActivationStateType|undefined), + * NetworkTechnology: (string|undefined), + * RoamingState: (string|undefined), + * SIMPresent: (boolean|undefined), + * SignalStrength: (number|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-CellularStateProperties + */ +chrome.networkingPrivate.CellularStateProperties; + +/** + * @typedef {{ + * Authentication: (string|undefined), + * EAP: (!chrome.networkingPrivate.EAPProperties|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-EthernetProperties + */ +chrome.networkingPrivate.EthernetProperties; + +/** + * @typedef {{ + * Authentication: string + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-EthernetStateProperties + */ +chrome.networkingPrivate.EthernetStateProperties; + +/** + * @typedef {{ + * AutoConnect: (boolean|undefined), * Host: (string|undefined), + * IPsec: (!chrome.networkingPrivate.IPSecProperties|undefined), + * L2TP: (!chrome.networkingPrivate.L2TPProperties|undefined), * OpenVPN: (!chrome.networkingPrivate.OpenVPNProperties|undefined), * ThirdPartyVPN: (!chrome.networkingPrivate.ThirdPartyVPNProperties|undefined), * Type: (string|undefined) * }} - * @see https://developer.chrome.com/extensions/networkingPrivate#type-VPNConfigProperties + * @see https://developer.chrome.com/extensions/networkingPrivate#type-VPNProperties */ -chrome.networkingPrivate.VPNConfigProperties; +chrome.networkingPrivate.VPNProperties; /** * @typedef {{ @@ -255,16 +446,23 @@ chrome.networkingPrivate.VPNStateProperties; /** * @typedef {{ + * AllowGatewayARPPolling: (boolean|undefined), * AutoConnect: (boolean|undefined), + * BSSID: (string|undefined), + * EAP: (!chrome.networkingPrivate.EAPProperties|undefined), + * Frequency: (number|undefined), + * FrequencyList: (!Array<number>|undefined), * HexSSID: (string|undefined), * HiddenSSID: (boolean|undefined), * Passphrase: (string|undefined), + * RoamThreshold: (number|undefined), * SSID: (string|undefined), - * Security: (string|undefined) + * Security: (string|undefined), + * SignalStrength: (number|undefined) * }} - * @see https://developer.chrome.com/extensions/networkingPrivate#type-WiFiConfigProperties + * @see https://developer.chrome.com/extensions/networkingPrivate#type-WiFiProperties */ -chrome.networkingPrivate.WiFiConfigProperties; +chrome.networkingPrivate.WiFiProperties; /** * @typedef {{ @@ -277,11 +475,13 @@ chrome.networkingPrivate.WiFiStateProperties; /** * @typedef {{ - * AutoConnect: (boolean|undefined) + * AutoConnect: (boolean|undefined), + * EAP: (!chrome.networkingPrivate.EAPProperties|undefined), + * SignalStrength: (number|undefined) * }} - * @see https://developer.chrome.com/extensions/networkingPrivate#type-WiMaxConfigProperties + * @see https://developer.chrome.com/extensions/networkingPrivate#type-WiMAXProperties */ -chrome.networkingPrivate.WiMaxConfigProperties; +chrome.networkingPrivate.WiMAXProperties; /** * @typedef {{ @@ -293,7 +493,8 @@ chrome.networkingPrivate.WiMAXStateProperties; /** * @typedef {{ - * Cellular: (!chrome.networkingPrivate.CellularConfigProperties|undefined), + * Cellular: (!chrome.networkingPrivate.CellularProperties|undefined), + * Ethernet: (!chrome.networkingPrivate.EthernetProperties|undefined), * GUID: (string|undefined), * IPAddressConfigType: (!chrome.networkingPrivate.IPConfigType|undefined), * Name: (string|undefined), @@ -302,9 +503,9 @@ chrome.networkingPrivate.WiMAXStateProperties; * ProxySettings: (!chrome.networkingPrivate.ProxySettings|undefined), * StaticIPConfig: (!chrome.networkingPrivate.IPConfigProperties|undefined), * Type: (!chrome.networkingPrivate.NetworkType|undefined), - * VPN: (!chrome.networkingPrivate.VPNConfigProperties|undefined), - * WiFi: (!chrome.networkingPrivate.WiFiConfigProperties|undefined), - * WiMAX: (!chrome.networkingPrivate.WiMaxConfigProperties|undefined) + * VPN: (!chrome.networkingPrivate.VPNProperties|undefined), + * WiFi: (!chrome.networkingPrivate.WiFiProperties|undefined), + * WiMAX: (!chrome.networkingPrivate.WiMAXProperties|undefined) * }} * @see https://developer.chrome.com/extensions/networkingPrivate#type-NetworkConfigProperties */ @@ -332,6 +533,34 @@ chrome.networkingPrivate.NetworkStateProperties; /** * @typedef {{ + * Cellular: (!chrome.networkingPrivate.CellularProperties|undefined), + * Connectable: (boolean|undefined), + * ConnectionState: (!chrome.networkingPrivate.ConnectionStateType|undefined), + * ErrorState: (string|undefined), + * Ethernet: (!chrome.networkingPrivate.EthernetProperties|undefined), + * GUID: string, + * IPAddressConfigType: (!chrome.networkingPrivate.IPConfigType|undefined), + * IPConfigs: (!Array<!chrome.networkingPrivate.IPConfigProperties>|undefined), + * MacAddress: (string|undefined), + * Name: (string|undefined), + * NameServersConfigType: (!chrome.networkingPrivate.IPConfigType|undefined), + * Priority: (number|undefined), + * ProxySettings: (!chrome.networkingPrivate.ProxySettings|undefined), + * RestrictedConnectivity: (boolean|undefined), + * StaticIPConfig: (!chrome.networkingPrivate.IPConfigProperties|undefined), + * SavedIPConfig: (!chrome.networkingPrivate.IPConfigProperties|undefined), + * Source: (string|undefined), + * Type: !chrome.networkingPrivate.NetworkType, + * VPN: (!chrome.networkingPrivate.VPNProperties|undefined), + * WiFi: (!chrome.networkingPrivate.WiFiProperties|undefined), + * WiMAX: (!chrome.networkingPrivate.WiMAXProperties|undefined) + * }} + * @see https://developer.chrome.com/extensions/networkingPrivate#type-NetworkProperties + */ +chrome.networkingPrivate.NetworkProperties; + +/** + * @typedef {{ * certificate: string, * intermediateCertificates: (!Array<string>|undefined), * publicKey: string, @@ -360,8 +589,8 @@ chrome.networkingPrivate.NetworkFilter; * Gets all the properties of the network with id networkGuid. Includes all * properties of the network (read-only and read/write values). * @param {string} networkGuid The GUID of the network to get properties for. - * @param {function(Object):void} callback Called with the network properties - * when received. + * @param {function(!chrome.networkingPrivate.NetworkProperties):void} callback + * Called with the network properties when received. * @see https://developer.chrome.com/extensions/networkingPrivate#method-getProperties */ chrome.networkingPrivate.getProperties = function(networkGuid, callback) {}; @@ -660,3 +889,5 @@ chrome.networkingPrivate.onDeviceStateListChanged; * @see https://developer.chrome.com/extensions/networkingPrivate#event-onPortalDetectionCompleted */ chrome.networkingPrivate.onPortalDetectionCompleted; + + diff --git a/ui/webui/resources/cr_elements/v1_0/network/cr_network_icon.js b/ui/webui/resources/cr_elements/v1_0/network/cr_network_icon.js index c6bce8770..ed5eb56 100644 --- a/ui/webui/resources/cr_elements/v1_0/network/cr_network_icon.js +++ b/ui/webui/resources/cr_elements/v1_0/network/cr_network_icon.js @@ -53,12 +53,13 @@ Polymer({ properties: { /** - * If set, the ONC state properties will be used to display the icon. - * @type {?CrOnc.NetworkStateProperties} + * If set, the ONC properties will be used to display the icon. This may + * either be the complete set of NetworkProperties or the subset of + * NetworkStateProperties. + * @type {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} */ networkState: { type: Object, - value: null, observer: 'networkStateChanged_' }, @@ -120,7 +121,7 @@ Polymer({ this.networkType = null; this.iconType_ = getIconTypeFromNetworkType(this.networkState.Type); var strength = /** @type {number} */ ( - CrOnc.getTypeProperty(this.networkState, 'SignalStrength') || 0); + CrOnc.getActiveTypeValue(this.networkState, 'SignalStrength') || 0); var params = /** @type {NetworkIconParamType} */ { showBadges: true, showDisconnected: !this.isListItem, @@ -138,7 +139,7 @@ Polymer({ if (!this.networkType) return; - this.networkState = null; + this.networkState = undefined; this.iconType_ = getIconTypeFromNetworkType(this.networkType); var params = /** @type {NetworkIconParamType} */ { showBadges: false, @@ -242,7 +243,7 @@ Polymer({ (params.showBadges && networkState) ? networkState.Type : ''; if (type == CrOnc.Type.WI_FI) { this.roaming_ = false; - var security = CrOnc.getTypeProperty(networkState, 'Security'); + var security = CrOnc.getActiveTypeValue(networkState, 'Security'); this.secure_ = !!security && security != 'None'; this.technology_ = ''; } else if (type == CrOnc.Type.WI_MAX) { @@ -250,11 +251,11 @@ Polymer({ this.secure_ = false; this.technology_ = '4g'; } else if (type == CrOnc.Type.CELLULAR) { - this.roaming_ = CrOnc.getTypeProperty(networkState, 'RoamingState') == + this.roaming_ = CrOnc.getActiveTypeValue(networkState, 'RoamingState') == CrOnc.RoamingState.ROAMING; this.secure_ = false; var oncTechnology = - CrOnc.getTypeProperty(networkState, 'NetworkTechnology'); + CrOnc.getActiveTypeValue(networkState, 'NetworkTechnology'); switch (oncTechnology) { case CrOnc.NetworkTechnology.CDMA1XRTT: this.technology_ = '1x'; diff --git a/ui/webui/resources/cr_elements/v1_0/network/cr_network_select.js b/ui/webui/resources/cr_elements/v1_0/network/cr_network_select.js index e4c6a22..23ead1a 100644 --- a/ui/webui/resources/cr_elements/v1_0/network/cr_network_select.js +++ b/ui/webui/resources/cr_elements/v1_0/network/cr_network_select.js @@ -98,7 +98,7 @@ Polymer({ /** @override */ detached: function() { - chrome.networkingPrivate.onNetworksChanged.removeListener( + chrome.networkingPrivate.onNetworkListChanged.removeListener( this.networkListChangedListener_); chrome.networkingPrivate.onDeviceStateListChanged.removeListener( this.deviceStateListChangedListener_); diff --git a/ui/webui/resources/cr_elements/v1_0/network/cr_onc_types.js b/ui/webui/resources/cr_elements/v1_0/network/cr_onc_types.js index 873dee2..cca3371 100644 --- a/ui/webui/resources/cr_elements/v1_0/network/cr_onc_types.js +++ b/ui/webui/resources/cr_elements/v1_0/network/cr_onc_types.js @@ -20,33 +20,32 @@ var CrOnc = {}; /** @typedef {chrome.networkingPrivate.NetworkStateProperties} */ CrOnc.NetworkStateProperties; +/** @typedef {chrome.networkingPrivate.NetworkProperties} */ +CrOnc.NetworkProperties; + /** @typedef {string|number|boolean|Object|Array<Object>} */ -CrOnc.NetworkStateProperty; +CrOnc.NetworkPropertyType; /** + * TODO(stevenjb): Eliminate this when we switch to using + * chrome.networkingPrivate.ManagedProperties once defined. * @typedef {{ - * Active: CrOnc.NetworkStateProperty, - * Effective: CrOnc.NetworkStateProperty, - * UserPolicy: CrOnc.NetworkStateProperty, - * DevicePolicy: CrOnc.NetworkStateProperty, - * UserSetting: CrOnc.NetworkStateProperty, - * SharedSetting: CrOnc.NetworkStateProperty, + * Active: CrOnc.NetworkPropertyType, + * Effective: CrOnc.NetworkPropertyType, + * UserPolicy: CrOnc.NetworkPropertyType, + * DevicePolicy: CrOnc.NetworkPropertyType, + * UserSetting: CrOnc.NetworkPropertyType, + * SharedSetting: CrOnc.NetworkPropertyType, * UserEditable: boolean, * DeviceEditable: boolean * }} */ CrOnc.ManagedProperty; -/** @typedef {CrOnc.NetworkStateProperty|!CrOnc.ManagedProperty} */ +/** @typedef {CrOnc.NetworkPropertyType|!CrOnc.ManagedProperty} */ CrOnc.ManagedNetworkStateProperty; -/** - * @typedef {{ - * LockType: !CrOnc.LockType, - * LockEnabled: boolean, - * RetriesLeft: (number|undefined) - * }} - */ +/** @typedef {chrome.networkingPrivate.SIMLockStatus} */ CrOnc.SIMLockStatus; /** @typedef {chrome.networkingPrivate.APNProperties} */ @@ -81,13 +80,7 @@ CrOnc.ProxySettings; */ CrOnc.IPConfigUIProperties; -/** - * @typedef {{ - * Method: string, - * PostData: (string|undefined), - * Url: string - * }} - */ +/** @typedef {chrome.networkingPrivate.PaymentPortal} */ CrOnc.PaymentPortal; CrOnc.ActivationState = chrome.networkingPrivate.ActivationStateType; @@ -152,15 +145,18 @@ CrOnc.Source = { /** * Helper function to retrieve the active ONC property value. - * @param {!CrOnc.ManagedNetworkStateProperty} property The property, which may - * be a managed dictionary or the property itself. - * @return {!CrOnc.NetworkStateProperty|undefined} The active property value + * @param {!CrOnc.ManagedNetworkStateProperty|undefined} property The property, + * which may be a managed dictionary or the property itself. + * @return {!CrOnc.NetworkPropertyType|undefined} The active property value * if it exists, otherwise undefined. */ -CrOnc.getActivePropertyValue = function(property) { +CrOnc.getActiveValue = function(property) { + if (property == undefined) + return undefined; + // If this is not a dictionary, return the value. if (Array.isArray(property) || typeof property != 'object') - return /** @type {!CrOnc.NetworkStateProperty} */ (property); + return /** @type {!CrOnc.NetworkPropertyType} */ (property); // Otherwise return the Active value if it exists. if ('Active' in property) @@ -173,91 +169,43 @@ CrOnc.getActivePropertyValue = function(property) { return property[effective]; } - console.error('getActivePropertyValue called on invalid ONC object: ' + - property); + console.error('getActiveValue called on invalid ONC object: ' + + JSON.stringify(property)); return undefined; }; /** - * Returns either a managed property dictionary or an unmanaged value associated - * with a key. TODO(stevenjb): Remove this. Properties should be accessed - * directly so that the closure compiler can do type checking. Removal is - * dependent on adding a NetworkProperties type to the networking_private.js - * externs file. - * @param {?CrOnc.NetworkStateProperties|undefined} state The ONC network state. - * @param {string} key The property key which may be nested, e.g. 'Foo.Bar'. - * @return {!CrOnc.ManagedNetworkStateProperty|undefined} The property value or - * dictionary if it exists, otherwise undefined. - */ -CrOnc.getProperty = function(state, key) { - if (!state) { - console.error('CrOnc.getProperty called with undefined state'); - return undefined; - } - while (true) { - var index = key.indexOf('.'); - if (index < 0) - break; - var keyComponent = key.substr(0, index); - if (!state.hasOwnProperty(keyComponent)) - return undefined; - state = state[keyComponent]; - key = key.substr(index + 1); - } - return state[key]; -}; - -/** - * Calls getProperty with '{state.Type}.key', e.g. WiFi.AutoConnect. - * @param {?CrOnc.NetworkStateProperties|undefined} state The ONC network state. + * Calls getActiveValue with '{state.Type}.key', e.g. WiFi.AutoConnect. + * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} + * properties The ONC network properties or state properties. * @param {string} key The type property key, e.g. 'AutoConnect'. * @return {!CrOnc.ManagedNetworkStateProperty|undefined} The property value or * dictionary if it exists, otherwise undefined. */ -CrOnc.getTypeProperty = function(state, key) { - var typeKey = state ? state.Type + '.' + key : ''; - return CrOnc.getProperty(state, typeKey); -}; - -/** - * Returns either the active value of a managed property dictionary or the - * unmanaged value associated with a key. - * @param {?CrOnc.NetworkStateProperties|undefined} state The ONC network state. - * @param {string} key The property key which may be nested, e.g. 'Foo.Bar'. - * @return {!CrOnc.ManagedNetworkStateProperty|undefined} The active property - * value if it exists, otherwise undefined. - */ -CrOnc.getActiveValue = function(state, key) { - var property = CrOnc.getProperty(state, key); - if (property == undefined) +CrOnc.getActiveTypeValue = function(properties, key) { + var typeDict = properties[properties.Type]; + if (!typeDict) { + // An 'Ethernet' dictionary will only be present for EAP ethernet networks, + // so don't log an error when Type == Ethernet. + if (properties.Type != chrome.networkingPrivate.NetworkType.ETHERNET) + console.error('Network properties missing for:', properties.GUID); return undefined; - return CrOnc.getActivePropertyValue(property); -}; - -/** - * Calls getActiveValue with '{state.Type}.key', e.g. WiFi.AutoConnect. - * @param {?CrOnc.NetworkStateProperties|undefined} state The ONC network state. - * @param {string} key The type property key, e.g. 'AutoConnect'. - * @return {!CrOnc.ManagedNetworkStateProperty|undefined} The active property - * value if it exists, otherwise undefined. - */ -CrOnc.getActiveTypeValue = function(state, key) { - var typeKey = state ? state.Type + '.' + key : ''; - return CrOnc.getActiveValue(state, typeKey); + } + return CrOnc.getActiveValue(typeDict[key]); }; /** * Returns an IPConfigProperties object for |type|. For IPV4, these will be the * static properties if IPAddressConfigType is Static and StaticIPConfig is set. - * @param {?CrOnc.NetworkStateProperties|undefined} state The ONC network state. + * @param {!CrOnc.NetworkProperties|undefined} properties The ONC properties. * @param {!CrOnc.IPType} type The IP Config type. - * @return {?CrOnc.IPConfigProperties} The IP Config object, or undefined if - * no properties for |type| are available. + * @return {CrOnc.IPConfigProperties|undefined} The IP Config object, or + * undefined if no properties for |type| are available. */ -CrOnc.getIPConfigForType = function(state, type) { +CrOnc.getIPConfigForType = function(properties, type) { 'use strict'; var result; - var ipConfigs = CrOnc.getActiveValue(state, 'IPConfigs'); + var ipConfigs = properties.IPConfigs; if (ipConfigs) { for (let i = 0; i < ipConfigs.length; ++i) { let ipConfig = ipConfigs[i]; @@ -270,8 +218,7 @@ CrOnc.getIPConfigForType = function(state, type) { if (type != CrOnc.IPType.IPV4) return result; - var staticIpConfig = - /** @type{CrOnc.IPConfigProperties} */ (state['StaticIPConfig']); + var staticIpConfig = properties.StaticIPConfig; if (!staticIpConfig) return result; @@ -281,30 +228,33 @@ CrOnc.getIPConfigForType = function(state, type) { // Otherwise, merge the appropriate static values into the result. if (staticIpConfig.IPAddress && - CrOnc.getActiveValue(state, 'IPAddressConfigType') == 'Static') { + CrOnc.getActiveValue(properties.IPAddressConfigType) == 'Static') { result.Gateway = staticIpConfig.Gateway; result.IPAddress = staticIpConfig.IPAddress; result.RoutingPrefix = staticIpConfig.RoutingPrefix; result.Type = staticIpConfig.Type; } if (staticIpConfig.NameServers && - CrOnc.getActiveValue(state, 'NameServersConfigType') == 'Static') { + CrOnc.getActiveValue(properties.NameServersConfigType) == 'Static') { result.NameServers = staticIpConfig.NameServers; } return result; }; /** - * @param {?CrOnc.NetworkStateProperties|undefined} state The ONC network state. - * @return {boolean} True if |state| is a Cellular network with a locked SIM. + * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} + * properties The ONC network properties or state properties. + * @return {boolean} True if |properties| is a Cellular network with a + * locked SIM. */ -CrOnc.isSimLocked = function(state) { - if (!state || state.Type != CrOnc.Type.CELLULAR) +CrOnc.isSimLocked = function(properties) { + if (!properties.Cellular) + return false; + var simLockStatus = properties.Cellular.SIMLockStatus; + if (simLockStatus == undefined) return false; - var property = /** @type {!CrOnc.SIMLockStatus} */( - CrOnc.getProperty(state, 'Cellular.SIMLockStatus')); - return property != undefined && (property.LockType == CrOnc.LockType.PIN || - property.LockType == CrOnc.LockType.PUK); + return simLockStatus.LockType == CrOnc.LockType.PIN || + simLockStatus.LockType == CrOnc.LockType.PUK; }; /** @@ -313,17 +263,17 @@ CrOnc.isSimLocked = function(state) { * properties in |config| will be preserved unless invalid. * @param {!chrome.networkingPrivate.NetworkConfigProperties} config A partial * ONC configuration. - * @param {!CrOnc.NetworkStateProperties} state The complete ONC network state. + * @param {CrOnc.NetworkProperties|undefined} properties The ONC properties. */ -CrOnc.setValidStaticIPConfig = function(config, state) { +CrOnc.setValidStaticIPConfig = function(config, properties) { if (!config.IPAddressConfigType) { var ipConfigType = /** @type {chrome.networkingPrivate.IPConfigType} */( - CrOnc.getActiveValue(state, 'IPAddressConfigType')); + CrOnc.getActiveValue(properties.IPAddressConfigType)); config.IPAddressConfigType = ipConfigType || CrOnc.IPConfigType.DHCP; } if (!config.NameServersConfigType) { var nsConfigType = /** @type {chrome.networkingPrivate.IPConfigType} */( - CrOnc.getActiveValue(state, 'NameServersConfigType')); + CrOnc.getActiveValue(properties.NameServersConfigType)); config.NameServersConfigType = nsConfigType || CrOnc.IPConfigType.DHCP; } if (config.IPAddressConfigType != CrOnc.IPConfigType.STATIC && @@ -338,7 +288,7 @@ CrOnc.setValidStaticIPConfig = function(config, state) { /** @type {chrome.networkingPrivate.IPConfigProperties} */({}); } var staticIP = config.StaticIPConfig; - var stateIPConfig = CrOnc.getIPConfigForType(state, CrOnc.IPType.IPV4); + var stateIPConfig = CrOnc.getIPConfigForType(properties, CrOnc.IPType.IPV4); if (config.IPAddressConfigType == 'Static') { staticIP.Gateway = staticIP.Gateway || stateIPConfig.Gateway || ''; staticIP.IPAddress = staticIP.IPAddress || stateIPConfig.IPAddress || ''; @@ -356,8 +306,9 @@ CrOnc.setValidStaticIPConfig = function(config, state) { /** * Sets the value of a property in an ONC dictionary. * @param {!chrome.networkingPrivate.NetworkConfigProperties} properties + * The ONC property dictionary to modify. * @param {string} key The property key which may be nested, e.g. 'Foo.Bar'. - * @param {!CrOnc.NetworkStateProperty} value The property value to set. + * @param {!CrOnc.NetworkPropertyType} value The property value to set. */ CrOnc.setProperty = function(properties, key, value) { while (true) { @@ -378,7 +329,7 @@ CrOnc.setProperty = function(properties, key, value) { * @param {!chrome.networkingPrivate.NetworkConfigProperties} properties The * ONC properties to set. properties.Type must be set already. * @param {string} key The type property key, e.g. 'AutoConnect'. - * @param {!CrOnc.NetworkStateProperty} value The property value to set. + * @param {!CrOnc.NetworkPropertyType} value The property value to set. */ CrOnc.setTypeProperty = function(properties, key, value) { if (properties.Type == undefined) { |