| 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 wrapping cr-network-list including the | 6 * @fileoverview Polymer element wrapping cr-network-list including the |
| 7 * networkingPrivate calls to populate it. | 7 * networkingPrivate calls to populate it. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 Polymer({ | 10 Polymer({ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 /** | 47 /** |
| 48 * List of all network state data for all visible networks. | 48 * List of all network state data for all visible networks. |
| 49 * @private {!Array<!CrOnc.NetworkStateProperties>} | 49 * @private {!Array<!CrOnc.NetworkStateProperties>} |
| 50 */ | 50 */ |
| 51 networkStateList_: { | 51 networkStateList_: { |
| 52 type: Array, | 52 type: Array, |
| 53 value: function() { | 53 value: function() { |
| 54 return []; | 54 return []; |
| 55 }, | 55 }, |
| 56 }, | 56 }, |
| 57 | |
| 58 }, | 57 }, |
| 59 | 58 |
| 60 /** | 59 /** |
| 61 * Listener function for chrome.networkingPrivate.onNetworkListChanged event. | 60 * Listener function for chrome.networkingPrivate.onNetworkListChanged event. |
| 62 * @type {function(!Array<string>)} | 61 * @type {function(!Array<string>)} |
| 63 * @private | 62 * @private |
| 64 */ | 63 */ |
| 65 networkListChangedListener_: function() {}, | 64 networkListChangedListener_: function() {}, |
| 66 | 65 |
| 67 /** | 66 /** |
| 68 * Listener function for chrome.networkingPrivate.onDeviceStateListChanged | 67 * Listener function for chrome.networkingPrivate.onDeviceStateListChanged |
| 69 * event. | 68 * event. |
| 70 * @type {function(!Array<string>)} | 69 * @type {function(!Array<string>)} |
| 71 * @private | 70 * @private |
| 72 */ | 71 */ |
| 73 deviceStateListChangedListener_: function() {}, | 72 deviceStateListChangedListener_: function() {}, |
| 74 | 73 |
| 74 /** @private {number|null} */ |
| 75 scanIntervalId_: null, |
| 76 |
| 75 /** @override */ | 77 /** @override */ |
| 76 attached: function() { | 78 attached: function() { |
| 77 this.networkListChangedListener_ = this.refreshNetworks.bind(this); | 79 this.networkListChangedListener_ = this.refreshNetworks.bind(this); |
| 78 chrome.networkingPrivate.onNetworkListChanged.addListener( | 80 chrome.networkingPrivate.onNetworkListChanged.addListener( |
| 79 this.networkListChangedListener_); | 81 this.networkListChangedListener_); |
| 80 | 82 |
| 81 this.deviceStateListChangedListener_ = this.refreshNetworks.bind(this); | 83 this.deviceStateListChangedListener_ = this.refreshNetworks.bind(this); |
| 82 chrome.networkingPrivate.onDeviceStateListChanged.addListener( | 84 chrome.networkingPrivate.onDeviceStateListChanged.addListener( |
| 83 this.deviceStateListChangedListener_); | 85 this.deviceStateListChangedListener_); |
| 84 | 86 |
| 85 this.refreshNetworks(); | 87 this.refreshNetworks(); |
| 88 |
| 89 /** @const */ var INTERVAL_MS = 10 * 1000; |
| 86 chrome.networkingPrivate.requestNetworkScan(); | 90 chrome.networkingPrivate.requestNetworkScan(); |
| 91 this.scanIntervalId_ = window.setInterval(function() { |
| 92 chrome.networkingPrivate.requestNetworkScan(); |
| 93 }.bind(this), INTERVAL_MS); |
| 87 }, | 94 }, |
| 88 | 95 |
| 89 /** @override */ | 96 /** @override */ |
| 90 detached: function() { | 97 detached: function() { |
| 98 if (this.scanIntervalId_ !== null) |
| 99 window.clearInterval(this.scanIntervalId_); |
| 91 chrome.networkingPrivate.onNetworkListChanged.removeListener( | 100 chrome.networkingPrivate.onNetworkListChanged.removeListener( |
| 92 this.networkListChangedListener_); | 101 this.networkListChangedListener_); |
| 93 chrome.networkingPrivate.onDeviceStateListChanged.removeListener( | 102 chrome.networkingPrivate.onDeviceStateListChanged.removeListener( |
| 94 this.deviceStateListChangedListener_); | 103 this.deviceStateListChangedListener_); |
| 95 }, | 104 }, |
| 96 | 105 |
| 97 /** | 106 /** |
| 98 * Request the list of visible networks. May be called externally to force a | 107 * Request the list of visible networks. May be called externally to force a |
| 99 * refresh and list update (e.g. when the element is shown). | 108 * refresh and list update (e.g. when the element is shown). |
| 100 */ | 109 */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 }, | 165 }, |
| 157 | 166 |
| 158 /** | 167 /** |
| 159 * @param {?CrOnc.NetworkStateProperties} state | 168 * @param {?CrOnc.NetworkStateProperties} state |
| 160 * @private | 169 * @private |
| 161 */ | 170 */ |
| 162 defaultNetworkChanged_: function(state) { | 171 defaultNetworkChanged_: function(state) { |
| 163 this.fire('default-network-changed', state); | 172 this.fire('default-network-changed', state); |
| 164 }, | 173 }, |
| 165 }); | 174 }); |
| OLD | NEW |