| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 /** | 54 /** |
| 55 * Interface for networkingPrivate calls, passed from internet_page. | 55 * Interface for networkingPrivate calls, passed from internet_page. |
| 56 * @type {NetworkingPrivate} | 56 * @type {NetworkingPrivate} |
| 57 */ | 57 */ |
| 58 networkingPrivate: Object, | 58 networkingPrivate: Object, |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * The device state for each network device type. | 61 * The device state for each network device type. |
| 62 * @private {DeviceStateObject} | 62 * @private {DeviceStateObject} |
| 63 */ | 63 */ |
| 64 deviceStates_: { | 64 deviceStates: { |
| 65 type: Object, | 65 type: Object, |
| 66 value: function() { | 66 value: function() { |
| 67 return {}; | 67 return {}; |
| 68 }, | 68 }, |
| 69 notify: true, |
| 69 }, | 70 }, |
| 70 | 71 |
| 71 /** | 72 /** |
| 72 * Array of active network states, one per device type. | 73 * Array of active network states, one per device type. |
| 73 * @private {!Array<!CrOnc.NetworkStateProperties>} | 74 * @private {!Array<!CrOnc.NetworkStateProperties>} |
| 74 */ | 75 */ |
| 75 activeNetworkStates_: { | 76 activeNetworkStates_: { |
| 76 type: Array, | 77 type: Array, |
| 77 value: function() { | 78 value: function() { |
| 78 return []; | 79 return []; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 onSelected_: function(event) { | 172 onSelected_: function(event) { |
| 172 var state = event.detail; | 173 var state = event.detail; |
| 173 if (this.canConnect_(state, this.globalPolicy)) { | 174 if (this.canConnect_(state, this.globalPolicy)) { |
| 174 this.connectToNetwork_(state); | 175 this.connectToNetwork_(state); |
| 175 return; | 176 return; |
| 176 } | 177 } |
| 177 this.fire('show-detail', state); | 178 this.fire('show-detail', state); |
| 178 }, | 179 }, |
| 179 | 180 |
| 180 /** | 181 /** |
| 181 * Event triggered when the enabled state of a network-summary-item is | |
| 182 * toggled. | |
| 183 * @param {!{detail: {enabled: boolean, | |
| 184 * type: chrome.networkingPrivate.NetworkType}}} event | |
| 185 * @private | |
| 186 */ | |
| 187 onDeviceEnabledToggled_: function(event) { | |
| 188 if (event.detail.enabled) | |
| 189 this.networkingPrivate.enableNetworkType(event.detail.type); | |
| 190 else | |
| 191 this.networkingPrivate.disableNetworkType(event.detail.type); | |
| 192 }, | |
| 193 | |
| 194 /** | |
| 195 * networkingPrivate.onNetworkListChanged event callback. | 182 * networkingPrivate.onNetworkListChanged event callback. |
| 196 * @private | 183 * @private |
| 197 */ | 184 */ |
| 198 onNetworkListChangedEvent_: function() { | 185 onNetworkListChangedEvent_: function() { |
| 199 this.getNetworkLists_(); | 186 this.getNetworkLists_(); |
| 200 }, | 187 }, |
| 201 | 188 |
| 202 /** | 189 /** |
| 203 * networkingPrivate.onDeviceStateListChanged event callback. | 190 * networkingPrivate.onDeviceStateListChanged event callback. |
| 204 * @private | 191 * @private |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 */ | 326 */ |
| 340 updateNetworkStates_: function(networkStates, opt_deviceStates) { | 327 updateNetworkStates_: function(networkStates, opt_deviceStates) { |
| 341 var newDeviceStates; | 328 var newDeviceStates; |
| 342 if (opt_deviceStates) { | 329 if (opt_deviceStates) { |
| 343 newDeviceStates = /** @type {!DeviceStateObject} */ ({}); | 330 newDeviceStates = /** @type {!DeviceStateObject} */ ({}); |
| 344 for (var i = 0; i < opt_deviceStates.length; ++i) { | 331 for (var i = 0; i < opt_deviceStates.length; ++i) { |
| 345 var state = opt_deviceStates[i]; | 332 var state = opt_deviceStates[i]; |
| 346 newDeviceStates[state.Type] = state; | 333 newDeviceStates[state.Type] = state; |
| 347 } | 334 } |
| 348 } else { | 335 } else { |
| 349 newDeviceStates = this.deviceStates_; | 336 newDeviceStates = this.deviceStates; |
| 350 } | 337 } |
| 351 | 338 |
| 352 // Clear any current networks. | 339 // Clear any current networks. |
| 353 var activeNetworkStatesByType = | 340 var activeNetworkStatesByType = |
| 354 /** @type {!Map<string, !CrOnc.NetworkStateProperties>} */ (new Map); | 341 /** @type {!Map<string, !CrOnc.NetworkStateProperties>} */ (new Map); |
| 355 | 342 |
| 356 // Complete list of states by type. | 343 // Complete list of states by type. |
| 357 /** @type {!NetworkStateListObject} */ var newNetworkStateLists = { | 344 /** @type {!NetworkStateListObject} */ var newNetworkStateLists = { |
| 358 Ethernet: [], | 345 Ethernet: [], |
| 359 WiFi: [], | 346 WiFi: [], |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; | 388 var state = activeNetworkStatesByType.get(type) || {GUID: '', Type: type}; |
| 402 if (state.Source === undefined && | 389 if (state.Source === undefined && |
| 403 device.State == chrome.networkingPrivate.DeviceStateType.PROHIBITED) { | 390 device.State == chrome.networkingPrivate.DeviceStateType.PROHIBITED) { |
| 404 // Prohibited technologies are enforced by the device policy. | 391 // Prohibited technologies are enforced by the device policy. |
| 405 state.Source = CrOnc.Source.DEVICE_POLICY; | 392 state.Source = CrOnc.Source.DEVICE_POLICY; |
| 406 } | 393 } |
| 407 newActiveNetworkStates.push(state); | 394 newActiveNetworkStates.push(state); |
| 408 this.activeNetworkIds_.add(state.GUID); | 395 this.activeNetworkIds_.add(state.GUID); |
| 409 } | 396 } |
| 410 | 397 |
| 411 this.deviceStates_ = newDeviceStates; | 398 this.deviceStates = newDeviceStates; |
| 412 this.networkStateLists_ = newNetworkStateLists; | 399 this.networkStateLists_ = newNetworkStateLists; |
| 413 // Set activeNetworkStates last to rebuild the dom-repeat. | 400 // Set activeNetworkStates last to rebuild the dom-repeat. |
| 414 this.activeNetworkStates_ = newActiveNetworkStates; | 401 this.activeNetworkStates_ = newActiveNetworkStates; |
| 415 }, | 402 }, |
| 416 }); | 403 }); |
| OLD | NEW |