| 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'; |
| 467 var entry = {label: loadTimeData.getString(label), | 477 var entry = {label: loadTimeData.getString(label), |
| 468 data: {}}; | 478 data: {}}; |
| 469 if (disabled) { | 479 if (disabled) { |
| 470 entry.command = null; | 480 entry.command = null; |
| 471 entry.tooltip = | 481 entry.tooltip = |
| 472 loadTimeData.getString('dataRoamingDisableToggleTooltip'); | 482 loadTimeData.getString('dataRoamingDisableToggleTooltip'); |
| 473 } else { | 483 } else { |
| 474 var self = this; | 484 var self = this; |
| 475 entry.command = function() { | 485 entry.command = function() { |
| 476 options.Preferences.setBooleanPref( | 486 options.Preferences.setBooleanPref( |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 /** | 936 /** |
| 927 * Sets the default icon to use for each network type if disconnected. | 937 * Sets the default icon to use for each network type if disconnected. |
| 928 * @param {!Object.<string, string>} data Mapping of network type to icon | 938 * @param {!Object.<string, string>} data Mapping of network type to icon |
| 929 * data url. | 939 * data url. |
| 930 */ | 940 */ |
| 931 NetworkList.setDefaultNetworkIcons = function(data) { | 941 NetworkList.setDefaultNetworkIcons = function(data) { |
| 932 defaultIcons_ = Object.create(data); | 942 defaultIcons_ = Object.create(data); |
| 933 }; | 943 }; |
| 934 | 944 |
| 935 /** | 945 /** |
| 946 * Sets the current logged in user type. |
| 947 * @param {string} userType Current logged in user type. |
| 948 */ |
| 949 NetworkList.updateLoggedInUserType = function(userType) { |
| 950 loggedInUserType_ = String(userType); |
| 951 }; |
| 952 |
| 953 /** |
| 936 * Chrome callback for updating network controls. | 954 * Chrome callback for updating network controls. |
| 937 * @param {Object} data Description of available network devices and their | 955 * @param {Object} data Description of available network devices and their |
| 938 * corresponding state. | 956 * corresponding state. |
| 939 */ | 957 */ |
| 940 NetworkList.refreshNetworkData = function(data) { | 958 NetworkList.refreshNetworkData = function(data) { |
| 941 var networkList = $('network-list'); | 959 var networkList = $('network-list'); |
| 942 networkList.startBatchUpdates(); | 960 networkList.startBatchUpdates(); |
| 943 cellularAvailable_ = data.cellularAvailable; | 961 cellularAvailable_ = data.cellularAvailable; |
| 944 cellularEnabled_ = data.cellularEnabled; | 962 cellularEnabled_ = data.cellularEnabled; |
| 945 cellularSupportsScan_ = data.cellularSupportsScan; | 963 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. | 1162 * Whether the Network list is disabled. Only used for display purpose. |
| 1145 * @type {boolean} | 1163 * @type {boolean} |
| 1146 */ | 1164 */ |
| 1147 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); | 1165 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 1148 | 1166 |
| 1149 // Export | 1167 // Export |
| 1150 return { | 1168 return { |
| 1151 NetworkList: NetworkList | 1169 NetworkList: NetworkList |
| 1152 }; | 1170 }; |
| 1153 }); | 1171 }); |
| OLD | NEW |