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

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

Issue 570503002: Compile chrome://settings, part 6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@H_options_errors_4
Patch Set: Created 6 years, 3 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 /**
6 * @typedef {{
7 * ConnectionState: string,
8 * iconURL: string,
9 * policyManaged: boolean,
10 * servicePath: string
11 * }}
12 * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
13 */
14 var NetworkInfo;
15
5 cr.define('options.network', function() { 16 cr.define('options.network', function() {
6 var ArrayDataModel = cr.ui.ArrayDataModel; 17 var ArrayDataModel = cr.ui.ArrayDataModel;
7 var List = cr.ui.List; 18 var List = cr.ui.List;
8 var ListItem = cr.ui.ListItem; 19 var ListItem = cr.ui.ListItem;
9 var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; 20 var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
10 var Menu = cr.ui.Menu; 21 var Menu = cr.ui.Menu;
11 var MenuItem = cr.ui.MenuItem; 22 var MenuItem = cr.ui.MenuItem;
12 var ControlledSettingIndicator = options.ControlledSettingIndicator; 23 var ControlledSettingIndicator = options.ControlledSettingIndicator;
13 24
14 /** 25 /**
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 this.menu_.hidden = false; 373 this.menu_.hidden = false;
363 } 374 }
364 if (rescan) 375 if (rescan)
365 chrome.send('refreshNetworks'); 376 chrome.send('refreshNetworks');
366 }, 377 },
367 }; 378 };
368 379
369 /** 380 /**
370 * Creates a control for selecting or configuring a network connection based 381 * Creates a control for selecting or configuring a network connection based
371 * on the type of connection (e.g. wifi versus vpn). 382 * on the type of connection (e.g. wifi versus vpn).
372 * @param {{key: string, networkList: Array.<Object>}} data Description of the 383 * @param {{key: string, networkList: Array.<NetworkInfo>}} data Description
373 * network. 384 * of the network.
374 * @constructor 385 * @constructor
375 * @extends {NetworkMenuItem} 386 * @extends {NetworkMenuItem}
376 */ 387 */
377 function NetworkSelectorItem(data) { 388 function NetworkSelectorItem(data) {
378 var el = new NetworkMenuItem(data); 389 var el = new NetworkMenuItem(data);
379 el.__proto__ = NetworkSelectorItem.prototype; 390 el.__proto__ = NetworkSelectorItem.prototype;
380 el.decorate(); 391 el.decorate();
381 return el; 392 return el;
382 } 393 }
383 394
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 discardOnClose = true; 624 discardOnClose = true;
614 } 625 }
615 } 626 }
616 oldMenu.data = {discardOnClose: discardOnClose}; 627 oldMenu.data = {discardOnClose: discardOnClose};
617 return true; 628 return true;
618 }, 629 },
619 630
620 /** 631 /**
621 * Extracts a mapping of network names to menu element and position. 632 * Extracts a mapping of network names to menu element and position.
622 * @param {!Element} menu The menu to process. 633 * @param {!Element} menu The menu to process.
623 * @return {Object.<string, {index: number, button: Element}>} 634 * @return {Object.<string, ?{index: number, button: Element}>}
624 * Network mapping. 635 * Network mapping.
625 * @private 636 * @private
626 */ 637 */
627 extractNetworkConnectButtons_: function(menu) { 638 extractNetworkConnectButtons_: function(menu) {
628 var group = menu.getElementsByClassName('network-menu-group')[0]; 639 var group = menu.getElementsByClassName('network-menu-group')[0];
629 var networkButtons = {}; 640 var networkButtons = {};
630 if (!group) 641 if (!group)
631 return networkButtons; 642 return networkButtons;
632 var buttons = group.getElementsByClassName('network-menu-item'); 643 var buttons = group.getElementsByClassName('network-menu-item');
633 for (var i = 0; i < buttons.length; i++) { 644 for (var i = 0; i < buttons.length; i++) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 this.dataModel.splice(referenceIndex + 1, 0, data); 894 this.dataModel.splice(referenceIndex + 1, 0, data);
884 } 895 }
885 } else { 896 } else {
886 var entry = this.dataModel.item(index); 897 var entry = this.dataModel.item(index);
887 data.sortIndex = entry.sortIndex; 898 data.sortIndex = entry.sortIndex;
888 this.dataModel.splice(index, 1, data); 899 this.dataModel.splice(index, 1, data);
889 } 900 }
890 this.endBatchUpdates(); 901 this.endBatchUpdates();
891 }, 902 },
892 903
893 /** @override */ 904 /**
905 * @override
906 * @param {Object} entry
907 */
894 createItem: function(entry) { 908 createItem: function(entry) {
895 if (entry.networkList) 909 if (entry.networkList)
896 return new NetworkSelectorItem(entry); 910 return new NetworkSelectorItem(
911 /** @type {{key: string, networkList: Array.<NetworkInfo>}} */(
912 entry));
Dan Beam 2014/09/12 03:25:19 indent off
Vitaly Pavlenko 2014/09/12 19:16:23 This way?
Dan Beam 2014/09/16 01:04:14 yes
Vitaly Pavlenko 2014/09/16 03:11:20 Acknowledged.
897 if (entry.command) 913 if (entry.command)
898 return new NetworkButtonItem(entry); 914 return new NetworkButtonItem(
915 /** @type {{key: string, subtitle: string, command: Function}} */(
916 entry));
899 if (entry.menu) 917 if (entry.menu)
900 return new NetworkMenuItem(entry); 918 return new NetworkMenuItem(entry);
901 return undefined; 919 return undefined;
902 }, 920 },
903 921
904 /** 922 /**
905 * Deletes an element from the list. 923 * Deletes an element from the list.
906 * @param {string} key Unique identifier for the element. 924 * @param {string} key Unique identifier for the element.
907 */ 925 */
908 deleteItem: function(key) { 926 deleteItem: function(key) {
(...skipping 22 matching lines...) Expand all
931 * Sets the default icon to use for each network type if disconnected. 949 * Sets the default icon to use for each network type if disconnected.
932 * @param {!Object.<string, string>} data Mapping of network type to icon 950 * @param {!Object.<string, string>} data Mapping of network type to icon
933 * data url. 951 * data url.
934 */ 952 */
935 NetworkList.setDefaultNetworkIcons = function(data) { 953 NetworkList.setDefaultNetworkIcons = function(data) {
936 defaultIcons_ = Object.create(data); 954 defaultIcons_ = Object.create(data);
937 }; 955 };
938 956
939 /** 957 /**
940 * Chrome callback for updating network controls. 958 * Chrome callback for updating network controls.
941 * @param {{wiredList: Array, wirelessList: Array, vpnList: Array, 959 * @param {{wiredList: Array.<NetworkInfo>, wirelessList: Array.<NetworkInfo>,
942 * rememberedList: Array, wifiAvailable: boolean, wifiEnabled: boolean, 960 * vpnList: Array.<NetworkInfo>, rememberedList: Array.<NetworkInfo>,
943 * wimaxAvailable: boolean, wimaxEnabled: boolean, 961 * wifiAvailable: boolean, wifiEnabled: boolean, wimaxAvailable: boolean,
944 * cellularAvailable: boolean, cellularEnabled: boolean, 962 * wimaxEnabled: boolean, cellularAvailable: boolean,
945 * cellularSupportsScan: boolean}} data Description of available network 963 * cellularEnabled: boolean, cellularSupportsScan: boolean}} data
946 * devices and their corresponding state. 964 * Description of available network devices and their corresponding state.
947 */ 965 */
948 NetworkList.refreshNetworkData = function(data) { 966 NetworkList.refreshNetworkData = function(data) {
949 var networkList = $('network-list'); 967 var networkList = $('network-list');
950 networkList.startBatchUpdates(); 968 networkList.startBatchUpdates();
951 cellularAvailable_ = data.cellularAvailable; 969 cellularAvailable_ = data.cellularAvailable;
952 cellularEnabled_ = data.cellularEnabled; 970 cellularEnabled_ = data.cellularEnabled;
953 cellularSupportsScan_ = data.cellularSupportsScan; 971 cellularSupportsScan_ = data.cellularSupportsScan;
954 wimaxAvailable_ = data.wimaxAvailable; 972 wimaxAvailable_ = data.wimaxAvailable;
955 wimaxEnabled_ = data.wimaxEnabled; 973 wimaxEnabled_ = data.wimaxEnabled;
956 974
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 /** 1173 /**
1156 * Whether the Network list is disabled. Only used for display purpose. 1174 * Whether the Network list is disabled. Only used for display purpose.
1157 */ 1175 */
1158 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); 1176 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR);
1159 1177
1160 // Export 1178 // Export
1161 return { 1179 return {
1162 NetworkList: NetworkList 1180 NetworkList: NetworkList
1163 }; 1181 };
1164 }); 1182 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698