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

Side by Side Diff: chrome/browser/resources/options2/chromeos/network_list.js

Issue 10824328: Reduce number of expensive calls to List.redraw() during load of settings page. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed all comments. Created 8 years, 4 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 (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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 * @constructor 721 * @constructor
722 */ 722 */
723 var NetworkList = cr.ui.define('list'); 723 var NetworkList = cr.ui.define('list');
724 724
725 NetworkList.prototype = { 725 NetworkList.prototype = {
726 __proto__: List.prototype, 726 __proto__: List.prototype,
727 727
728 /** @inheritDoc */ 728 /** @inheritDoc */
729 decorate: function() { 729 decorate: function() {
730 List.prototype.decorate.call(this); 730 List.prototype.decorate.call(this);
731 this.startBatchUpdates();
731 this.autoExpands = true; 732 this.autoExpands = true;
732 this.addEventListener('blur', this.onBlur_); 733 this.addEventListener('blur', this.onBlur_);
733 this.dataModel = new ArrayDataModel([]); 734 this.dataModel = new ArrayDataModel([]);
734 735
735 // Wi-Fi control is always visible. 736 // Wi-Fi control is always visible.
736 this.update({key: 'wifi', networkList: []}); 737 this.update({key: 'wifi', networkList: []});
737 738
738 if (airplaneModeAvailable_()) { 739 if (airplaneModeAvailable_()) {
739 this.update({key: 'airplaneMode', 740 this.update({key: 'airplaneMode',
740 subtitle: loadTimeData.getString('airplaneModeLabel'), 741 subtitle: loadTimeData.getString('airplaneModeLabel'),
(...skipping 16 matching lines...) Expand all
757 command: addConnection(Constants.TYPE_WIFI)}, 758 command: addConnection(Constants.TYPE_WIFI)},
758 {label: loadTimeData.getString('addConnectionVPN'), 759 {label: loadTimeData.getString('addConnectionVPN'),
759 command: addConnection(Constants.TYPE_VPN)}] 760 command: addConnection(Constants.TYPE_VPN)}]
760 }); 761 });
761 762
762 var prefs = options.Preferences.getInstance(); 763 var prefs = options.Preferences.getInstance();
763 prefs.addEventListener('cros.signed.data_roaming_enabled', 764 prefs.addEventListener('cros.signed.data_roaming_enabled',
764 function(event) { 765 function(event) {
765 enableDataRoaming_ = event.value.value; 766 enableDataRoaming_ = event.value.value;
766 }); 767 });
768 this.endBatchUpdates();
767 }, 769 },
768 770
769 /** 771 /**
770 * When the list loses focus, unselect all items in the list and close the 772 * When the list loses focus, unselect all items in the list and close the
771 * active menu. 773 * active menu.
772 * @private 774 * @private
773 */ 775 */
774 onBlur_: function() { 776 onBlur_: function() {
775 this.selectionModel.unselectAll(); 777 this.selectionModel.unselectAll();
776 closeMenu_(); 778 closeMenu_();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 } 873 }
872 }; 874 };
873 875
874 /** 876 /**
875 * Chrome callback for updating network controls. 877 * Chrome callback for updating network controls.
876 * @param {Object} data Description of available network devices and their 878 * @param {Object} data Description of available network devices and their
877 * corresponding state. 879 * corresponding state.
878 */ 880 */
879 NetworkList.refreshNetworkData = function(data) { 881 NetworkList.refreshNetworkData = function(data) {
880 var networkList = $('network-list'); 882 var networkList = $('network-list');
883 networkList.startBatchUpdates();
881 cellularAvailable_ = data.cellularAvailable; 884 cellularAvailable_ = data.cellularAvailable;
882 cellularEnabled_ = data.cellularEnabled; 885 cellularEnabled_ = data.cellularEnabled;
883 wimaxAvailable_ = data.wimaxAvailable; 886 wimaxAvailable_ = data.wimaxAvailable;
884 wimaxEnabled_ = data.wimaxEnabled; 887 wimaxEnabled_ = data.wimaxEnabled;
885 888
886 if (data.accessLocked) { 889 if (data.accessLocked) {
887 $('network-locked-message').hidden = false; 890 $('network-locked-message').hidden = false;
888 networkList.disabled = true; 891 networkList.disabled = true;
889 $('use-shared-proxies').disabled = true; 892 $('use-shared-proxies').disabled = true;
890 } else { 893 } else {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 } 962 }
960 963
961 // Only show VPN control if there is an available network and an internet 964 // Only show VPN control if there is an available network and an internet
962 // connection. 965 // connection.
963 if (data.vpnList.length > 0 && (ethernetConnection || 966 if (data.vpnList.length > 0 && (ethernetConnection ||
964 isConnected_(data.wirelessList))) 967 isConnected_(data.wirelessList)))
965 loadData_('vpn', data.vpnList, data.rememberedList); 968 loadData_('vpn', data.vpnList, data.rememberedList);
966 else 969 else
967 networkList.deleteItem('vpn'); 970 networkList.deleteItem('vpn');
968 networkList.updateToggleControl('airplaneMode', data.airplaneMode); 971 networkList.updateToggleControl('airplaneMode', data.airplaneMode);
972 networkList.endBatchUpdates();
969 }; 973 };
970 974
971 /** 975 /**
972 * Element for indicating a policy managed network. 976 * Element for indicating a policy managed network.
973 * @constructor 977 * @constructor
974 */ 978 */
975 function ManagedNetworkIndicator() { 979 function ManagedNetworkIndicator() {
976 var el = cr.doc.createElement('div'); 980 var el = cr.doc.createElement('div');
977 el.__proto__ = ManagedNetworkIndicator.prototype; 981 el.__proto__ = ManagedNetworkIndicator.prototype;
978 el.decorate(); 982 el.decorate();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 * Whether the Network list is disabled. Only used for display purpose. 1089 * Whether the Network list is disabled. Only used for display purpose.
1086 * @type {boolean} 1090 * @type {boolean}
1087 */ 1091 */
1088 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); 1092 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR);
1089 1093
1090 // Export 1094 // Export
1091 return { 1095 return {
1092 NetworkList: NetworkList 1096 NetworkList: NetworkList
1093 }; 1097 };
1094 }); 1098 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698