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 (function() { | 9 (function() { |
10 | 10 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 * networkingPrivate.onNetworksChanged event callback. | 201 * networkingPrivate.onNetworksChanged event callback. |
202 * @param {!Array<string>} networkIds The list of changed network GUIDs. | 202 * @param {!Array<string>} networkIds The list of changed network GUIDs. |
203 * @private | 203 * @private |
204 */ | 204 */ |
205 onNetworksChangedEvent_: function(networkIds) { | 205 onNetworksChangedEvent_: function(networkIds) { |
206 networkIds.forEach(function(id) { | 206 networkIds.forEach(function(id) { |
207 if (id in this.networkIds_) { | 207 if (id in this.networkIds_) { |
208 chrome.networkingPrivate.getState( | 208 chrome.networkingPrivate.getState( |
209 id, | 209 id, |
210 function(state) { | 210 function(state) { |
| 211 if (chrome.runtime.lastError) { |
| 212 if (chrome.runtime.lastError != 'Error.NetworkUnavailable') { |
| 213 console.error('Unexpected networkingPrivate.getState error:', |
| 214 chrome.runtime.lastError); |
| 215 } |
| 216 return; |
| 217 } |
211 // Async call, ensure id still exists. | 218 // Async call, ensure id still exists. |
212 if (!this.networkIds_[id]) | 219 if (!this.networkIds_[id]) |
213 return; | 220 return; |
214 if (!state) { | 221 if (!state) { |
215 this.networkIds_[id] = undefined; | 222 this.networkIds_[id] = undefined; |
216 return; | 223 return; |
217 } | 224 } |
218 this.updateNetworkState_(state.Type, state); | 225 this.updateNetworkState_(state.Type, state); |
219 }.bind(this)); | 226 }.bind(this)); |
220 } | 227 } |
221 }, this); | 228 }, this); |
222 }, | 229 }, |
223 | 230 |
224 /** | 231 /** |
225 * Handles UI requests to connect to a network. | 232 * Handles UI requests to connect to a network. |
226 * TODO(stevenjb): Handle Cellular activation, etc. | 233 * TODO(stevenjb): Handle Cellular activation, etc. |
227 * @param {!CrOnc.NetworkStateProperties} state The network state. | 234 * @param {!CrOnc.NetworkStateProperties} state The network state. |
228 * @private | 235 * @private |
229 */ | 236 */ |
230 connectToNetwork_: function(state) { | 237 connectToNetwork_: function(state) { |
231 chrome.networkingPrivate.startConnect(state.GUID); | 238 chrome.networkingPrivate.startConnect(state.GUID, function() { |
| 239 if (chrome.runtime.lastError && |
| 240 chrome.runtime.lastError != 'connecting') { |
| 241 console.error('Unexpected networkingPrivate.startConnect error:', |
| 242 chrome.runtime.lastError); |
| 243 } |
| 244 }); |
232 }, | 245 }, |
233 | 246 |
234 /** | 247 /** |
235 * Requests the list of device states and network states from Chrome. | 248 * Requests the list of device states and network states from Chrome. |
236 * Updates deviceStates, networkStates, and networkStateLists once the | 249 * Updates deviceStates, networkStates, and networkStateLists once the |
237 * results are returned from Chrome. | 250 * results are returned from Chrome. |
238 * @private | 251 * @private |
239 */ | 252 */ |
240 getNetworkLists_: function() { | 253 getNetworkLists_: function() { |
241 // First get the device states. | 254 // First get the device states. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 * matching |type|. | 347 * matching |type|. |
335 * @private | 348 * @private |
336 */ | 349 */ |
337 updateNetworkState_: function(type, state) { | 350 updateNetworkState_: function(type, state) { |
338 this.set('networkStates.' + type, state); | 351 this.set('networkStates.' + type, state); |
339 if (state) | 352 if (state) |
340 this.networkIds_[state.GUID] = true; | 353 this.networkIds_[state.GUID] = true; |
341 }, | 354 }, |
342 }); | 355 }); |
343 })(); | 356 })(); |
OLD | NEW |