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

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

Issue 2838323002: [CrOS Tether] Add tether settings section to the MD settings page. (Closed)
Patch Set: Fix Closure compiler error. Created 3 years, 7 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 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 newDeviceStates = Object.assign({}, this.deviceStates); 279 newDeviceStates = Object.assign({}, this.deviceStates);
280 } 280 }
281 281
282 // Clear any current networks. 282 // Clear any current networks.
283 var activeNetworkStatesByType = 283 var activeNetworkStatesByType =
284 /** @type {!Map<string, !CrOnc.NetworkStateProperties>} */ (new Map); 284 /** @type {!Map<string, !CrOnc.NetworkStateProperties>} */ (new Map);
285 285
286 // Complete list of states by type. 286 // Complete list of states by type.
287 /** @type {!NetworkStateListObject} */ var newNetworkStateLists = { 287 /** @type {!NetworkStateListObject} */ var newNetworkStateLists = {
288 Ethernet: [], 288 Ethernet: [],
289 Tether: [],
289 WiFi: [], 290 WiFi: [],
290 Cellular: [], 291 Cellular: [],
291 WiMAX: [], 292 WiMAX: [],
292 VPN: [], 293 VPN: [],
293 }; 294 };
294 295
295 var firstConnectedNetwork = null; 296 var firstConnectedNetwork = null;
296 networkStates.forEach(function(networkState) { 297 networkStates.forEach(function(networkState) {
297 var type = networkState.Type; 298 var type = networkState.Type;
298 if (!activeNetworkStatesByType.has(type)) { 299 if (!activeNetworkStatesByType.has(type)) {
299 activeNetworkStatesByType.set(type, networkState); 300 activeNetworkStatesByType.set(type, networkState);
300 if (!firstConnectedNetwork && networkState.Type != CrOnc.Type.VPN && 301 if (!firstConnectedNetwork && networkState.Type != CrOnc.Type.VPN &&
301 networkState.ConnectionState == CrOnc.ConnectionState.CONNECTED) { 302 networkState.ConnectionState == CrOnc.ConnectionState.CONNECTED) {
302 firstConnectedNetwork = networkState; 303 firstConnectedNetwork = networkState;
303 } 304 }
304 } 305 }
305 if (newNetworkStateLists.hasOwnProperty(type)) { 306 newNetworkStateLists[type].push(networkState);
306 newNetworkStateLists[type].push(networkState);
307 }
308 }, this); 307 }, this);
309 308
310 this.defaultNetwork = firstConnectedNetwork; 309 this.defaultNetwork = firstConnectedNetwork;
311 310
312 // Create a VPN entry in deviceStates if there are any VPN networks. 311 // Create a VPN entry in deviceStates if there are any VPN networks.
313 if (newNetworkStateLists.VPN && newNetworkStateLists.VPN.length > 0) { 312 if (newNetworkStateLists.VPN && newNetworkStateLists.VPN.length > 0) {
314 newDeviceStates.VPN = /** @type {DeviceStateProperties} */ ({ 313 newDeviceStates.VPN = /** @type {DeviceStateProperties} */ ({
315 Type: CrOnc.Type.VPN, 314 Type: CrOnc.Type.VPN,
316 State: chrome.networkingPrivate.DeviceStateType.ENABLED 315 State: chrome.networkingPrivate.DeviceStateType.ENABLED
317 }); 316 });
318 } 317 }
319 318
320 // Push the active networks onto newActiveNetworkStates in order based on 319 // Push the active networks onto newActiveNetworkStates in order based on
321 // device priority, creating an empty state for devices with no networks. 320 // device priority, creating an empty state for devices with no networks.
322 var newActiveNetworkStates = []; 321 var newActiveNetworkStates = [];
323 this.activeNetworkIds_ = new Set; 322 this.activeNetworkIds_ = new Set;
324 var orderedDeviceTypes = [ 323 var orderedDeviceTypes = [
325 CrOnc.Type.ETHERNET, CrOnc.Type.WI_FI, CrOnc.Type.CELLULAR, 324 CrOnc.Type.ETHERNET, CrOnc.Type.WI_FI, CrOnc.Type.CELLULAR,
326 CrOnc.Type.WI_MAX, CrOnc.Type.VPN 325 CrOnc.Type.TETHER, CrOnc.Type.WI_MAX, CrOnc.Type.VPN
327 ]; 326 ];
328 for (var i = 0; i < orderedDeviceTypes.length; ++i) { 327 for (var i = 0; i < orderedDeviceTypes.length; ++i) {
329 var type = orderedDeviceTypes[i]; 328 var type = orderedDeviceTypes[i];
330 var device = newDeviceStates[type]; 329 var device = newDeviceStates[type];
331 if (!device) 330 if (!device)
332 continue; 331 continue;
333 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; 332 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type};
334 if (state.Source === undefined && 333 if (state.Source === undefined &&
335 device.State == chrome.networkingPrivate.DeviceStateType.PROHIBITED) { 334 device.State == chrome.networkingPrivate.DeviceStateType.PROHIBITED) {
336 // Prohibited technologies are enforced by the device policy. 335 // Prohibited technologies are enforced by the device policy.
337 state.Source = CrOnc.Source.DEVICE_POLICY; 336 state.Source = CrOnc.Source.DEVICE_POLICY;
338 } 337 }
339 newActiveNetworkStates.push(state); 338 newActiveNetworkStates.push(state);
340 this.activeNetworkIds_.add(state.GUID); 339 this.activeNetworkIds_.add(state.GUID);
341 } 340 }
342 341
343 this.deviceStates = newDeviceStates; 342 this.deviceStates = newDeviceStates;
344 this.networkStateLists_ = newNetworkStateLists; 343 this.networkStateLists_ = newNetworkStateLists;
345 // Set activeNetworkStates last to rebuild the dom-repeat. 344 // Set activeNetworkStates last to rebuild the dom-repeat.
346 this.activeNetworkStates_ = newActiveNetworkStates; 345 this.activeNetworkStates_ = newActiveNetworkStates;
347 }, 346 },
348 }); 347 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698