| 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: [I18nBehavior], | 16 behaviors: [CrPolicyNetworkBehavior, 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: Object, | 23 deviceState: Object, |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Network state for the active network. | 26 * Network state for the active network. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Interface for networkingPrivate calls, passed from internet_page. | 43 * Interface for networkingPrivate calls, passed from internet_page. |
| 44 * @type {!NetworkingPrivate} | 44 * @type {!NetworkingPrivate} |
| 45 */ | 45 */ |
| 46 networkingPrivate: Object, | 46 networkingPrivate: Object, |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @return {string} |
| 51 * @private |
| 52 */ |
| 53 getNetworkName_: function() { |
| 54 return CrOncStrings['OncType' + this.activeNetworkState.Type]; |
| 55 }, |
| 56 |
| 57 /** |
| 58 * @return {string} |
| 59 * @private |
| 60 */ |
| 61 getNetworkStateText_: function() { |
| 62 var network = this.activeNetworkState; |
| 63 var state = network.ConnectionState; |
| 64 var name = CrOnc.getNetworkName(network); |
| 65 if (state) |
| 66 return this.getConnectionStateText_(state, name); |
| 67 if (this.deviceIsEnabled_(this.deviceState)) |
| 68 return CrOncStrings.networkListItemNotConnected; |
| 69 return this.i18n('deviceOff'); |
| 70 }, |
| 71 |
| 72 /** |
| 73 * @param {CrOnc.ConnectionState} state |
| 74 * @param {string} name |
| 75 * @return {string} |
| 76 * @private |
| 77 */ |
| 78 getConnectionStateText_: function(state, name) { |
| 79 switch (state) { |
| 80 case CrOnc.ConnectionState.CONNECTED: |
| 81 return name; |
| 82 case CrOnc.ConnectionState.CONNECTING: |
| 83 if (name) |
| 84 return CrOncStrings.networkListItemConnectingTo.replace('$1', name); |
| 85 return CrOncStrings.networkListItemConnecting; |
| 86 case CrOnc.ConnectionState.NOT_CONNECTED: |
| 87 return CrOncStrings.networkListItemNotConnected; |
| 88 } |
| 89 assertNotReached(); |
| 90 return state; |
| 91 }, |
| 92 |
| 93 /** |
| 94 * @return {boolean} |
| 95 * @private |
| 96 */ |
| 97 showPolicyIndicator_: function() { |
| 98 var network = this.activeNetworkState; |
| 99 return network.ConnectionState == CrOnc.ConnectionState.CONNECTED || |
| 100 this.isPolicySource(network.Source); |
| 101 }, |
| 102 |
| 103 /** |
| 50 * Show the <network-siminfo> element if this is a disabled and locked | 104 * Show the <network-siminfo> element if this is a disabled and locked |
| 51 * cellular device. | 105 * cellular device. |
| 52 * @return {boolean} | 106 * @return {boolean} |
| 53 * @private | 107 * @private |
| 54 */ | 108 */ |
| 55 showSimInfo_: function() { | 109 showSimInfo_: function() { |
| 56 var device = this.deviceState; | 110 var device = this.deviceState; |
| 57 if (device.Type != CrOnc.Type.CELLULAR || | 111 if (device.Type != CrOnc.Type.CELLULAR || |
| 58 this.deviceIsEnabled_(this.deviceState)) { | 112 this.deviceIsEnabled_(this.deviceState)) { |
| 59 return false; | 113 return false; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 */ | 249 */ |
| 196 onDeviceEnabledTap_: function(event) { | 250 onDeviceEnabledTap_: function(event) { |
| 197 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); | 251 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); |
| 198 var type = this.deviceState ? this.deviceState.Type : ''; | 252 var type = this.deviceState ? this.deviceState.Type : ''; |
| 199 this.fire( | 253 this.fire( |
| 200 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); | 254 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); |
| 201 // Make sure this does not propagate to onDetailsTap_. | 255 // Make sure this does not propagate to onDetailsTap_. |
| 202 event.stopPropagation(); | 256 event.stopPropagation(); |
| 203 }, | 257 }, |
| 204 }); | 258 }); |
| OLD | NEW |