diff options
Diffstat (limited to 'chromium/chrome/browser/resources/settings/internet_page')
15 files changed, 344 insertions, 307 deletions
diff --git a/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn b/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn index 7b8a8fa0718..5aa49429248 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn +++ b/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn @@ -28,7 +28,6 @@ js_library("internet_page") { "//chromeos/services/network_config/public/mojom:mojom_js_library_for_compile", "//ui/webui/resources/cr_components/chromeos/network:mojo_interface_provider", "//ui/webui/resources/cr_elements/chromeos/network:cr_network_listener_behavior", - "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types", "//ui/webui/resources/js:assert", "//ui/webui/resources/js:i18n_behavior", "//ui/webui/resources/js:web_ui_listener_behavior", @@ -51,7 +50,6 @@ js_library("internet_config") { deps = [ "..:route", "//ui/webui/resources/cr_components/chromeos/network:network_config", - "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types", "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog", "//ui/webui/resources/js:assert", "//ui/webui/resources/js:i18n_behavior", @@ -67,7 +65,6 @@ js_library("internet_detail_page") { ":tether_connection_dialog", "..:route", "//ui/webui/resources/cr_elements/chromeos/network:cr_network_listener_behavior", - "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types", "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior_mojo", "//ui/webui/resources/js:assert", "//ui/webui/resources/js:i18n_behavior", @@ -82,7 +79,6 @@ js_library("internet_detail_page") { js_library("internet_known_networks_page") { deps = [ "//ui/webui/resources/cr_elements/chromeos/network:cr_network_listener_behavior", - "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types", "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu", "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior_mojo", "//ui/webui/resources/js:assert", @@ -122,7 +118,6 @@ js_library("network_proxy_section") { js_library("network_summary") { deps = [ "//ui/webui/resources/cr_elements/chromeos/network:cr_network_listener_behavior", - "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types", "//ui/webui/resources/js:assert", "//ui/webui/resources/js/chromeos:onc_mojo", ] @@ -131,7 +126,7 @@ js_library("network_summary") { js_library("network_summary_item") { deps = [ - "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types", + "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_strings", "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior_mojo", "//ui/webui/resources/js:assert", "//ui/webui/resources/js:i18n_behavior", diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_config.html b/chromium/chrome/browser/resources/settings/internet_page/internet_config.html index df873613ea5..65ef26edeee 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_config.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_config.html @@ -1,7 +1,6 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_config.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html"> @@ -23,13 +22,11 @@ <cr-dialog id="dialog" close-text="$i18n{close}"> <div slot="title"> - [[getDialogTitle_(managedProperties_, showConnect)]] + [[getDialogTitle_(name, type, showConnect)]] </div> <div slot="body"> <network-config id="networkConfig" class="flex" - networking-private="[[networkingPrivate]]" - global-policy="[[globalPolicy]]" - managed-properties="{{managedProperties_}}" + guid="[[guid]]" name="{{name}}" type="{{type}}" enable-connect="{{enableConnect_}}" enable-save="{{enableSave_}}" share-allow-enable="[[shareAllowEnable_]]" share-default="[[shareDefault_]]" diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_config.js b/chromium/chrome/browser/resources/settings/internet_page/internet_config.js index 0b3760d0477..d5bd42d5da2 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_config.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_config.js @@ -12,15 +12,6 @@ Polymer({ behaviors: [I18nBehavior], properties: { - /** - * Interface for networkingPrivate calls, passed from internet_page. - * @type {NetworkingPrivate} - */ - networkingPrivate: Object, - - /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */ - globalPolicy: Object, - /** @private */ shareAllowEnable_: { type: Boolean, @@ -44,13 +35,14 @@ Polymer({ guid: String, /** - * The type of network to be configured. - * @type {!chrome.networkingPrivate.NetworkType} + * The type of network to be configured as a string. May be set initially or + * updated by network-config. */ type: String, /** - * The name of network (for display while the network details are fetched). + * The name of the network. May be set initially or updated by + * network-config. */ name: String, @@ -66,14 +58,6 @@ Polymer({ enableSave_: Boolean, /** - * The current properties if an existing network is being configured, or - * a minimal subset for a new network. Note: network-config may modify - * this (specifically .name). - * @private {!chrome.networkingPrivate.ManagedProperties} - */ - managedProperties_: Object, - - /** * Set by network-config when a configuration error occurs. * @private */ @@ -89,14 +73,6 @@ Polymer({ dialog.showModal(); } - // Set managedProperties for new configurations and for existing - // configurations until the current properties are loaded. - assert(this.type && this.type != CrOnc.Type.ALL); - this.managedProperties_ = { - GUID: this.guid, - Name: {Active: this.name}, - Type: this.type, - }; this.$.networkConfig.init(); }, @@ -113,7 +89,6 @@ Polymer({ */ onClose_: function(event) { this.close(); - event.stopPropagation(); }, /** @@ -121,18 +96,10 @@ Polymer({ * @private */ getDialogTitle_: function() { - // If no properties are available yet, wait until they are set as part of - // open(). - if (!this.managedProperties_) { - return ''; - } - - const name = /** @type {string} */ ( - CrOnc.getActiveValue(this.managedProperties_.Name)); - if (name && !this.showConnect) { - return this.i18n('internetConfigName', HTMLEscape(name)); + if (this.name && !this.showConnect) { + return this.i18n('internetConfigName', HTMLEscape(this.name)); } - const type = this.i18n('OncType' + this.managedProperties_.Type); + const type = this.i18n('OncType' + this.type); return this.i18n('internetJoinType', type); }, diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html index c78ca56e50b..2d27c7dc86d 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html @@ -8,7 +8,6 @@ <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_siminfo.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_listener_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> @@ -68,10 +67,15 @@ paper-spinner-lite { @apply --cr-icon-height-width; } + .warning { color: var(--cr-secondary-text-color); margin-inline-start: var(--settings-controlled-by-spacing); } + + #mac-address-container { + border-top: none; + } </style> <!-- Title section: Icon + name + connection state. --> <div id="titleDiv" class="settings-box first"> @@ -83,9 +87,9 @@ <div id="networkState" class="title settings-box-text" connected$="[[isConnectedState_(managedProperties_)]]" error$="[[isConnectionErrorState_( - managedProperties_, outOfRange_)]]"> + managedProperties_, outOfRange_, deviceState_)]]"> [[getStateText_(managedProperties_, propertiesReceived_, - outOfRange_)]] + outOfRange_, deviceState_)]] </div> <template is="dom-if" if="[[isPolicySource(managedProperties_.source))]]"> @@ -118,17 +122,18 @@ </cr-button> <!-- Use policy properties from vpn_config_allowed to indicate when that pref disables buttons in this row. --> - <controlled-button id="connect" action-button on-click="onConnectTap_" + <controlled-button id="connect" class="action-button" + on-click="onConnectTap_" hidden$="[[!showConnect_(managedProperties_, globalPolicy, - managedNetworkAvailable)]]" + managedNetworkAvailable, deviceState_)]]" disabled="[[!enableConnect_(managedProperties_, defaultNetwork, propertiesReceived_, outOfRange_, globalPolicy, - managedNetworkAvailable)]]" + managedNetworkAvailable, deviceState_)]]" label="$i18n{networkButtonConnect}" pref="[[getFakeVpnConfigPrefForEnforcement_(managedProperties_, prefs.vpn_config_allowed)]]"> </controlled-button> - <controlled-button id="disconnect" action-button + <controlled-button id="disconnect" class="action-button" on-click="onDisconnectTap_" hidden$="[[!showDisconnect_(managedProperties_)]]" label="$i18n{networkButtonDisconnect}" @@ -324,6 +329,7 @@ <!-- MAC Address. --> <div class="settings-box two-line single-column stretch indented" + id="mac-address-container" hidden$="[[!deviceState_.macAddress]]"> <div>$i18n{OncMacAddress}</div> <div class="secondary">[[deviceState_.macAddress]]</div> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js index 3dd71d9ff20..7c15915a2c8 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js @@ -104,12 +104,6 @@ Polymer({ }, /** - * Interface for networkingPrivate calls, passed from internet_page. - * @type {NetworkingPrivate} - */ - networkingPrivate: Object, - - /** * The network AutoConnect state as a fake preference object. * @private {!chrome.settingsPrivate.PrefObject|undefined} */ @@ -205,12 +199,7 @@ Polymer({ /** @private {settings.InternetPageBrowserProxy} */ browserProxy_: null, - /** - * This UI will use both the networkingPrivate extension API and the - * networkConfig mojo API until we provide all of the required functionality - * in networkConfig. TODO(stevenjb): Remove use of networkingPrivate api. - * @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} - */ + /** @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */ networkConfig_: null, /** @override */ @@ -355,10 +344,9 @@ Polymer({ if (!this.didSetFocus_) { // Focus a button once the initial state is set. this.didSetFocus_ = true; - const button = this.$$('#titleDiv .action-button:not([hidden])') || - this.$$('#titleDiv cr-button:not([hidden])'); + const button = this.$$('#titleDiv .action-button:not([hidden])'); if (button) { - setTimeout(() => button.focus()); + Polymer.RenderStatus.afterNextRender(this, () => button.focus()); } } @@ -389,7 +377,7 @@ Polymer({ if (!this.propertiesReceived_) { return; } - const config = {}; + const config = this.getDefaultConfigProperties_(); config.autoConnect = {value: !!this.autoConnectPref_.value}; this.setMojoNetworkProperties_(config); }, @@ -441,7 +429,7 @@ Polymer({ if (!this.propertiesReceived_) { return; } - const config = {}; + const config = this.getDefaultConfigProperties_(); config.priority = {value: this.preferNetwork_ ? 1 : 0}; this.setMojoNetworkProperties_(config); }, @@ -451,7 +439,7 @@ Polymer({ const filter = { filter: mojom.FilterType.kVisible, networkType: mojom.NetworkType.kAll, - limit: mojom.kNoLimit, + limit: mojom.NO_LIMIT, }; this.networkConfig_.getNetworkState(this.guid).then(response => { if (response.result) { @@ -522,10 +510,25 @@ Polymer({ this.close(); return; } + const managedProperties = OncMojo.getDefaultManagedProperties( networkState.type, networkState.guid, networkState.name); managedProperties.connectable = networkState.connectable; managedProperties.connectionState = networkState.connectionState; + switch (networkState.type) { + case mojom.NetworkType.kCellular: + managedProperties.typeProperties.cellular.signalStrength = + networkState.typeState.cellular.signalStrength; + break; + case mojom.NetworkType.kTether: + managedProperties.typeProperties.tether.signalStrength = + networkState.typeState.tether.signalStrength; + break; + case mojom.NetworkType.kWiFi: + managedProperties.typeProperties.wifi.signalStrength = + networkState.typeState.wifi.signalStrength; + break; + } this.managedProperties_ = managedProperties; this.propertiesReceived_ = true; @@ -544,6 +547,14 @@ Polymer({ }, /** + * @return {!mojom.ConfigProperties} + * @private + */ + getDefaultConfigProperties_: function() { + return OncMojo.getDefaultConfigProperties(this.managedProperties_.type); + }, + + /** * @param {!mojom.ConfigProperties} config * @private */ @@ -565,15 +576,17 @@ Polymer({ * @param {!mojom.ManagedProperties} managedProperties * @param {boolean} propertiesReceived * @param {boolean} outOfRange + * @param {?OncMojo.DeviceStateProperties} deviceState * @return {string} The text to display for the network connection state. * @private */ - getStateText_: function(managedProperties, propertiesReceived, outOfRange) { + getStateText_: function( + managedProperties, propertiesReceived, outOfRange, deviceState) { if (!managedProperties || !propertiesReceived) { return ''; } - if (outOfRange) { + if (this.isOutOfRangeOrNotEnabled_(outOfRange, deviceState)) { return managedProperties.type == mojom.NetworkType.kTether ? this.i18n('tetherPhoneOutOfRange') : this.i18n('networkOutOfRange'); @@ -581,11 +594,11 @@ Polymer({ if (managedProperties.type == mojom.NetworkType.kCellular && !managedProperties.connectable) { - if (managedProperties.cellular.homeProvider && - managedProperties.cellular.homeProvider.name) { + if (managedProperties.typeProperties.cellular.homeProvider && + managedProperties.typeProperties.cellular.homeProvider.name) { return this.i18n( 'cellularContactSpecificCarrier', - managedProperties.cellular.homeProvider.name); + managedProperties.typeProperties.cellular.homeProvider.name); } return this.i18n('cellularContactDefaultCarrier'); } @@ -614,11 +627,11 @@ Polymer({ if (!this.isCellular_(managedProperties)) { return ''; } - if (!managedProperties.cellular.allowRoaming) { + if (!managedProperties.typeProperties.cellular.allowRoaming) { return this.i18n('networkAllowDataRoamingDisabled'); } - return managedProperties.cellular.roamingState == 'Roaming' ? + return managedProperties.typeProperties.cellular.roamingState == 'Roaming' ? this.i18n('networkAllowDataRoamingEnabledRoaming') : this.i18n('networkAllowDataRoamingEnabledHome'); }, @@ -636,11 +649,13 @@ Polymer({ /** * @param {!mojom.ManagedProperties|undefined} managedProperties * @param {boolean} outOfRange + * @param {?OncMojo.DeviceStateProperties} deviceState * @return {boolean} True if the network shown cannot initiate a connection. * @private */ - isConnectionErrorState_: function(managedProperties, outOfRange) { - if (outOfRange) { + isConnectionErrorState_: function( + managedProperties, outOfRange, deviceState) { + if (this.isOutOfRangeOrNotEnabled_(outOfRange, deviceState)) { return true; } @@ -710,7 +725,8 @@ Polymer({ this.isPolicySource(managedProperties.source)) { return false; } - const hexSsid = OncMojo.getActiveString(managedProperties.wifi.hexSsid); + const hexSsid = + OncMojo.getActiveString(managedProperties.typeProperties.wifi.hexSsid); return !!globalPolicy.allowOnlyPolicyNetworksToConnect || (!!globalPolicy.allowOnlyPolicyNetworksToConnectIfAvailable && !!managedNetworkAvailable) || @@ -722,11 +738,12 @@ Polymer({ * @param {!mojom.ManagedProperties} managedProperties * @param {!mojom.GlobalPolicy} globalPolicy * @param {boolean} managedNetworkAvailable + * @param {?OncMojo.DeviceStateProperties} deviceState * @return {boolean} * @private */ showConnect_: function( - managedProperties, globalPolicy, managedNetworkAvailable) { + managedProperties, globalPolicy, managedNetworkAvailable, deviceState) { if (!managedProperties) { return false; } @@ -741,15 +758,24 @@ Polymer({ if (this.isArcVpn_(managedProperties)) { return false; } + if (managedProperties.connectionState != mojom.ConnectionStateType.kNotConnected) { return false; } + + if (deviceState && + deviceState.deviceState != + chromeos.networkConfig.mojom.DeviceStateType.kEnabled) { + return false; + } + // Cellular is not configurable, so we always show the connect button, and // disable it if 'connectable' is false. if (managedProperties.type == mojom.NetworkType.kCellular) { return true; } + // If 'connectable' is false we show the configure button. return managedProperties.connectable && managedProperties.type != mojom.NetworkType.kEthernet; @@ -801,7 +827,8 @@ Polymer({ if (!this.isCellular_(managedProperties)) { return false; } - const activation = managedProperties.cellular.activationState; + const activation = + managedProperties.typeProperties.cellular.activationState; return activation == mojom.ActivationStateType.kNotActivated || activation == mojom.ActivationStateType.kPartiallyActivated; }, @@ -828,7 +855,8 @@ Polymer({ return false; } if (type == mojom.NetworkType.kWiFi && - managedProperties.wifi.security == mojom.SecurityType.kNone) { + managedProperties.typeProperties.wifi.security == + mojom.SecurityType.kNone) { return false; } if (type == mojom.NetworkType.kWiFi && @@ -916,18 +944,20 @@ Polymer({ return false; } - const paymentPortal = managedProperties.cellular.paymentPortal; + const paymentPortal = + managedProperties.typeProperties.cellular.paymentPortal; if (!paymentPortal || !paymentPortal.url) { return false; } // Only show for connected networks or LTE networks with a valid MDN. if (!this.isConnectedState_(managedProperties)) { - const technology = managedProperties.cellular.networkTechnology; + const technology = + managedProperties.typeProperties.cellular.networkTechnology; if (technology != 'LTE' && technology != 'LTEAdvanced') { return false; } - if (!managedProperties.cellular.mdn) { + if (!managedProperties.typeProperties.cellular.mdn) { return false; } } @@ -942,14 +972,16 @@ Polymer({ * @param {boolean} outOfRange * @param {!mojom.GlobalPolicy} globalPolicy * @param {boolean} managedNetworkAvailable + * @param {?OncMojo.DeviceStateProperties} deviceState * @return {boolean} Whether or not to enable the network connect button. * @private */ enableConnect_: function( managedProperties, defaultNetwork, propertiesReceived, outOfRange, - globalPolicy, managedNetworkAvailable) { + globalPolicy, managedNetworkAvailable, deviceState) { if (!this.showConnect_( - managedProperties, globalPolicy, managedNetworkAvailable)) { + managedProperties, globalPolicy, managedNetworkAvailable, + deviceState)) { return false; } if (!propertiesReceived || outOfRange) { @@ -1017,7 +1049,7 @@ Polymer({ /** @private */ onConnectTap_: function() { if (this.managedProperties_.type == mojom.NetworkType.kTether && - (!this.managedProperties_.tether.hasConnectedToHost)) { + (!this.managedProperties_.typeProperties.tether.hasConnectedToHost)) { this.showTetherDialog_(); return; } @@ -1054,9 +1086,13 @@ Polymer({ /** @private */ onForgetTap_: function() { - this.networkingPrivate.forgetNetwork(this.guid); - // A forgotten network no longer has a valid GUID, close the subpage. - this.close(); + this.networkConfig_.forgetNetwork(this.guid).then(response => { + if (!response.success) { + console.error('Froget network failed for: ' + this.guid); + } + // A forgotten network no longer has a valid GUID, close the subpage. + this.close(); + }); }, /** @private */ @@ -1102,8 +1138,9 @@ Polymer({ return loadTimeData.getBoolean('showHiddenNetworkWarning') && !!this.autoConnectPref_ && !!this.autoConnectPref_.value && !!this.managedProperties_ && - !!this.managedProperties_.type == mojom.NetworkType.kWiFi && - !!OncMojo.getActiveValue(this.managedProperties_.wifi.hiddenSsid); + this.managedProperties_.type == mojom.NetworkType.kWiFi && + !!OncMojo.getActiveValue( + this.managedProperties_.typeProperties.wifi.hiddenSsid); }, /** @@ -1120,7 +1157,7 @@ Polymer({ } const field = e.detail.field; const value = e.detail.value; - const config = {}; + const config = this.getDefaultConfigProperties_(); const valueType = typeof value; if (valueType != 'string' && valueType != 'number' && valueType != 'boolean' && !Array.isArray(value)) { @@ -1130,10 +1167,17 @@ Polymer({ return; } OncMojo.setConfigProperty(config, field, value); - // Ensure any required configuration properties are also set. - if (this.managedProperties_.vpn && config.vpn && - config.vpn.type === undefined) { - config.vpn.type = this.managedProperties_.vpn.type; + // Ensure that any required configuration properties for partial + // configurations are set. + const vpnConfig = config.typeConfig.vpn; + if (vpnConfig) { + vpnConfig.type = this.managedProperties_.typeProperties.vpn.type; + if (vpnConfig.openVpn && vpnConfig.openVpn.saveCredentials == undefined) { + vpnConfig.openVpn.saveCredentials = false; + } + if (vpnConfig.l2tp && vpnConfig.l2tp.saveCredentials == undefined) { + vpnConfig.l2tp.saveCredentials = false; + } } this.setMojoNetworkProperties_(config); }, @@ -1146,8 +1190,9 @@ Polymer({ if (!this.propertiesReceived_) { return; } + const config = this.getDefaultConfigProperties_(); const apn = event.detail; - const config = {cellular: {apn: apn}}; + config.typeConfig.cellular = {apn: apn}; this.setMojoNetworkProperties_(config); }, @@ -1180,7 +1225,9 @@ Polymer({ if (!this.propertiesReceived_) { return; } - this.setMojoNetworkProperties_({proxySettings: event.detail}); + const config = this.getDefaultConfigProperties_(); + config.proxySettings = event.detail; + this.setMojoNetworkProperties_(config); }, /** @@ -1226,7 +1273,7 @@ Polymer({ return this.isArcVpn_(managedProperties) && this.prefs.arc && this.prefs.arc.vpn && this.prefs.arc.vpn.always_on && this.prefs.arc.vpn.always_on.vpn_package && - OncMojo.getActiveValue(managedProperties.vpn.host) === + OncMojo.getActiveValue(managedProperties.typeProperties.vpn.host) === this.prefs.arc.vpn.always_on.vpn_package.value; }, @@ -1289,7 +1336,8 @@ Polymer({ */ hasVisibleFields_: function(fields) { for (let i = 0; i < fields.length; ++i) { - const value = this.get(fields[i], this.managedProperties_); + const key = OncMojo.getManagedPropertyKey(fields[i]); + const value = this.get(key, this.managedProperties_); if (value !== undefined && value !== '') { return true; } @@ -1316,39 +1364,44 @@ Polymer({ } /** @type {!Array<string>} */ const fields = []; - const type = this.managedProperties_.type; - if (type == mojom.NetworkType.kCellular) { - fields.push('cellular.activationState', 'cellular.servingOperator.name'); - if (this.managedProperties_.restrictedConnectivity) { - fields.push('restrictedConnectivity'); - } - } else if (type == mojom.NetworkType.kTether) { - fields.push( - 'tether.batteryPercentage', 'tether.signalStrength', - 'tether.carrier'); - } else if (type == mojom.NetworkType.kVPN) { - const vpnType = this.managedProperties_.vpn.type; - switch (vpnType) { - case mojom.VpnType.kExtension: - fields.push('vpn.providerName'); - break; - case mojom.VpnType.kArc: - fields.push('vpn.type'); - fields.push('vpn.providerName'); - break; - case mojom.VpnType.kOpenVPN: - fields.push( - 'vpn.type', 'vpn.host', 'vpn.openVpn.username', - 'vpn.openVpn.extraHosts'); - break; - case mojom.VpnType.kL2TPIPsec: - fields.push('vpn.type', 'vpn.host', 'vpn.l2tp.username'); - break; - } - } else if (type == mojom.NetworkType.kWiFi) { - if (this.managedProperties_.restrictedConnectivity) { - fields.push('restrictedConnectivity'); - } + switch (this.managedProperties_.type) { + case mojom.NetworkType.kCellular: + fields.push( + 'cellular.activationState', 'cellular.servingOperator.name'); + if (this.managedProperties_.restrictedConnectivity) { + fields.push('restrictedConnectivity'); + } + break; + case mojom.NetworkType.kTether: + fields.push( + 'tether.batteryPercentage', 'tether.signalStrength', + 'tether.carrier'); + break; + case mojom.NetworkType.kVPN: + const vpnType = this.managedProperties_.typeProperties.vpn.type; + switch (vpnType) { + case mojom.VpnType.kExtension: + fields.push('vpn.providerName'); + break; + case mojom.VpnType.kArc: + fields.push('vpn.type'); + fields.push('vpn.providerName'); + break; + case mojom.VpnType.kOpenVPN: + fields.push( + 'vpn.type', 'vpn.host', 'vpn.openVpn.username', + 'vpn.openVpn.extraHosts'); + break; + case mojom.VpnType.kL2TPIPsec: + fields.push('vpn.type', 'vpn.host', 'vpn.l2tp.username'); + break; + } + break; + case mojom.NetworkType.kWiFi: + if (this.managedProperties_.restrictedConnectivity) { + fields.push('restrictedConnectivity'); + } + break; } return fields; }, @@ -1368,7 +1421,7 @@ Polymer({ /** @dict */ const editFields = {}; const type = this.managedProperties_.type; if (type == mojom.NetworkType.kVPN) { - const vpnType = this.managedProperties_.vpn.type; + const vpnType = this.managedProperties_.typeProperties.vpn.type; if (vpnType != mojom.VpnType.kExtension) { editFields['vpn.host'] = 'String'; } @@ -1391,15 +1444,19 @@ Polymer({ /** @type {!Array<string>} */ const fields = []; const type = this.managedProperties_.type; - if (type == mojom.NetworkType.kCellular) { - fields.push( - 'cellular.family', 'cellular.networkTechnology', - 'cellular.servingOperator.code'); - } else if (type == mojom.NetworkType.kWiFi) { - fields.push( - 'wifi.ssid', 'wifi.bssid', 'wifi.signalStrength', 'wifi.security', - 'wifi.eap.outer', 'wifi.eap.inner', 'wifi.eap.subjectMatch', - 'wifi.eap.identity', 'wifi.eap.anonymousIdentity', 'wifi.frequency'); + switch (type) { + case mojom.NetworkType.kCellular: + fields.push( + 'cellular.family', 'cellular.networkTechnology', + 'cellular.servingOperator.code'); + break; + case mojom.NetworkType.kWiFi: + fields.push( + 'wifi.ssid', 'wifi.bssid', 'wifi.signalStrength', 'wifi.security', + 'wifi.eap.outer', 'wifi.eap.inner', 'wifi.eap.subjectMatch', + 'wifi.eap.identity', 'wifi.eap.anonymousIdentity', + 'wifi.frequency'); + break; } return fields; }, @@ -1520,7 +1577,7 @@ Polymer({ showCellularChooseNetwork_: function(managedProperties) { return !!managedProperties && managedProperties.type == mojom.NetworkType.kCellular && - managedProperties.cellular.supportNetworkScan; + managedProperties.typeProperties.cellular.supportNetworkScan; }, /** @@ -1543,7 +1600,7 @@ Polymer({ showCellularSim_: function(managedProperties) { return !!managedProperties && managedProperties.type == mojom.NetworkType.kCellular && - managedProperties.cellular.family != 'CDMA'; + managedProperties.typeProperties.cellular.family != 'CDMA'; }, /** @@ -1554,7 +1611,7 @@ Polymer({ isArcVpn_: function(managedProperties) { return !!managedProperties && managedProperties.type == mojom.NetworkType.kVPN && - managedProperties.vpn.type == mojom.VpnType.kArc; + managedProperties.typeProperties.vpn.type == mojom.VpnType.kArc; }, /** @@ -1565,7 +1622,7 @@ Polymer({ isThirdPartyVpn_: function(managedProperties) { return !!managedProperties && managedProperties.type == mojom.NetworkType.kVPN && - managedProperties.vpn.type == mojom.VpnType.kExtension; + managedProperties.typeProperties.vpn.type == mojom.VpnType.kExtension; }, /** @@ -1608,5 +1665,18 @@ Polymer({ } return true; }, + + /** + * @param {boolean} outOfRange + * @param {?OncMojo.DeviceStateProperties} deviceState + * @return {boolean} + * @private + */ + isOutOfRangeOrNotEnabled_: function(outOfRange, deviceState) { + return outOfRange || + (!!deviceState && + deviceState.deviceState != + chromeos.networkConfig.mojom.DeviceStateType.kEnabled); + }, }); })(); diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js index 2e42c952c87..3351442766d 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js @@ -18,20 +18,14 @@ Polymer({ properties: { /** * The type of networks to list. - * @type {CrOnc.Type} + * @type {chromeos.networkConfig.mojom.NetworkType|undefined} */ networkType: { - type: String, + type: Number, observer: 'networkTypeChanged_', }, /** - * Interface for networkingPrivate calls, passed from internet_page. - * @type {NetworkingPrivate} - */ - networkingPrivate: Object, - - /** * List of all network state data for the network type. * @private {!Array<!OncMojo.NetworkStateProperties>} */ @@ -60,12 +54,7 @@ Polymer({ /** @private {string} */ selectedGuid_: '', - /** - * This UI will use both the networkingPrivate extension API and the - * networkConfig mojo API until we provide all of the required functionality - * in networkConfig. TODO(stevenjb): Remove use of networkingPrivate api. - * @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} - */ + /** @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */ networkConfig_: null, /** @override */ @@ -90,13 +79,13 @@ Polymer({ * @private */ refreshNetworks_: function() { - if (!this.networkType) { + if (this.networkType === undefined) { return; } const filter = { filter: chromeos.networkConfig.mojom.FilterType.kConfigured, - limit: chromeos.networkConfig.mojom.kNoLimit, - networkType: OncMojo.getNetworkTypeFromString(this.networkType), + limit: chromeos.networkConfig.mojom.NO_LIMIT, + networkType: this.networkType, }; this.networkConfig_.getNetworkStateList(filter).then(response => { this.networkStateList_ = response.result; @@ -201,19 +190,29 @@ Polymer({ /** @private */ onRemovePreferredTap_: function() { - this.setProperties_({priority: {value: 0}}); + assert(this.networkType !== undefined); + const config = OncMojo.getDefaultConfigProperties(this.networkType); + config.priority = {value: 0}; + this.setProperties_(config); /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close(); }, /** @private */ onAddPreferredTap_: function() { - this.setProperties_({priority: {value: 1}}); + assert(this.networkType !== undefined); + const config = OncMojo.getDefaultConfigProperties(this.networkType); + config.priority = {value: 1}; + this.setProperties_(config); /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close(); }, /** @private */ onForgetTap_: function() { - this.networkingPrivate.forgetNetwork(this.selectedGuid_); + this.networkConfig_.forgetNetwork(this.selectedGuid_).then(response => { + if (!response.success) { + console.error('Froget network failed for: ' + this.selectedGuid_); + } + }); /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close(); }, diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page.html b/chromium/chrome/browser/resources/settings/internet_page/internet_page.html index 10eeff05b0a..f9b99636a51 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_page.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page.html @@ -1,7 +1,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/mojo_interface_provider.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> +<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_listener_behavior.html"> <link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/icons.html"> @@ -49,13 +49,12 @@ </cr-expand-button> <template is="dom-if" if="[[addConnectionExpanded_]]"> <div class="list-frame vertical-list"> - <template is="dom-if" - if="[[deviceIsEnabled_(deviceStates, 'WiFi')]]"> + <template is="dom-if" if="[[wifiIsEnabled_(deviceStates)]]"> <div actionable class="list-item" on-click="onAddWiFiTap_"> <div class="start settings-box-text"> $i18n{internetAddWiFi} </div> - <cr-icon-button class$="[[getAddNetworkClass_('WiFi')]]" + <cr-icon-button class="icon-add-wifi" aria-label="$i18n{internetAddWiFi}"></cr-icon-button> </div> </template> @@ -63,7 +62,7 @@ <div class="start settings-box-text"> $i18n{internetAddVPN} </div> - <cr-icon-button class$="[[getAddNetworkClass_('VPN')]]" + <cr-icon-button class="icon-add-circle" aria-label="$i18n{internetAddVPN}"></cr-icon-button> </div> <template is="dom-repeat" items="[[vpnProviders_]]"> @@ -96,7 +95,6 @@ <settings-internet-detail-page prefs="{{prefs}}" default-network="[[defaultNetwork]]" global-policy="[[globalPolicy_]]" - networking-private="[[networkingPrivate]]" managed-network-available="[[managedNetworkAvailable]]"> </settings-internet-detail-page> </settings-subpage> @@ -105,8 +103,7 @@ <template is="dom-if" route-path="/knownNetworks" no-search restamp> <settings-subpage page-title="$i18n{internetKnownNetworksPageTitle}"> <settings-internet-known-networks-page - network-type="[[knownNetworksType_]]" - networking-private="[[networkingPrivate]]"> + network-type="[[knownNetworksType_]]"> </settings-internet-known-networks-page> </settings-subpage> </template> @@ -128,10 +125,10 @@ </settings-animated-pages> - <internet-config id="configDialog" - networking-private="[[networkingPrivate]]" - global-policy="[[globalPolicy_]]"> - </internet-config> + <template is="dom-if" if="[[showInternetConfig_]]" restamp> + <internet-config id="configDialog" on-close="onInternetConfigClose_"> + </internet-config> + </template> </template> <script src="internet_page.js"></script> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_page.js index 1737c822b40..8f2b2d7b745 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_page.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page.js @@ -22,14 +22,6 @@ Polymer({ ], properties: { - /** - * Interface for networkingPrivate calls. May be overriden by tests. - * @type {NetworkingPrivate} - */ - networkingPrivate: { - type: Object, - value: chrome.networkingPrivate, - }, /** Preferences state. */ prefs: { @@ -65,16 +57,18 @@ Polymer({ showSpinner_: Boolean, /** - * The network type for the networks subpage. Used in the subpage header. + * The network type for the networks subpage when shown. + * @type {chromeos.networkConfig.mojom.NetworkType} * @private */ - subpageType_: String, + subpageType_: Number, /** - * The network type for the known networks subpage. + * The network type for the known networks subpage when shown. + * @type {chromeos.networkConfig.mojom.NetworkType} * @private */ - knownNetworksType_: String, + knownNetworksType_: Number, /** * Whether the 'Add connection' section is expanded. @@ -109,6 +103,12 @@ Polymer({ } }, + /** @private {boolean} */ + showInternetConfig_: { + type: Boolean, + value: false, + }, + /** @private {!Map<string, Element>} */ focusConfig_: { type: Object, @@ -118,8 +118,11 @@ Polymer({ }, }, - /** @private {string} Type of last detail page visited. */ - detailType_: '', + /** + * Type of last detail page visited + * @private {chromeos.networkConfig.mojom.NetworkType|undefined} + */ + detailType_: undefined, // Element event listeners listeners: { @@ -134,12 +137,7 @@ Polymer({ /** @private {?settings.InternetPageBrowserProxy} */ browserProxy_: null, - /** - * This UI will use both the networkingPrivate extension API and the - * networkConfig mojo API until we provide all of the required functionality - * in networkConfig. TODO(stevenjb): Remove use of networkingPrivate api. - * @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} - */ + /** @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */ networkConfig_: null, /** @override */ @@ -170,7 +168,7 @@ Polymer({ const queryParams = settings.getQueryParameters(); const type = queryParams.get('type'); if (type) { - this.subpageType_ = type; + this.subpageType_ = OncMojo.getNetworkTypeFromString(type); } } else if (route == settings.routes.KNOWN_NETWORKS) { // Handle direct navigation to the known networks page, @@ -178,7 +176,7 @@ Polymer({ const queryParams = settings.getQueryParameters(); const type = queryParams.get('type'); if (type) { - this.knownNetworksType_ = type; + this.knownNetworksType_ = OncMojo.getNetworkTypeFromString(type); } } else if ( route != settings.routes.INTERNET && route != settings.routes.BASIC) { @@ -201,9 +199,9 @@ Polymer({ if (subPage) { element = subPage.$$('#networkList'); } - } else if (this.detailType_) { - const rowForDetailType = - this.$$('network-summary').$$(`#${this.detailType_}`); + } else if (this.detailType_ !== undefined) { + const oncType = OncMojo.getNetworkTypeString(this.detailType_); + const rowForDetailType = this.$$('network-summary').$$(`#${oncType}`); // Note: It is possible that the row is no longer present in the DOM // (e.g., when a Cellular dongle is unplugged or when Instant Tethering @@ -219,7 +217,7 @@ Polymer({ } }, - /** CrosNetworkConfigObserver impl */ + /** CrNetworkListenerBehavior override */ onVpnProvidersChanged: function() { this.networkConfig_.getVpnProviders().then(response => { const providers = response.providers; @@ -246,33 +244,48 @@ Polymer({ * @private */ onShowConfig_: function(event) { + const type = OncMojo.getNetworkTypeFromString(event.detail.type); if (!event.detail.guid) { // New configuration - this.showConfig_(true /* configAndConnect */, event.detail.type); + this.showConfig_(true /* configAndConnect */, type); } else { this.showConfig_( - false /* configAndConnect */, event.detail.type, event.detail.guid, + false /* configAndConnect */, type, event.detail.guid, event.detail.name); } }, /** * @param {boolean} configAndConnect - * @param {string} type + * @param {chromeos.networkConfig.mojom.NetworkType} type * @param {?string=} opt_guid * @param {?string=} opt_name * @private */ showConfig_: function(configAndConnect, type, opt_guid, opt_name) { - assert(type != CrOnc.Type.CELLULAR && type != CrOnc.Type.TETHER); - const configDialog = - /** @type {!InternetConfigElement} */ (this.$.configDialog); - configDialog.type = - /** @type {chrome.networkingPrivate.NetworkType} */ (type); - configDialog.guid = opt_guid || ''; - configDialog.name = opt_name || ''; - configDialog.showConnect = configAndConnect; - configDialog.open(); + assert( + type != chromeos.networkConfig.mojom.NetworkType.kCellular && + type != chromeos.networkConfig.mojom.NetworkType.kTether); + if (this.showInternetConfig_) { + return; + } + this.showInternetConfig_ = true; + // Async call to ensure dialog is stamped. + setTimeout(() => { + const configDialog = + /** @type {!InternetConfigElement} */ (this.$$('#configDialog')); + assert(!!configDialog); + configDialog.type = OncMojo.getNetworkTypeString(type); + configDialog.guid = opt_guid || ''; + configDialog.name = opt_name || ''; + configDialog.showConnect = configAndConnect; + configDialog.open(); + }); + }, + + /** @private */ + onInternetConfigClose_: function() { + this.showInternetConfig_ = false; }, /** @@ -281,11 +294,10 @@ Polymer({ */ onShowDetail_: function(event) { const networkState = event.detail; - const oncType = OncMojo.getNetworkTypeString(networkState.type); - this.detailType_ = oncType; + this.detailType_ = networkState.type; const params = new URLSearchParams; params.append('guid', networkState.guid); - params.append('type', oncType); + params.append('type', OncMojo.getNetworkTypeString(networkState.type)); params.append('name', OncMojo.getNetworkStateDisplayName(networkState)); settings.navigateTo(settings.routes.NETWORK_DETAIL, params); }, @@ -306,39 +318,31 @@ Polymer({ // The shared Cellular/Tether subpage is referred to as "Mobile". // TODO(khorimoto): Remove once Cellular/Tether are split into their own // sections. - if (this.subpageType_ == CrOnc.Type.CELLULAR || - this.subpageType_ == CrOnc.Type.TETHER) { + if (this.subpageType_ == mojom.NetworkType.kCellular || + this.subpageType_ == mojom.NetworkType.kTether) { return this.i18n('OncTypeMobile'); } - return this.i18n('OncType' + this.subpageType_); - }, - - /** - * @param {string} type - * @return {string} - * @private - */ - getAddNetworkClass_: function(type) { - return type == CrOnc.Type.WI_FI ? 'icon-add-wifi' : 'icon-add-circle'; + return this.i18n( + 'OncType' + OncMojo.getNetworkTypeString(this.subpageType_)); }, /** - * @param {string} subpageType + * @param {chromeos.networkConfig.mojom.NetworkType} subpageType * @param {!Object<!OncMojo.DeviceStateProperties>|undefined} deviceStates * @return {!OncMojo.DeviceStateProperties|undefined} * @private */ getDeviceState_: function(subpageType, deviceStates) { - if (!subpageType) { + if (subpageType === undefined) { return undefined; } // If both Tether and Cellular are enabled, use the Cellular device state // when directly navigating to the Tether page. - if (subpageType == CrOnc.Type.TETHER && + if (subpageType == mojom.NetworkType.kTether && this.deviceStates[mojom.NetworkType.kCellular]) { - subpageType = CrOnc.Type.CELLULAR; + subpageType = mojom.NetworkType.kCellular; } - return deviceStates[OncMojo.getNetworkTypeFromString(subpageType)]; + return deviceStates[subpageType]; }, /** @@ -356,7 +360,8 @@ Polymer({ * @private */ onDeviceStatesChanged_: function(newValue, oldValue) { - const wifiDeviceState = this.getDeviceState_(CrOnc.Type.WI_FI, newValue); + const wifiDeviceState = + this.getDeviceState_(mojom.NetworkType.kWiFi, newValue); let managedNetworkAvailable = false; if (wifiDeviceState) { managedNetworkAvailable = !!wifiDeviceState.managedNetworkAvailable; @@ -366,9 +371,7 @@ Polymer({ this.managedNetworkAvailable = managedNetworkAvailable; } - if (this.detailType_ && - !this.deviceStates[OncMojo.getNetworkTypeFromString( - this.detailType_)]) { + if (this.detailType_ && !this.deviceStates[this.detailType_]) { // If the device type associated with the current network has been // removed (e.g., due to unplugging a Cellular dongle), the details page, // if visible, displays controls which are no longer functional. If this @@ -385,22 +388,26 @@ Polymer({ * @private */ onShowKnownNetworks_: function(event) { - const oncType = OncMojo.getNetworkTypeString(event.detail); - this.detailType_ = oncType; - this.knownNetworksType_ = oncType; + const type = event.detail; + this.detailType_ = type; + this.knownNetworksType_ = type; const params = new URLSearchParams; - params.append('type', oncType); + params.append('type', OncMojo.getNetworkTypeString(type)); settings.navigateTo(settings.routes.KNOWN_NETWORKS, params); }, /** @private */ onAddWiFiTap_: function() { - this.showConfig_(true /* configAndConnect */, CrOnc.Type.WI_FI); + this.showConfig_( + true /* configAndConnect */, + chromeos.networkConfig.mojom.NetworkType.kWiFi); }, /** @private */ onAddVPNTap_: function() { - this.showConfig_(true /* configAndConnect */, CrOnc.Type.VPN); + this.showConfig_( + true /* configAndConnect */, + chromeos.networkConfig.mojom.NetworkType.kVPN); }, /** @@ -417,11 +424,10 @@ Polymer({ * @private */ showNetworksSubpage_: function(type) { - const oncType = OncMojo.getNetworkTypeString(type); - this.detailType_ = oncType; + this.detailType_ = type; const params = new URLSearchParams; - params.append('type', oncType); - this.subpageType_ = oncType; + params.append('type', OncMojo.getNetworkTypeString(type)); + this.subpageType_ = type; settings.navigateTo(settings.routes.INTERNET_NETWORKS, params); }, @@ -452,14 +458,13 @@ Polymer({ /** * @param {!Array<!OncMojo.DeviceStateProperties>} deviceStates - * @param {string} type * @return {boolean} * @private */ - deviceIsEnabled_: function(deviceStates, type) { - const device = deviceStates[OncMojo.getNetworkTypeFromString(type)]; - return !!device && - device.deviceState == + wifiIsEnabled_: function(deviceStates) { + const wifi = deviceStates[mojom.NetworkType.kWiFi]; + return !!wifi && + wifi.deviceState == chromeos.networkConfig.mojom.DeviceStateType.kEnabled; }, @@ -497,15 +502,15 @@ Polymer({ */ onNetworkConnect_: function(event) { const networkState = event.detail.networkState; - const oncType = OncMojo.getNetworkTypeString(networkState.type); + const type = networkState.type; const displayName = OncMojo.getNetworkStateDisplayName(networkState); if (!event.detail.bypassConnectionDialog && - networkState.type == mojom.NetworkType.kTether && - !networkState.tether.hasConnectedToHost) { + type == mojom.NetworkType.kTether && + !networkState.typeState.tether.hasConnectedToHost) { const params = new URLSearchParams; params.append('guid', networkState.guid); - params.append('type', oncType); + params.append('type', OncMojo.getNetworkTypeString(type)); params.append('name', displayName); params.append('showConfigure', true.toString()); @@ -513,10 +518,10 @@ Polymer({ return; } - const isMobile = OncMojo.networkTypeIsMobile(networkState.type); + const isMobile = OncMojo.networkTypeIsMobile(type); if (!isMobile && (!networkState.connectable || !!networkState.errorState)) { this.showConfig_( - true /* configAndConnect */, oncType, networkState.guid, displayName); + true /* configAndConnect */, type, networkState.guid, displayName); return; } @@ -532,7 +537,7 @@ Polymer({ case mojom.StartConnectResult.kNotConfigured: if (!isMobile) { this.showConfig_( - true /* configAndConnect */, oncType, networkState.guid, + true /* configAndConnect */, type, networkState.guid, displayName); } return; diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js index 9996d3b6538..8ce6c994e2f 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js @@ -120,12 +120,7 @@ Polymer({ /** @private {settings.InternetPageBrowserProxy} */ browserProxy_: null, - /** - * This UI will use both the networkingPrivate extension API and the - * networkConfig mojo API until we provide all of the required functionality - * in networkConfig. TODO(stevenjb): Remove use of networkingPrivate api. - * @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} - */ + /** @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */ networkConfig_: null, /** @override */ @@ -275,7 +270,7 @@ Polymer({ } const filter = { filter: chromeos.networkConfig.mojom.FilterType.kVisible, - limit: chromeos.networkConfig.mojom.kNoLimit, + limit: chromeos.networkConfig.mojom.NO_LIMIT, networkType: this.deviceState.type, }; this.networkConfig_.getNetworkStateList(filter).then(response => { @@ -298,7 +293,7 @@ Polymer({ this.tetherDeviceState) { const filter = { filter: chromeos.networkConfig.mojom.FilterType.kVisible, - limit: chromeos.networkConfig.mojom.kNoLimit, + limit: chromeos.networkConfig.mojom.NO_LIMIT, networkType: mojom.NetworkType.kTether, }; this.networkConfig_.getNetworkStateList(filter).then(response => { @@ -314,7 +309,7 @@ Polymer({ const thirdPartyVpns = {}; networkStates.forEach(state => { assert(state.type == mojom.NetworkType.kVPN); - switch (state.vpn.type) { + switch (state.typeState.vpn.type) { case mojom.VpnType.kL2TPIPsec: case mojom.VpnType.kOpenVPN: builtinNetworkStates.push(state); @@ -326,7 +321,7 @@ Polymer({ } // Otherwise Arc VPNs are treated the same as Extension VPNs. case mojom.VpnType.kExtension: - const providerId = state.vpn.providerId; + const providerId = state.typeState.vpn.providerId; thirdPartyVpns[providerId] = thirdPartyVpns[providerId] || []; thirdPartyVpns[providerId].push(state); break; @@ -354,7 +349,7 @@ Polymer({ for (const vpnList of Object.values(thirdPartyVpns)) { assert(vpnList.length > 0); // All vpns in the list will have the same type and provider id. - const vpn = vpnList[0].vpn; + const vpn = vpnList[0].typeState.vpn; const provider = { type: vpn.type, providerId: vpn.providerId, @@ -584,7 +579,8 @@ Polymer({ (!!this.globalPolicy.allowOnlyPolicyNetworksToConnectIfAvailable && !!this.deviceState && !!this.deviceState.managedNetworkAvailable) || (!!this.globalPolicy.blockedHexSsids && - this.globalPolicy.blockedHexSsids.includes(state.wifi.hexSsid)); + this.globalPolicy.blockedHexSsids.includes( + state.typeState.wifi.hexSsid)); }, /** diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.html b/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.html index a061a6e92ab..f44b433b079 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.html +++ b/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.html @@ -1,7 +1,6 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_proxy.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> <link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.js b/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.js index 3827c8cbf37..f04803663de 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.js +++ b/chromium/chrome/browser/resources/settings/internet_page/network_proxy_section.js @@ -60,12 +60,12 @@ Polymer({ }, /** - * @return {!OncMojo.ManagedProperty|undefined} + * @return {!mojom.ManagedString|undefined} * @private */ getProxySettingsTypeProperty_: function() { - return /** @type {!OncMojo.ManagedProperty|undefined} */ ( - this.get('proxySettings.type', this.managedProperties)); + const proxySettings = this.managedProperties.proxySettings; + return proxySettings ? proxySettings.type : undefined; }, /** diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary.js b/chromium/chrome/browser/resources/settings/internet_page/network_summary.js index ac6a45c2d31..bc02417ee3e 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_summary.js +++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary.js @@ -149,7 +149,7 @@ Polymer({ getNetworkStates_: function(deviceStateList) { const filter = { filter: chromeos.networkConfig.mojom.FilterType.kVisible, - limit: chromeos.networkConfig.mojom.kNoLimit, + limit: chromeos.networkConfig.mojom.NO_LIMIT, networkType: mojom.NetworkType.kAll, }; this.networkConfig_.getNetworkStateList(filter).then(response => { diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html index 5b26c96577a..4c6312d3dc0 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html +++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html @@ -2,7 +2,7 @@ <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_siminfo.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> +<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_strings.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js index 09cbcd3965e..7b26f618a41 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js +++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js @@ -132,7 +132,12 @@ Polymer({ const connectionState = networkState.connectionState; const name = OncMojo.getNetworkStateDisplayName(networkState); if (OncMojo.connectionStateIsConnected(connectionState)) { - return name; + // Ethernet networks always have the display name 'Ethernet' so we use the + // state text 'Connected' to avoid repeating the label in the sublabel. + // See http://crbug.com/989907 for details. + return networkState.type == mojom.NetworkType.kEthernet ? + CrOncStrings.networkListItemConnected : + name; } if (connectionState == mojom.ConnectionStateType.kConnecting) { return name ? @@ -282,14 +287,22 @@ Polymer({ const type = deviceState.type; if (type == mojom.NetworkType.kTether || (type == mojom.NetworkType.kCellular && this.tetherDeviceState)) { - // The "Mobile data" subpage should always be shown if Tether networks are + // The "Mobile data" subpage should always be shown if Tether is // available, even if there are currently no associated networks. return true; } - const minlen = - (type == mojom.NetworkType.kWiFi || type == mojom.NetworkType.kVPN) ? - 1 : - 2; + let minlen; + if (type == mojom.NetworkType.kVPN) { + // VPN subpage provides provider info so show if there are any networks. + minlen = 1; + } else if (type == mojom.NetworkType.kWiFi) { + // WiFi subpage includes 'Known Networks' so always show, even if the + // technology is still enabling / scanning, or none are visible. + minlen = 0; + } else { + // By default, only show the subpage if there are 2+ networks + minlen = 2; + } return networkStateList.length >= minlen; }, diff --git a/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js b/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js index 5a7c6beff6f..cce1a1de45c 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js +++ b/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js @@ -79,27 +79,20 @@ Polymer({ * @private */ getBatteryPercentageAsString_: function(managedProperties) { - const percentage = this.get('tether.batteryPercentage', managedProperties); - if (percentage === undefined) { - return ''; - } - return percentage.toString(); + return managedProperties.typeProperties.tether.batteryPercentage.toString(); }, /** * Retrieves an image that corresponds to signal strength of the tether host. * Custom icons are used here instead of a <cr-network-icon> because this * dialog uses a special color scheme. - * * @param {!mojom.ManagedProperties} managedProperties * @return {string} The name of the icon to be used to represent the network's - * signal strength. + * signal strength. */ getSignalStrengthIconName_: function(managedProperties) { - let signalStrength = this.get('tether.signalStrength', managedProperties); - if (signalStrength === undefined) { - signalStrength = 4; - } + const signalStrength = + managedProperties.typeProperties.tether.signalStrength; return 'os-settings:signal-cellular-' + Math.min(4, Math.max(signalStrength, 0)) + '-bar'; }, |