OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options.network', function() { | 5 cr.define('options.network', function() { |
6 | 6 |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 var List = cr.ui.List; | 8 var List = cr.ui.List; |
9 var ListItem = cr.ui.ListItem; | 9 var ListItem = cr.ui.ListItem; |
10 var Menu = cr.ui.Menu; | 10 var Menu = cr.ui.Menu; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return menu; | 302 return menu; |
303 } | 303 } |
304 return null; | 304 return null; |
305 }, | 305 }, |
306 | 306 |
307 /** | 307 /** |
308 * Displays a popup menu. | 308 * Displays a popup menu. |
309 */ | 309 */ |
310 showMenu: function() { | 310 showMenu: function() { |
311 var rebuild = false; | 311 var rebuild = false; |
| 312 // Force a rescan if opening the menu for WiFi networks to ensure the |
| 313 // list is up to date. Networks are periodically rescanned, but depending |
| 314 // on timing, there could be an excessive delay before the first rescan |
| 315 // unless forced. |
| 316 var rescan = !activeMenu_ && this.data_.key == 'wifi'; |
312 if (!this.menu_) { | 317 if (!this.menu_) { |
313 rebuild = true; | 318 rebuild = true; |
314 var existing = $(this.getMenuName_()); | 319 var existing = $(this.getMenuName_()); |
315 if (existing) | 320 if (existing) |
316 closeMenu_(); | 321 closeMenu_(); |
317 this.menu_ = this.createMenu(); | 322 this.menu_ = this.createMenu(); |
318 var parent = $('network-menus'); | 323 var parent = $('network-menus'); |
319 if (existing) | 324 if (existing) |
320 parent.replaceChild(this.menu_, existing); | 325 parent.replaceChild(this.menu_, existing); |
321 else | 326 else |
322 parent.appendChild(this.menu_); | 327 parent.appendChild(this.menu_); |
323 } | 328 } |
324 var top = this.offsetTop + this.clientHeight; | 329 var top = this.offsetTop + this.clientHeight; |
325 var menuId = this.getMenuName_(); | 330 var menuId = this.getMenuName_(); |
326 if (menuId != activeMenu_ || rebuild) { | 331 if (menuId != activeMenu_ || rebuild) { |
327 closeMenu_(); | 332 closeMenu_(); |
328 activeMenu_ = menuId; | 333 activeMenu_ = menuId; |
329 this.menu_.style.setProperty('top', top + 'px'); | 334 this.menu_.style.setProperty('top', top + 'px'); |
330 this.menu_.hidden = false; | 335 this.menu_.hidden = false; |
331 } | 336 } |
| 337 if (rescan) |
| 338 chrome.send('refreshNetworksCallback'); |
332 }, | 339 }, |
333 }; | 340 }; |
334 | 341 |
335 /** | 342 /** |
336 * Creates a control for selecting or configuring a network connection based | 343 * Creates a control for selecting or configuring a network connection based |
337 * on the type of connection (e.g. wifi versus vpn). | 344 * on the type of connection (e.g. wifi versus vpn). |
338 * @param {{key: string, | 345 * @param {{key: string, |
339 * networkList: Array.<Object>} data Description of the network. | 346 * networkList: Array.<Object>} data Description of the network. |
340 * @constructor | 347 * @constructor |
341 */ | 348 */ |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 * Whether the Network list is disabled. Only used for display purpose. | 1007 * Whether the Network list is disabled. Only used for display purpose. |
1001 * @type {boolean} | 1008 * @type {boolean} |
1002 */ | 1009 */ |
1003 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); | 1010 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); |
1004 | 1011 |
1005 // Export | 1012 // Export |
1006 return { | 1013 return { |
1007 NetworkList: NetworkList | 1014 NetworkList: NetworkList |
1008 }; | 1015 }; |
1009 }); | 1016 }); |
OLD | NEW |