Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_summary.js

Issue 2913323003: Settings: Network: Merge Tether networks into Mobile subpage (Closed)
Patch Set: Fix browser_tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
313 continue; // The technology for this device type is unavailable.
314
315 // If both 'Tether' and 'Cellular' technoligies exist, merge the network
316 // lists and do not add an active network for 'Tether' so that there is
317 // only one 'Mobile data' section / subpage.
318 if (type == CrOnc.Type.TETHER && newDeviceStates[CrOnc.Type.CELLULAR]) {
319 newNetworkStateLists[CrOnc.Type.CELLULAR] =
320 newNetworkStateLists[CrOnc.Type.CELLULAR].concat(
321 newNetworkStateLists[CrOnc.Type.TETHER]);
313 continue; 322 continue;
314 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; 323 }
324
325 // Note: The active state for 'Cellular' may be a Tether network if both
326 // types are enabled but no Cellular network exists (edge case).
327 var state = this.getActiveStateForType_(activeNetworkStatesByType, type);
315 if (state.Source === undefined && 328 if (state.Source === undefined &&
316 device.State == CrOnc.DeviceState.PROHIBITED) { 329 device.State == CrOnc.DeviceState.PROHIBITED) {
317 // Prohibited technologies are enforced by the device policy. 330 // Prohibited technologies are enforced by the device policy.
318 state.Source = CrOnc.Source.DEVICE_POLICY; 331 state.Source = CrOnc.Source.DEVICE_POLICY;
319 } 332 }
320 newActiveNetworkStates.push(state); 333 newActiveNetworkStates.push(state);
321 this.activeNetworkIds_.add(state.GUID); 334 this.activeNetworkIds_.add(state.GUID);
322 } 335 }
323 336
324 this.deviceStates = newDeviceStates; 337 this.deviceStates = newDeviceStates;
325 this.networkStateLists_ = newNetworkStateLists; 338 this.networkStateLists_ = newNetworkStateLists;
326 // Set activeNetworkStates last to rebuild the dom-repeat. 339 // Set activeNetworkStates last to rebuild the dom-repeat.
327 this.activeNetworkStates_ = newActiveNetworkStates; 340 this.activeNetworkStates_ = newActiveNetworkStates;
328 }, 341 },
342
343 /**
344 * Returns the active network state for |type| or a default network state.
345 * If there is no 'Cellular' network, return the active 'Tether' network if
346 * any since the two types are represented by the same section / subpage.
347 * @param {!Map<string, !CrOnc.NetworkStateProperties>} activeStatesByType
348 * @param {string} type
349 * @return {!CrOnc.NetworkStateProperties|undefined}
350 */
351 getActiveStateForType_: function(activeStatesByType, type) {
352 var activeState = activeStatesByType.get(type);
353 if (!activeState && type == CrOnc.Type.CELLULAR)
354 activeState = activeStatesByType.get(CrOnc.Type.TETHER);
355 return activeState || {GUID: '', Type: type};
356 },
329 }); 357 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698