Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_summary_item.js

Issue 2707033006: MD Settings: Internet: Use custom a11y labels for network toggle buttons (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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],
hcarmona 2017/02/23 00:52:21 Another possibility is to use $i18nPolymer{...} in
stevenjb 2017/02/23 20:51:33 There are currently 3 and eventually 4 strings (wh
hcarmona 2017/02/23 21:51:06 Sounds good, no objections
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,
hcarmona 2017/02/23 00:52:21 itemName can also be removed from cr-network-list-
stevenjb 2017/02/23 20:51:33 I saw that but decided that leaving itemName as a
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
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 * @return {string}
239 * @private
240 */
241 getToggleA11yString_: function() {
242 switch (this.deviceState.Type) {
243 case CrOnc.Type.CELLULAR:
244 return this.i18n('internetToggleMobileA11yLabel');
245 case CrOnc.Type.WI_FI:
246 return this.i18n('internetToggleWiFiA11yLabel');
247 case CrOnc.Type.WI_MAX:
248 return this.i18n('internetToggleWiMAXA11yLabel');
249 }
250 return '';
hcarmona 2017/02/23 00:52:21 Does it make sense to return "Unknown device enabl
stevenjb 2017/02/23 20:51:33 I'd rather not added a string we don't plan to use
hcarmona 2017/02/23 21:51:06 Awesome, thanks :-)
251 },
252
253 /**
241 * @return {boolean} Whether or not to show the UI to expand the list. 254 * @return {boolean} Whether or not to show the UI to expand the list.
242 * @private 255 * @private
243 */ 256 */
244 expandIsVisible_: function() { 257 expandIsVisible_: function() {
245 if (!this.deviceIsEnabled_(this.deviceState)) 258 if (!this.deviceIsEnabled_(this.deviceState))
246 return false; 259 return false;
247 var type = this.deviceState.Type; 260 var type = this.deviceState.Type;
248 var minLength = 261 var minLength =
249 (type == CrOnc.Type.WI_FI || type == CrOnc.Type.VPN) ? 1 : 2; 262 (type == CrOnc.Type.WI_FI || type == CrOnc.Type.VPN) ? 1 : 2;
250 return this.networkStateList.length >= minLength; 263 return this.networkStateList.length >= minLength;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 */ 328 */
316 onDeviceEnabledTap_: function(event) { 329 onDeviceEnabledTap_: function(event) {
317 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); 330 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState);
318 var type = this.deviceState ? this.deviceState.Type : ''; 331 var type = this.deviceState ? this.deviceState.Type : '';
319 this.fire( 332 this.fire(
320 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); 333 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type});
321 // Make sure this does not propagate to onDetailsTap_. 334 // Make sure this does not propagate to onDetailsTap_.
322 event.stopPropagation(); 335 event.stopPropagation();
323 }, 336 },
324 }); 337 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698