| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 value: null, | 45 value: null, |
| 46 notify: true, | 46 notify: true, |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The device state for each network device type. | 50 * The device state for each network device type. |
| 51 * @type {DeviceStateObject} | 51 * @type {DeviceStateObject} |
| 52 */ | 52 */ |
| 53 deviceStates: { | 53 deviceStates: { |
| 54 type: Object, | 54 type: Object, |
| 55 value: function() { return {}; }, | 55 value: function() { |
| 56 return {}; |
| 57 }, |
| 56 }, | 58 }, |
| 57 | 59 |
| 58 /** | 60 /** |
| 59 * Array of active network states, one per device type. | 61 * Array of active network states, one per device type. |
| 60 * @type {!Array<!CrOnc.NetworkStateProperties>} | 62 * @type {!Array<!CrOnc.NetworkStateProperties>} |
| 61 */ | 63 */ |
| 62 activeNetworkStates: { | 64 activeNetworkStates: { |
| 63 type: Array, | 65 type: Array, |
| 64 value: function() { return []; }, | 66 value: function() { |
| 67 return []; |
| 68 }, |
| 65 }, | 69 }, |
| 66 | 70 |
| 67 /** | 71 /** |
| 68 * List of network state data for each network type. | 72 * List of network state data for each network type. |
| 69 * @type {NetworkStateListObject} | 73 * @type {NetworkStateListObject} |
| 70 */ | 74 */ |
| 71 networkStateLists: { | 75 networkStateLists: { |
| 72 type: Object, | 76 type: Object, |
| 73 value: function() { return {}; }, | 77 value: function() { |
| 78 return {}; |
| 79 }, |
| 74 }, | 80 }, |
| 75 | 81 |
| 76 /** | 82 /** |
| 77 * Interface for networkingPrivate calls, passed from internet_page. | 83 * Interface for networkingPrivate calls, passed from internet_page. |
| 78 * @type {NetworkingPrivate} | 84 * @type {NetworkingPrivate} |
| 79 */ | 85 */ |
| 80 networkingPrivate: { | 86 networkingPrivate: { |
| 81 type: Object, | 87 type: Object, |
| 82 }, | 88 }, |
| 83 }, | 89 }, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (event.detail.enabled) | 187 if (event.detail.enabled) |
| 182 this.networkingPrivate.enableNetworkType(event.detail.type); | 188 this.networkingPrivate.enableNetworkType(event.detail.type); |
| 183 else | 189 else |
| 184 this.networkingPrivate.disableNetworkType(event.detail.type); | 190 this.networkingPrivate.disableNetworkType(event.detail.type); |
| 185 }, | 191 }, |
| 186 | 192 |
| 187 /** | 193 /** |
| 188 * networkingPrivate.onNetworkListChanged event callback. | 194 * networkingPrivate.onNetworkListChanged event callback. |
| 189 * @private | 195 * @private |
| 190 */ | 196 */ |
| 191 onNetworkListChangedEvent_: function() { this.getNetworkLists_(); }, | 197 onNetworkListChangedEvent_: function() { |
| 198 this.getNetworkLists_(); |
| 199 }, |
| 192 | 200 |
| 193 /** | 201 /** |
| 194 * networkingPrivate.onDeviceStateListChanged event callback. | 202 * networkingPrivate.onDeviceStateListChanged event callback. |
| 195 * @private | 203 * @private |
| 196 */ | 204 */ |
| 197 onDeviceStateListChangedEvent_: function() { this.getNetworkLists_(); }, | 205 onDeviceStateListChangedEvent_: function() { |
| 206 this.getNetworkLists_(); |
| 207 }, |
| 198 | 208 |
| 199 /** | 209 /** |
| 200 * networkingPrivate.onNetworksChanged event callback. | 210 * networkingPrivate.onNetworksChanged event callback. |
| 201 * @param {!Array<string>} networkIds The list of changed network GUIDs. | 211 * @param {!Array<string>} networkIds The list of changed network GUIDs. |
| 202 * @private | 212 * @private |
| 203 */ | 213 */ |
| 204 onNetworksChangedEvent_: function(networkIds) { | 214 onNetworksChangedEvent_: function(networkIds) { |
| 205 if (!this.activeNetworkIds_) | 215 if (!this.activeNetworkIds_) |
| 206 return; // Initial list of networks not received yet. | 216 return; // Initial list of networks not received yet. |
| 207 networkIds.forEach(function(id) { | 217 networkIds.forEach(function(id) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 this.defaultNetwork = firstConnectedNetwork; | 369 this.defaultNetwork = firstConnectedNetwork; |
| 360 | 370 |
| 361 // Create a VPN entry in deviceStates if there are any VPN networks. | 371 // Create a VPN entry in deviceStates if there are any VPN networks. |
| 362 if (newNetworkStateLists.VPN && newNetworkStateLists.VPN.length > 0) { | 372 if (newNetworkStateLists.VPN && newNetworkStateLists.VPN.length > 0) { |
| 363 newDeviceStates.VPN = /** @type {DeviceStateProperties} */ ({ | 373 newDeviceStates.VPN = /** @type {DeviceStateProperties} */ ({ |
| 364 Type: CrOnc.Type.VPN, | 374 Type: CrOnc.Type.VPN, |
| 365 State: chrome.networkingPrivate.DeviceStateType.ENABLED | 375 State: chrome.networkingPrivate.DeviceStateType.ENABLED |
| 366 }); | 376 }); |
| 367 } | 377 } |
| 368 | 378 |
| 369 // Push the active networks onto newActiveNetworkStates in device order, | 379 // Push the active networks onto newActiveNetworkStates in order based on |
| 370 // creating an empty state for devices with no networks. | 380 // device priority, creating an empty state for devices with no networks. |
| 371 var newActiveNetworkStates = []; | 381 let newActiveNetworkStates = []; |
| 372 this.activeNetworkIds_ = new Set; | 382 this.activeNetworkIds_ = new Set; |
| 373 for (let type in newDeviceStates) { | 383 let orderedDeviceTypes = [ |
| 374 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; | 384 CrOnc.Type.ETHERNET, CrOnc.Type.WI_FI, CrOnc.Type.CELLULAR, |
| 385 CrOnc.Type.WI_MAX, CrOnc.Type.VPN |
| 386 ]; |
| 387 for (let type of orderedDeviceTypes) { |
| 388 let device = newDeviceStates[type]; |
| 389 if (!device) |
| 390 continue; |
| 391 let state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; |
| 375 newActiveNetworkStates.push(state); | 392 newActiveNetworkStates.push(state); |
| 376 this.activeNetworkIds_.add(state.GUID); | 393 this.activeNetworkIds_.add(state.GUID); |
| 377 } | 394 } |
| 378 | 395 |
| 379 this.deviceStates = newDeviceStates; | 396 this.deviceStates = newDeviceStates; |
| 380 this.networkStateLists = newNetworkStateLists; | 397 this.networkStateLists = newNetworkStateLists; |
| 381 // Set activeNetworkStates last to rebuild the dom-repeat. | 398 // Set activeNetworkStates last to rebuild the dom-repeat. |
| 382 this.activeNetworkStates = newActiveNetworkStates; | 399 this.activeNetworkStates = newActiveNetworkStates; |
| 383 }, | 400 }, |
| 384 }); | 401 }); |
| OLD | NEW |