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} */ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 /** | 57 /** |
58 * @return {string} | 58 * @return {string} |
59 * @private | 59 * @private |
60 */ | 60 */ |
61 getNetworkStateText_: function() { | 61 getNetworkStateText_: function() { |
62 var network = this.activeNetworkState; | 62 var network = this.activeNetworkState; |
63 var state = network.ConnectionState; | 63 var state = network.ConnectionState; |
64 var name = CrOnc.getNetworkName(network); | 64 var name = CrOnc.getNetworkName(network); |
65 if (state) | 65 if (state) |
66 return this.getConnectionStateText_(state, name); | 66 return this.getConnectionStateText_(state, name); |
67 if (this.deviceIsEnabled_(this.deviceState)) | 67 var deviceState = this.deviceState; |
68 return CrOncStrings.networkListItemNotConnected; | 68 if (deviceState) { |
| 69 if (deviceState.State == |
| 70 chrome.networkingPrivate.DeviceStateType.ENABLING) { |
| 71 return this.i18n('internetDeviceEnabling'); |
| 72 } |
| 73 if (deviceState.Type == CrOnc.Type.CELLULAR && |
| 74 this.deviceState.Scanning) { |
| 75 return this.i18n('internetMobileSearching'); |
| 76 } |
| 77 if (deviceState.State == chrome.networkingPrivate.DeviceStateType.ENABLED) |
| 78 return CrOncStrings.networkListItemNotConnected; |
| 79 } |
69 return this.i18n('deviceOff'); | 80 return this.i18n('deviceOff'); |
70 }, | 81 }, |
71 | 82 |
72 /** | 83 /** |
73 * @param {CrOnc.ConnectionState} state | 84 * @param {CrOnc.ConnectionState} state |
74 * @param {string} name | 85 * @param {string} name |
75 * @return {string} | 86 * @return {string} |
76 * @private | 87 * @private |
77 */ | 88 */ |
78 getConnectionStateText_: function(state, name) { | 89 getConnectionStateText_: function(state, name) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 197 } |
187 assertNotReached(); | 198 assertNotReached(); |
188 return ''; | 199 return ''; |
189 }, | 200 }, |
190 | 201 |
191 /** | 202 /** |
192 * @return {boolean} | 203 * @return {boolean} |
193 * @private | 204 * @private |
194 */ | 205 */ |
195 showDetailsIsVisible_: function() { | 206 showDetailsIsVisible_: function() { |
196 return this.deviceIsEnabled_(this.deviceState); | 207 return this.deviceIsEnabled_(this.deviceState) && |
| 208 (!!this.activeNetworkState.GUID || this.networkStateList.length > 0); |
197 }, | 209 }, |
198 | 210 |
199 /** | 211 /** |
200 * @return {boolean} | 212 * @return {boolean} |
201 * @private | 213 * @private |
202 */ | 214 */ |
203 shouldShowList_: function() { | 215 shouldShowList_: function() { |
204 var minlen = (this.deviceState.Type == CrOnc.Type.WI_FI || | 216 var minlen = (this.deviceState.Type == CrOnc.Type.WI_FI || |
205 this.deviceState.Type == CrOnc.Type.VPN) ? | 217 this.deviceState.Type == CrOnc.Type.VPN) ? |
206 1 : | 218 1 : |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 */ | 261 */ |
250 onDeviceEnabledTap_: function(event) { | 262 onDeviceEnabledTap_: function(event) { |
251 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); | 263 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); |
252 var type = this.deviceState ? this.deviceState.Type : ''; | 264 var type = this.deviceState ? this.deviceState.Type : ''; |
253 this.fire( | 265 this.fire( |
254 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); | 266 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); |
255 // Make sure this does not propagate to onDetailsTap_. | 267 // Make sure this does not propagate to onDetailsTap_. |
256 event.stopPropagation(); | 268 event.stopPropagation(); |
257 }, | 269 }, |
258 }); | 270 }); |
OLD | NEW |