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 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 ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 10 var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 var enableDataRoaming_ = false; | 105 var enableDataRoaming_ = false; |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * Icon to use when not connected to a particular type of network. | 108 * Icon to use when not connected to a particular type of network. |
| 109 * @type {!Object.<string, string>} Mapping of network type to icon data url. | 109 * @type {!Object.<string, string>} Mapping of network type to icon data url. |
| 110 * @private | 110 * @private |
| 111 */ | 111 */ |
| 112 var defaultIcons_ = {}; | 112 var defaultIcons_ = {}; |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * Contains the current logged in user type, which is one of 'none', | |
| 116 * 'regular', 'owner', 'guest', 'retail-mode', 'public-account', | |
| 117 * 'locally-managed', and 'kiosk-app', or empty string if the data has not | |
| 118 * been set. | |
| 119 * @type {string} | |
| 120 * @private | |
| 121 */ | |
| 122 var loggedInUserType_ = ''; | |
| 123 | |
| 124 /** | |
| 115 * Create an element in the network list for controlling network | 125 * Create an element in the network list for controlling network |
| 116 * connectivity. | 126 * connectivity. |
| 117 * @param {Object} data Description of the network list or command. | 127 * @param {Object} data Description of the network list or command. |
| 118 * @constructor | 128 * @constructor |
| 119 */ | 129 */ |
| 120 function NetworkListItem(data) { | 130 function NetworkListItem(data) { |
| 121 var el = cr.doc.createElement('li'); | 131 var el = cr.doc.createElement('li'); |
| 122 el.data_ = {}; | 132 el.data_ = {}; |
| 123 for (var key in data) | 133 for (var key in data) |
| 124 el.data_[key] = data[key]; | 134 el.data_[key] = data[key]; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 label: loadTimeData.getString('otherCellularNetworks'), | 466 label: loadTimeData.getString('otherCellularNetworks'), |
| 457 command: createAddConnectionCallback_(Constants.TYPE_CELLULAR), | 467 command: createAddConnectionCallback_(Constants.TYPE_CELLULAR), |
| 458 addClass: ['other-cellulars'], | 468 addClass: ['other-cellulars'], |
| 459 data: {} | 469 data: {} |
| 460 }; | 470 }; |
| 461 addendum.push(entry); | 471 addendum.push(entry); |
| 462 } | 472 } |
| 463 | 473 |
| 464 var label = enableDataRoaming_ ? 'disableDataRoaming' : | 474 var label = enableDataRoaming_ ? 'disableDataRoaming' : |
| 465 'enableDataRoaming'; | 475 'enableDataRoaming'; |
| 466 var disabled = !UIAccountTweaks.currentUserIsOwner(); | 476 var disabled = !(loggedInUserType_ == 'owner' || |
| 477 UIAccountTweaks.currentUserIsOwner()); | |
|
stevenjb
2013/09/10 16:58:05
Do we still need toe UIAccountTweaks check? If so,
armansito
2013/09/10 21:55:19
I originally thought that we should use UIAccountT
| |
| 467 var entry = {label: loadTimeData.getString(label), | 478 var entry = {label: loadTimeData.getString(label), |
| 468 data: {}}; | 479 data: {}}; |
| 469 if (disabled) { | 480 if (disabled) { |
| 470 entry.command = null; | 481 entry.command = null; |
| 471 entry.tooltip = | 482 entry.tooltip = |
| 472 loadTimeData.getString('dataRoamingDisableToggleTooltip'); | 483 loadTimeData.getString('dataRoamingDisableToggleTooltip'); |
| 473 } else { | 484 } else { |
| 474 var self = this; | 485 var self = this; |
| 475 entry.command = function() { | 486 entry.command = function() { |
| 476 options.Preferences.setBooleanPref( | 487 options.Preferences.setBooleanPref( |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 926 /** | 937 /** |
| 927 * Sets the default icon to use for each network type if disconnected. | 938 * Sets the default icon to use for each network type if disconnected. |
| 928 * @param {!Object.<string, string>} data Mapping of network type to icon | 939 * @param {!Object.<string, string>} data Mapping of network type to icon |
| 929 * data url. | 940 * data url. |
| 930 */ | 941 */ |
| 931 NetworkList.setDefaultNetworkIcons = function(data) { | 942 NetworkList.setDefaultNetworkIcons = function(data) { |
| 932 defaultIcons_ = Object.create(data); | 943 defaultIcons_ = Object.create(data); |
| 933 }; | 944 }; |
| 934 | 945 |
| 935 /** | 946 /** |
| 947 * Sets the current logged in user type. | |
| 948 * @param {string} userType Current logged in user type. | |
| 949 */ | |
| 950 NetworkList.updateLoggedInUserType = function(userType) { | |
| 951 loggedInUserType_ = String(userType); | |
| 952 }; | |
| 953 | |
| 954 /** | |
| 936 * Chrome callback for updating network controls. | 955 * Chrome callback for updating network controls. |
| 937 * @param {Object} data Description of available network devices and their | 956 * @param {Object} data Description of available network devices and their |
| 938 * corresponding state. | 957 * corresponding state. |
| 939 */ | 958 */ |
| 940 NetworkList.refreshNetworkData = function(data) { | 959 NetworkList.refreshNetworkData = function(data) { |
| 941 var networkList = $('network-list'); | 960 var networkList = $('network-list'); |
| 942 networkList.startBatchUpdates(); | 961 networkList.startBatchUpdates(); |
| 943 cellularAvailable_ = data.cellularAvailable; | 962 cellularAvailable_ = data.cellularAvailable; |
| 944 cellularEnabled_ = data.cellularEnabled; | 963 cellularEnabled_ = data.cellularEnabled; |
| 945 cellularSupportsScan_ = data.cellularSupportsScan; | 964 cellularSupportsScan_ = data.cellularSupportsScan; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1144 * Whether the Network list is disabled. Only used for display purpose. | 1163 * Whether the Network list is disabled. Only used for display purpose. |
| 1145 * @type {boolean} | 1164 * @type {boolean} |
| 1146 */ | 1165 */ |
| 1147 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); | 1166 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 1148 | 1167 |
| 1149 // Export | 1168 // Export |
| 1150 return { | 1169 return { |
| 1151 NetworkList: NetworkList | 1170 NetworkList: NetworkList |
| 1152 }; | 1171 }; |
| 1153 }); | 1172 }); |
| OLD | NEW |