| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Polymer element for displaying the network state for a specific | 6 * @fileoverview Polymer element for displaying the network state for a specific |
| 7 * type and a list of networks for that type. | 7 * type and a list of networks for that type. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ | 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ |
| 11 var DeviceStateProperties; | 11 var DeviceStateProperties; |
| 12 | 12 |
| 13 Polymer({ | 13 Polymer({ |
| 14 is: 'network-summary-item', | 14 is: 'network-summary-item', |
| 15 | 15 |
| 16 behaviors: [Polymer.IronA11yKeysBehavior], | 16 behaviors: [Polymer.IronA11yKeysBehavior, I18nBehavior], |
| 17 | 17 |
| 18 properties: { | 18 properties: { |
| 19 /** | 19 /** |
| 20 * Device state for the network type. | 20 * Device state for the network type. |
| 21 * @type {!DeviceStateProperties|undefined} | 21 * @type {!DeviceStateProperties|undefined} |
| 22 */ | 22 */ |
| 23 deviceState: { | 23 deviceState: { |
| 24 type: Object, | 24 type: Object, |
| 25 observer: 'deviceStateChanged_', | 25 observer: 'deviceStateChanged_', |
| 26 }, | 26 }, |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Network state for the active network. | 29 * Network state for the active network. |
| 30 * @type {!CrOnc.NetworkStateProperties|undefined} | 30 * @type {!CrOnc.NetworkStateProperties|undefined} |
| 31 */ | 31 */ |
| 32 activeNetworkState: Object, | 32 activeNetworkState: Object, |
| 33 | 33 |
| 34 /** String for a11y purposes. */ | |
| 35 itemName: String, | |
| 36 | |
| 37 /** | 34 /** |
| 38 * List of all network state data for the network type. | 35 * List of all network state data for the network type. |
| 39 * @type {!Array<!CrOnc.NetworkStateProperties>} | 36 * @type {!Array<!CrOnc.NetworkStateProperties>} |
| 40 */ | 37 */ |
| 41 networkStateList: { | 38 networkStateList: { |
| 42 type: Array, | 39 type: Array, |
| 43 value: function() { | 40 value: function() { |
| 44 return []; | 41 return []; |
| 45 }, | 42 }, |
| 46 }, | 43 }, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 * @param {!DeviceStateProperties} deviceState | 228 * @param {!DeviceStateProperties} deviceState |
| 232 * @return {boolean} | 229 * @return {boolean} |
| 233 * @private | 230 * @private |
| 234 */ | 231 */ |
| 235 enableToggleIsEnabled_: function(deviceState) { | 232 enableToggleIsEnabled_: function(deviceState) { |
| 236 return deviceState.State != | 233 return deviceState.State != |
| 237 chrome.networkingPrivate.DeviceStateType.PROHIBITED; | 234 chrome.networkingPrivate.DeviceStateType.PROHIBITED; |
| 238 }, | 235 }, |
| 239 | 236 |
| 240 /** | 237 /** |
| 238 * @param {!DeviceStateProperties} deviceState |
| 239 * @return {string} |
| 240 * @private |
| 241 */ |
| 242 getToggleA11yString_: function(deviceState) { |
| 243 if (!this.enableToggleIsVisible_(deviceState)) |
| 244 return ''; |
| 245 switch (deviceState.Type) { |
| 246 case CrOnc.Type.CELLULAR: |
| 247 return this.i18n('internetToggleMobileA11yLabel'); |
| 248 case CrOnc.Type.WI_FI: |
| 249 return this.i18n('internetToggleWiFiA11yLabel'); |
| 250 case CrOnc.Type.WI_MAX: |
| 251 return this.i18n('internetToggleWiMAXA11yLabel'); |
| 252 } |
| 253 assertNotReached(); |
| 254 return ''; |
| 255 }, |
| 256 |
| 257 /** |
| 241 * @return {boolean} Whether or not to show the UI to expand the list. | 258 * @return {boolean} Whether or not to show the UI to expand the list. |
| 242 * @private | 259 * @private |
| 243 */ | 260 */ |
| 244 expandIsVisible_: function() { | 261 expandIsVisible_: function() { |
| 245 if (!this.deviceIsEnabled_(this.deviceState)) | 262 if (!this.deviceIsEnabled_(this.deviceState)) |
| 246 return false; | 263 return false; |
| 247 var type = this.deviceState.Type; | 264 var type = this.deviceState.Type; |
| 248 var minLength = | 265 var minLength = |
| 249 (type == CrOnc.Type.WI_FI || type == CrOnc.Type.VPN) ? 1 : 2; | 266 (type == CrOnc.Type.WI_FI || type == CrOnc.Type.VPN) ? 1 : 2; |
| 250 return this.networkStateList.length >= minLength; | 267 return this.networkStateList.length >= minLength; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 */ | 332 */ |
| 316 onDeviceEnabledTap_: function(event) { | 333 onDeviceEnabledTap_: function(event) { |
| 317 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); | 334 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); |
| 318 var type = this.deviceState ? this.deviceState.Type : ''; | 335 var type = this.deviceState ? this.deviceState.Type : ''; |
| 319 this.fire( | 336 this.fire( |
| 320 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); | 337 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); |
| 321 // Make sure this does not propagate to onDetailsTap_. | 338 // Make sure this does not propagate to onDetailsTap_. |
| 322 event.stopPropagation(); | 339 event.stopPropagation(); |
| 323 }, | 340 }, |
| 324 }); | 341 }); |
| OLD | NEW |