Chromium Code Reviews| 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 /** | 10 /** |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 // device priority, creating an empty state for devices with no networks. | 302 // device priority, creating an empty state for devices with no networks. |
| 303 var newActiveNetworkStates = []; | 303 var newActiveNetworkStates = []; |
| 304 this.activeNetworkIds_ = new Set; | 304 this.activeNetworkIds_ = new Set; |
| 305 var orderedDeviceTypes = [ | 305 var orderedDeviceTypes = [ |
| 306 CrOnc.Type.ETHERNET, CrOnc.Type.WI_FI, CrOnc.Type.CELLULAR, | 306 CrOnc.Type.ETHERNET, CrOnc.Type.WI_FI, CrOnc.Type.CELLULAR, |
| 307 CrOnc.Type.TETHER, CrOnc.Type.WI_MAX, CrOnc.Type.VPN | 307 CrOnc.Type.TETHER, CrOnc.Type.WI_MAX, CrOnc.Type.VPN |
| 308 ]; | 308 ]; |
| 309 for (var i = 0; i < orderedDeviceTypes.length; ++i) { | 309 for (var i = 0; i < orderedDeviceTypes.length; ++i) { |
| 310 var type = orderedDeviceTypes[i]; | 310 var type = orderedDeviceTypes[i]; |
| 311 var device = newDeviceStates[type]; | 311 var device = newDeviceStates[type]; |
| 312 if (!device) | 312 if (!device) |
|
Kyle Horimoto
2017/06/01 20:15:21
Is this if() necessary? It seems like we should al
stevenjb
2017/06/01 21:55:03
Incorrect. We have no "unavailable" device.State,
| |
| 313 continue; | 313 continue; |
| 314 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; | 314 // If both 'Tether' and 'Cellular' technoligies exist, merge the network |
| 315 // lists and do not add an active network for 'Tether' so that there is | |
| 316 // only one 'Mobile data' section / subpage. | |
| 317 if (type == CrOnc.Type.TETHER && newDeviceStates[CrOnc.Type.CELLULAR]) { | |
| 318 newNetworkStateLists[CrOnc.Type.CELLULAR] = | |
| 319 newNetworkStateLists[CrOnc.Type.CELLULAR].concat( | |
| 320 newNetworkStateLists[CrOnc.Type.TETHER]); | |
| 321 continue; | |
| 322 } | |
| 323 | |
| 324 // Note: The active state for 'Cellular' may be a Tether network if both | |
| 325 // types are enabled but no Cellular network exists (edge case). | |
| 326 var state = this.getActiveStateForType_(activeNetworkStatesByType, type); | |
| 315 if (state.Source === undefined && | 327 if (state.Source === undefined && |
| 316 device.State == CrOnc.DeviceState.PROHIBITED) { | 328 device.State == CrOnc.DeviceState.PROHIBITED) { |
| 317 // Prohibited technologies are enforced by the device policy. | 329 // Prohibited technologies are enforced by the device policy. |
| 318 state.Source = CrOnc.Source.DEVICE_POLICY; | 330 state.Source = CrOnc.Source.DEVICE_POLICY; |
| 319 } | 331 } |
| 320 newActiveNetworkStates.push(state); | 332 newActiveNetworkStates.push(state); |
| 321 this.activeNetworkIds_.add(state.GUID); | 333 this.activeNetworkIds_.add(state.GUID); |
| 322 } | 334 } |
| 323 | 335 |
| 324 this.deviceStates = newDeviceStates; | 336 this.deviceStates = newDeviceStates; |
| 325 this.networkStateLists_ = newNetworkStateLists; | 337 this.networkStateLists_ = newNetworkStateLists; |
| 326 // Set activeNetworkStates last to rebuild the dom-repeat. | 338 // Set activeNetworkStates last to rebuild the dom-repeat. |
| 327 this.activeNetworkStates_ = newActiveNetworkStates; | 339 this.activeNetworkStates_ = newActiveNetworkStates; |
| 328 }, | 340 }, |
| 341 | |
| 342 /** | |
| 343 * Returns the active network state for |type| or a default network state. | |
| 344 * If there is no 'Celular' network, return the active 'Tether' network if | |
|
Kyle Horimoto
2017/06/01 20:15:21
Cellular
stevenjb
2017/06/01 21:55:03
Done.
| |
| 345 * any since the two types are represented by the same section / subpage. | |
| 346 * @param {!Map<string, !CrOnc.NetworkStateProperties>} activeStatesByType | |
| 347 * @param {string} type | |
| 348 * @return {!CrOnc.NetworkStateProperties|undefined} | |
| 349 */ | |
| 350 getActiveStateForType_: function(activeStatesByType, type) { | |
| 351 var activeState = activeStatesByType.get(type); | |
| 352 if (!activeState && type == CrOnc.Type.CELLULAR) | |
| 353 activeState = activeStatesByType.get(CrOnc.Type.TETHER); | |
| 354 return activeState || {GUID: '', Type: type}; | |
| 355 }, | |
| 329 }); | 356 }); |
| OLD | NEW |