diff options
author | stevenjb <stevenjb@chromium.org> | 2015-04-16 20:04:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-17 03:04:35 +0000 |
commit | 1f3e7df7ae30ba4a0a1451ce02a24dc00f788f41 (patch) | |
tree | 4de7ead8db3945ec87adab3d9c3882045c916280 | |
parent | 56714d7becf503987c52dadd1fdbd784f5e8cdaa (diff) | |
download | chromium_src-1f3e7df7ae30ba4a0a1451ce02a24dc00f788f41.zip chromium_src-1f3e7df7ae30ba4a0a1451ce02a24dc00f788f41.tar.gz chromium_src-1f3e7df7ae30ba4a0a1451ce02a24dc00f788f41.tar.bz2 |
Use networkingPrivate types (but not enums) in JS
This is a subset of https://codereview.chromium.org/1030963003/ that
just introduces the use of NetworkStateProperties instead of
CrOnc.NetworkConfigType.
BUG=470262
Review URL: https://codereview.chromium.org/1044193004
Cr-Commit-Position: refs/heads/master@{#325590}
5 files changed, 29 insertions, 59 deletions
diff --git a/chrome/browser/resources/chromeos/network_ui/network_ui.js b/chrome/browser/resources/chromeos/network_ui/network_ui.js index 79666ee..8fcf934 100644 --- a/chrome/browser/resources/chromeos/network_ui/network_ui.js +++ b/chrome/browser/resources/chromeos/network_ui/network_ui.js @@ -58,8 +58,8 @@ var NetworkUI = (function() { * nested property, e.g. 'WiFi.Security'. If any part of a nested key is * missing, this will return undefined. * - * @param {!CrOnc.NetworkConfigType} networkState The network state - * property dictionary. + * @param {!chrome.networkingPrivate.NetworkStateProperties} networkState The + * network state property dictionary. * @param {string} key The ONC key for the property. * @return {*} The value associated with the property or undefined if the * key (any part of it) is not defined. @@ -99,7 +99,8 @@ var NetworkUI = (function() { /** * Creates a cell with an icon representing the network state. * - * @param {CrOnc.NetworkConfigType} networkState The network state properties. + * @param {!chrome.networkingPrivate.NetworkStateProperties} networkState The + * network state properties. * @return {!HTMLTableCellElement} The created td element that displays the * icon. */ @@ -131,7 +132,8 @@ var NetworkUI = (function() { * Creates a row in the network state table. * * @param {Array} stateFields The state fields to use for the row. - * @param {CrOnc.NetworkConfigType} networkState The network state properties. + * @param {!chrome.networkingPrivate.NetworkStateProperties} networkState The + * network state properties. * @return {!HTMLTableRowElement} The created tr element that contains the * network state information. */ @@ -164,8 +166,9 @@ var NetworkUI = (function() { * Creates a table for networks or favorites. * * @param {string} tablename The name of the table to be created. - * @param {Array} stateFields The list of fields for the table. - * @param {Array} states An array of network or favorite states. + * @param {!Array<string>} stateFields The list of fields for the table. + * @param {!Array<!chrome.networkingPrivate.NetworkStateProperties>} states + * An array of network or favorite states. */ var createStateTable = function(tablename, stateFields, states) { var table = $(tablename); @@ -173,8 +176,7 @@ var NetworkUI = (function() { for (var i = 0; i < oldRows.length; ++i) table.removeChild(oldRows[i]); states.forEach(function(state) { - table.appendChild(createStateTableRow( - stateFields, /** @type {!CrOnc.NetworkConfigType} */(state))); + table.appendChild(createStateTableRow(stateFields, state)); }); }; @@ -191,15 +193,16 @@ var NetworkUI = (function() { /** * This callback function is triggered when visible networks are received. * - * @param {!Array<!Object>} states A list of network state information for - * each visible network. + * @param {!Array<!chrome.networkingPrivate.NetworkStateProperties>} states + * A list of network state information for each visible network. */ var onVisibleNetworksReceived = function(states) { - /** @type {CrOnc.NetworkConfigType} */ var defaultState; + /** @type {chrome.networkingPrivate.NetworkStateProperties} */ var + defaultState; if (states.length > 0) - defaultState = /** @type {!CrOnc.NetworkConfigType} */(states[0]); + defaultState = states[0]; var icon = /** @type {CrNetworkIconElement} */($('default-network-icon')); - if (defaultState && defaultState.Type != 'VPN') { + if (defaultState && defaultState.Type != CrOnc.Type.VPN) { $('default-network-text').textContent = loadTimeData.getStringF('defaultNetworkText', defaultState.Name, @@ -218,8 +221,8 @@ var NetworkUI = (function() { /** * This callback function is triggered when favorite networks are received. * - * @param {!Array<!Object>} states A list of network state information for - * each favorite network. + * @param {!Array<!chrome.networkingPrivate.NetworkStateProperties>} states + * A list of network state information for each favorite network. */ var onFavoriteNetworksReceived = function(states) { createStateTable('favorite-state-table', FAVORITE_STATE_FIELDS, states); diff --git a/chrome/browser/resources/options/chromeos/network_list.js b/chrome/browser/resources/options/chromeos/network_list.js index 4be0cc8..df79cf0 100644 --- a/chrome/browser/resources/options/chromeos/network_list.js +++ b/chrome/browser/resources/options/chromeos/network_list.js @@ -5,8 +5,8 @@ /** * This partially describes the network list entries passed to * refreshNetworkData. The contents of those lists actually match - * CrOnc.NetworkConfigType with the addition of the policyManaged property. - * TODO(stevenjb): Use networkingPrivate.getNetworks. + * chrome.networkingPrivate.NetworkStateProperties with the addition of the + * policyManaged property. TODO(stevenjb): Use networkingPrivate.getNetworks. * @typedef {{ * ConnectionState: string, * GUID: string, @@ -243,7 +243,8 @@ cr.define('options.network', function() { return; var networkIcon = this.getNetworkIcon(); networkIcon.networkState = CrOncDataElement.create( - /** @type {CrOnc.NetworkConfigType} */ (data)); + /** @type {chrome.networkingPrivate.NetworkStateProperties} */ ( + data)); }, /** diff --git a/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js b/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js index 978532f..823fad1 100644 --- a/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js +++ b/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js @@ -5,8 +5,7 @@ /** * @fileoverview ONC network configuration support class. Wraps a dictionary * object containing ONC managed or unmanaged dictionaries. Also provides - * special accessors for ONC properties. See cr-onc-types for ONC types, - * e.g. CrOnc.NetworkConfigType. Used by consumers of the + * special accessors for ONC properties. Used by consumers of the * chrome.networkingPrivate API. See components/onc/docs/onc_spec.html. */ Polymer('cr-onc-data', { @@ -16,7 +15,7 @@ Polymer('cr-onc-data', { * chrome.networkingPrivate.getProperties() call. * * @attribute data - * @type CrOnc.NetworkConfigType + * @type {chrome.networkingPrivate.NetworkStateProperties} * @default null */ data: null, @@ -24,7 +23,8 @@ Polymer('cr-onc-data', { /** @override */ created: function() { - this.data = /** @type {CrOnc.NetworkConfigType} */({}); + this.data = + /** @type {chrome.networkingPrivate.NetworkStateProperties} */({}); }, /** @return {boolean} True if the network is connected. */ @@ -83,7 +83,8 @@ var CrOncDataElement = {}; * Helper method to create and return a typed cr-onc-data Polymer element. * Sets the data property of the element to |state|. * - * @param {!CrOnc.NetworkConfigType} state The network state properties. + * @param {!chrome.networkingPrivate.NetworkStateProperties} state The network + * state properties. * @return {!CrOncDataElement} A cr-onc-data element. */ CrOncDataElement.create = function(state) { diff --git a/ui/webui/resources/cr_elements/cr_onc/cr_onc_data_externs.js b/ui/webui/resources/cr_elements/cr_onc/cr_onc_data_externs.js index 00db01e..c4c18d8 100644 --- a/ui/webui/resources/cr_elements/cr_onc/cr_onc_data_externs.js +++ b/ui/webui/resources/cr_elements/cr_onc/cr_onc_data_externs.js @@ -13,5 +13,5 @@ /** @constructor @extends {HTMLElement} */ var CrOncDataElement = function() {}; -/** @type {CrOnc.NetworkConfigType} */ +/** @type {chrome.networkingPrivate.NetworkStateProperties} */ CrOncDataElement.prototype.data; diff --git a/ui/webui/resources/cr_elements/cr_onc/cr_onc_types.js b/ui/webui/resources/cr_elements/cr_onc/cr_onc_types.js index 87bc6d3..4dfa32f 100644 --- a/ui/webui/resources/cr_elements/cr_onc/cr_onc_types.js +++ b/ui/webui/resources/cr_elements/cr_onc/cr_onc_types.js @@ -58,38 +58,3 @@ CrOnc.Security = { WPA_EAP: 'WPA-EAP', WPA_PSK: 'WPA-PSK', }; - -/** @typedef {string|!Object} */ -CrOnc.ManagedStringType; - -/** - * @typedef {{ - * NetworkTechnology: CrOnc.NetworkTechnology, - * RoamingState: CrOnc.RoamingState, - * Strength: number - * }} - */ -CrOnc.CellularType; - -/** - * @typedef {{Security: CrOnc.Security, Strength: number}} - */ -CrOnc.WiFiType; - -/** - * @typedef {{Strength: number}} - */ -CrOnc.WiMAXType; - -/** - * @typedef {{ - * Cellular: CrOnc.CellularType, - * ConnectionState: CrOnc.ConnectionState, - * GUID: string, - * Name: CrOnc.ManagedStringType, - * Type: CrOnc.Type, - * WiFi: CrOnc.WiFiType, - * WiMAX: CrOnc.WiMAXType - * }} - */ -CrOnc.NetworkConfigType; |