Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @typedef {{ | 6 * @typedef {{ |
| 7 * ConnectionState: string, | 7 * ConnectionState: string, |
| 8 * iconURL: string, | 8 * iconURL: string, |
| 9 * policyManaged: boolean, | 9 * policyManaged: boolean, |
| 10 * servicePath: string | 10 * servicePath: string |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 142 } |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * @param {string} action An action to send to coreOptionsUserMetricsAction. | 145 * @param {string} action An action to send to coreOptionsUserMetricsAction. |
| 146 */ | 146 */ |
| 147 function sendChromeMetricsAction(action) { | 147 function sendChromeMetricsAction(action) { |
| 148 chrome.send('coreOptionsUserMetricsAction', [action]); | 148 chrome.send('coreOptionsUserMetricsAction', [action]); |
| 149 } | 149 } |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * @param {string} servicePath The network service path. | |
| 153 */ | |
| 154 function showDetails(servicePath) { | |
| 155 // TODO(stevenjb): chrome.networkingPrivate.getManagedProperties | |
| 156 // (Note: we will need to provide DetailsInternetPage.initializeDetailsPage | |
| 157 // as the callback). | |
| 158 chrome.send('getManagedProperties', [servicePath]); | |
| 159 } | |
| 160 | |
| 161 /** | |
| 152 * Decorate an element as a NetworkListItem. | 162 * Decorate an element as a NetworkListItem. |
| 153 * @param {!Element} el The element to decorate. | 163 * @param {!Element} el The element to decorate. |
| 154 */ | 164 */ |
| 155 NetworkListItem.decorate = function(el) { | 165 NetworkListItem.decorate = function(el) { |
| 156 el.__proto__ = NetworkListItem.prototype; | 166 el.__proto__ = NetworkListItem.prototype; |
| 157 el.decorate(); | 167 el.decorate(); |
| 158 }; | 168 }; |
| 159 | 169 |
| 160 NetworkListItem.prototype = { | 170 NetworkListItem.prototype = { |
| 161 __proto__: ListItem.prototype, | 171 __proto__: ListItem.prototype, |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 return networkButtons; | 692 return networkButtons; |
| 683 }, | 693 }, |
| 684 | 694 |
| 685 /** | 695 /** |
| 686 * Adds a menu item for showing network details. | 696 * Adds a menu item for showing network details. |
| 687 * @param {!Element} parent The parent element. | 697 * @param {!Element} parent The parent element. |
| 688 * @param {Object} data Description of the network. | 698 * @param {Object} data Description of the network. |
| 689 * @private | 699 * @private |
| 690 */ | 700 */ |
| 691 createNetworkOptionsCallback_: function(parent, data) { | 701 createNetworkOptionsCallback_: function(parent, data) { |
| 702 var servicePath = data.servicePath; | |
| 703 var showDetailsCallback = function() { | |
| 704 showDetails(servicePath); | |
| 705 }; | |
| 692 var menuItem = createCallback_(parent, | 706 var menuItem = createCallback_(parent, |
| 693 data, | 707 data, |
| 694 getNetworkName(data), | 708 getNetworkName(data), |
| 695 'showDetails', | 709 showDetailsCallback, |
|
pneubeck (no reviews)
2014/10/27 16:37:19
showDetails.bind(null, data.servicePath);
is IMO
stevenjb
2014/10/27 17:32:33
Done.
| |
| 696 data.iconURL); | 710 data.iconURL); |
| 697 if (data.policyManaged) | 711 if (data.policyManaged) |
| 698 menuItem.appendChild(new ManagedNetworkIndicator()); | 712 menuItem.appendChild(new ManagedNetworkIndicator()); |
| 699 if (data.ConnectionState == 'Connected' || | 713 if (data.ConnectionState == 'Connected' || |
| 700 data.ConnectionState == 'Connecting') { | 714 data.ConnectionState == 'Connecting') { |
| 701 var label = menuItem.getElementsByClassName( | 715 var label = menuItem.getElementsByClassName( |
| 702 'network-menu-item-label')[0]; | 716 'network-menu-item-label')[0]; |
| 703 label.classList.add('active-network'); | 717 label.classList.add('active-network'); |
| 704 } | 718 } |
| 705 } | 719 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 if (this.data.policyManaged) | 751 if (this.data.policyManaged) |
| 738 this.showManagedNetworkIndicator(); | 752 this.showManagedNetworkIndicator(); |
| 739 }, | 753 }, |
| 740 }; | 754 }; |
| 741 | 755 |
| 742 /** | 756 /** |
| 743 * Adds a command to a menu for modifying network settings. | 757 * Adds a command to a menu for modifying network settings. |
| 744 * @param {!Element} menu Parent menu. | 758 * @param {!Element} menu Parent menu. |
| 745 * @param {Object} data Description of the network. | 759 * @param {Object} data Description of the network. |
| 746 * @param {!string} label Display name for the menu item. | 760 * @param {!string} label Display name for the menu item. |
| 747 * @param {?(string|!Function)} command Callback function or name | 761 * @param {!Function} command Callback function. |
| 748 * of the command for |networkCommand|. | |
| 749 * @param {string=} opt_iconURL Optional URL to an icon for the menu item. | 762 * @param {string=} opt_iconURL Optional URL to an icon for the menu item. |
| 750 * @return {!Element} The created menu item. | 763 * @return {!Element} The created menu item. |
| 751 * @private | 764 * @private |
| 752 */ | 765 */ |
| 753 function createCallback_(menu, data, label, command, opt_iconURL) { | 766 function createCallback_(menu, data, label, command, opt_iconURL) { |
| 754 var button = menu.ownerDocument.createElement('div'); | 767 var button = menu.ownerDocument.createElement('div'); |
| 755 button.className = 'network-menu-item'; | 768 button.className = 'network-menu-item'; |
| 756 | 769 |
| 757 var buttonIcon = menu.ownerDocument.createElement('div'); | 770 var buttonIcon = menu.ownerDocument.createElement('div'); |
| 758 buttonIcon.className = 'network-menu-item-icon'; | 771 buttonIcon.className = 'network-menu-item-icon'; |
| 759 button.appendChild(buttonIcon); | 772 button.appendChild(buttonIcon); |
| 760 if (opt_iconURL) | 773 if (opt_iconURL) |
| 761 buttonIcon.style.backgroundImage = url(opt_iconURL); | 774 buttonIcon.style.backgroundImage = url(opt_iconURL); |
| 762 | 775 |
| 763 var buttonLabel = menu.ownerDocument.createElement('span'); | 776 var buttonLabel = menu.ownerDocument.createElement('span'); |
| 764 buttonLabel.className = 'network-menu-item-label'; | 777 buttonLabel.className = 'network-menu-item-label'; |
| 765 buttonLabel.textContent = label; | 778 buttonLabel.textContent = label; |
| 766 button.appendChild(buttonLabel); | 779 button.appendChild(buttonLabel); |
| 767 var callback = null; | 780 var callback = null; |
| 768 if (typeof command == 'string') { | 781 if (command != null) { |
| 769 var type = data.Type; | |
| 770 var path = data.servicePath; | |
| 771 callback = function() { | |
| 772 chrome.send('networkCommand', [type, path, command]); | |
| 773 closeMenu_(); | |
| 774 }; | |
| 775 } else if (command != null) { | |
| 776 if (data) { | 782 if (data) { |
| 777 callback = function() { | 783 callback = function() { |
| 778 (/** @type {Function} */(command))(data); | 784 (/** @type {Function} */(command))(data); |
| 779 closeMenu_(); | 785 closeMenu_(); |
| 780 }; | 786 }; |
| 781 } else { | 787 } else { |
| 782 callback = function() { | 788 callback = function() { |
| 783 (/** @type {Function} */(command))(); | 789 (/** @type {Function} */(command))(); |
| 784 closeMenu_(); | 790 closeMenu_(); |
| 785 }; | 791 }; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 cellularSimLockType_ = data.cellularSimLockType; | 1020 cellularSimLockType_ = data.cellularSimLockType; |
| 1015 wimaxAvailable_ = data.wimaxAvailable; | 1021 wimaxAvailable_ = data.wimaxAvailable; |
| 1016 wimaxEnabled_ = data.wimaxEnabled; | 1022 wimaxEnabled_ = data.wimaxEnabled; |
| 1017 | 1023 |
| 1018 // Only show Ethernet control if connected. | 1024 // Only show Ethernet control if connected. |
| 1019 var ethernetConnection = getConnection_(data.wiredList); | 1025 var ethernetConnection = getConnection_(data.wiredList); |
| 1020 if (ethernetConnection) { | 1026 if (ethernetConnection) { |
| 1021 var type = String('Ethernet'); | 1027 var type = String('Ethernet'); |
| 1022 var path = ethernetConnection.servicePath; | 1028 var path = ethernetConnection.servicePath; |
| 1023 var ethernetOptions = function() { | 1029 var ethernetOptions = function() { |
| 1024 chrome.send('networkCommand', [type, path, 'showDetails']); | 1030 showDetails(path); |
| 1025 }; | 1031 }; |
| 1026 networkList.update( | 1032 networkList.update( |
| 1027 { key: 'Ethernet', | 1033 { key: 'Ethernet', |
| 1028 subtitle: loadTimeData.getString('OncConnectionStateConnected'), | 1034 subtitle: loadTimeData.getString('OncConnectionStateConnected'), |
| 1029 iconURL: ethernetConnection.iconURL, | 1035 iconURL: ethernetConnection.iconURL, |
| 1030 command: ethernetOptions, | 1036 command: ethernetOptions, |
| 1031 policyManaged: ethernetConnection.policyManaged } | 1037 policyManaged: ethernetConnection.policyManaged } |
| 1032 ); | 1038 ); |
| 1033 } else { | 1039 } else { |
| 1034 networkList.deleteItem('Ethernet'); | 1040 networkList.deleteItem('Ethernet'); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1215 * @param {string} type An ONC network type | 1221 * @param {string} type An ONC network type |
| 1216 * @return {function()} The created callback. | 1222 * @return {function()} The created callback. |
| 1217 * @private | 1223 * @private |
| 1218 */ | 1224 */ |
| 1219 function createAddConnectionCallback_(type) { | 1225 function createAddConnectionCallback_(type) { |
| 1220 return function() { | 1226 return function() { |
| 1221 if (type == 'WiFi') | 1227 if (type == 'WiFi') |
| 1222 sendChromeMetricsAction('Options_NetworkJoinOtherWifi'); | 1228 sendChromeMetricsAction('Options_NetworkJoinOtherWifi'); |
| 1223 else if (type == 'VPN') | 1229 else if (type == 'VPN') |
| 1224 sendChromeMetricsAction('Options_NetworkJoinOtherVPN'); | 1230 sendChromeMetricsAction('Options_NetworkJoinOtherVPN'); |
| 1225 chrome.send('networkCommand', [type, '', 'add']); | 1231 chrome.send('addConnection', [type]); |
| 1226 }; | 1232 }; |
| 1227 } | 1233 } |
| 1228 | 1234 |
| 1229 /** | 1235 /** |
| 1230 * Whether the Network list is disabled. Only used for display purpose. | 1236 * Whether the Network list is disabled. Only used for display purpose. |
| 1231 */ | 1237 */ |
| 1232 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); | 1238 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 1233 | 1239 |
| 1234 // Export | 1240 // Export |
| 1235 return { | 1241 return { |
| 1236 NetworkList: NetworkList | 1242 NetworkList: NetworkList |
| 1237 }; | 1243 }; |
| 1238 }); | 1244 }); |
| OLD | NEW |