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 a summary of network states | 6 * @fileoverview Polymer element for displaying a summary of network states |
7 * by type: Ethernet, WiFi, Cellular, WiMAX, and VPN. | 7 * by type: Ethernet, WiFi, Cellular, WiMAX, and VPN. |
8 */ | 8 */ |
9 | 9 |
10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ | 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 var firstConnectedNetwork = null; | 295 var firstConnectedNetwork = null; |
296 networkStates.forEach(function(networkState) { | 296 networkStates.forEach(function(networkState) { |
297 var type = networkState.Type; | 297 var type = networkState.Type; |
298 if (!activeNetworkStatesByType.has(type)) { | 298 if (!activeNetworkStatesByType.has(type)) { |
299 activeNetworkStatesByType.set(type, networkState); | 299 activeNetworkStatesByType.set(type, networkState); |
300 if (!firstConnectedNetwork && networkState.Type != CrOnc.Type.VPN && | 300 if (!firstConnectedNetwork && networkState.Type != CrOnc.Type.VPN && |
301 networkState.ConnectionState == CrOnc.ConnectionState.CONNECTED) { | 301 networkState.ConnectionState == CrOnc.ConnectionState.CONNECTED) { |
302 firstConnectedNetwork = networkState; | 302 firstConnectedNetwork = networkState; |
303 } | 303 } |
304 } | 304 } |
305 newNetworkStateLists[type].push(networkState); | 305 if (newNetworkStateLists.hasOwnProperty(type)) { |
| 306 newNetworkStateLists[type].push(networkState); |
| 307 } |
306 }, this); | 308 }, this); |
307 | 309 |
308 this.defaultNetwork = firstConnectedNetwork; | 310 this.defaultNetwork = firstConnectedNetwork; |
309 | 311 |
310 // Create a VPN entry in deviceStates if there are any VPN networks. | 312 // Create a VPN entry in deviceStates if there are any VPN networks. |
311 if (newNetworkStateLists.VPN && newNetworkStateLists.VPN.length > 0) { | 313 if (newNetworkStateLists.VPN && newNetworkStateLists.VPN.length > 0) { |
312 newDeviceStates.VPN = /** @type {DeviceStateProperties} */ ({ | 314 newDeviceStates.VPN = /** @type {DeviceStateProperties} */ ({ |
313 Type: CrOnc.Type.VPN, | 315 Type: CrOnc.Type.VPN, |
314 State: chrome.networkingPrivate.DeviceStateType.ENABLED | 316 State: chrome.networkingPrivate.DeviceStateType.ENABLED |
315 }); | 317 }); |
(...skipping 21 matching lines...) Expand all Loading... |
337 newActiveNetworkStates.push(state); | 339 newActiveNetworkStates.push(state); |
338 this.activeNetworkIds_.add(state.GUID); | 340 this.activeNetworkIds_.add(state.GUID); |
339 } | 341 } |
340 | 342 |
341 this.deviceStates = newDeviceStates; | 343 this.deviceStates = newDeviceStates; |
342 this.networkStateLists_ = newNetworkStateLists; | 344 this.networkStateLists_ = newNetworkStateLists; |
343 // Set activeNetworkStates last to rebuild the dom-repeat. | 345 // Set activeNetworkStates last to rebuild the dom-repeat. |
344 this.activeNetworkStates_ = newActiveNetworkStates; | 346 this.activeNetworkStates_ = newActiveNetworkStates; |
345 }, | 347 }, |
346 }); | 348 }); |
OLD | NEW |