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 // NOTE(stevenjb): This code is in the process of being converted to be | 5 // NOTE(stevenjb): This code is in the process of being converted to be |
| 6 // compatible with the networkingPrivate extension API: | 6 // compatible with the networkingPrivate extension API: |
| 7 // * The network property dictionaries are being converted to use ONC values. | 7 // * The network property dictionaries are being converted to use ONC values. |
| 8 // * chrome.send calls will be replaced with an API object that simulates the | 8 // * chrome.send calls will be replaced with an API object that simulates the |
| 9 // networkingPrivate API. See network_config.js. | 9 // networkingPrivate API. See network_config.js. |
| 10 // See crbug.com/279351 for more info. | 10 // See crbug.com/279351 for more info. |
| 11 | 11 |
| 12 cr.define('options.internet', function() { | 12 cr.define('options.internet', function() { |
| 13 var Page = cr.ui.pageManager.Page; | 13 var Page = cr.ui.pageManager.Page; |
| 14 var PageManager = cr.ui.pageManager.PageManager; | 14 var PageManager = cr.ui.pageManager.PageManager; |
| 15 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 15 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 16 /** @const */ var IPAddressField = options.internet.IPAddressField; | 16 /** @const */ var IPAddressField = options.internet.IPAddressField; |
| 17 | 17 |
| 18 var GetManagedTypes = { | |
| 19 ACTIVE: 0, | |
| 20 TRANSLATED: 1, | |
| 21 RECOMMENDED: 2 | |
| 22 }; | |
| 23 | |
| 18 /** | 24 /** |
| 19 * Helper function to get the "Active" value of a property from a dictionary | 25 * Gets the value of a property from a dictionary |data| that includes ONC |
| 20 * that includes ONC managed properties, e.g. getActiveValue(data, 'Name'). | 26 * managed properties, e.g. getManagedValue(data, 'Name'). See notes for |
| 21 * We use (data, key) instead of getActiveValue(data[key]) so that we can | 27 * getManagedProperty. |
| 22 * (possibly) add ONC key validation once all properties use ONC. | |
| 23 * @param {object} data The properties dictionary. | 28 * @param {object} data The properties dictionary. |
| 24 * @param {string} key The property key. | 29 * @param {string} key The property key. |
| 25 * @return {*} the property value or undefined. | 30 * @param {string} type (Optional) The type of property to get as defined in |
| 31 * GetManagedTypes: | |
| 32 * 'ACTIVE' (default) - gets the active value | |
| 33 * 'TRANSLATED' - gets the traslated or active value | |
| 34 * 'RECOMMENDED' - gets the recommended value | |
| 35 * @return {*} The property value or undefined. | |
| 26 */ | 36 */ |
| 27 function getActiveValue(data, key) { | 37 function getManagedValue(data, key, type) { |
| 28 if (!(key in data)) | 38 var property = getManagedProperty(data, key); |
| 29 return undefined; | |
| 30 var property = data[key]; | |
| 31 if (typeof property != 'object') | 39 if (typeof property != 'object') |
| 32 return property; | 40 return property; |
| 41 if (type == GetManagedTypes.RECOMMENDED) | |
| 42 return getRecommendedValue(property); | |
| 43 if (type == GetManagedTypes.TRANSLATED && 'Translated' in property) | |
| 44 return property['Translated']; | |
| 45 // Otherwise get the Active value (defalt behavior). | |
|
pneubeck (no reviews)
2014/08/20 08:16:15
typo: defalt -> default
stevenjb
2014/08/20 17:18:37
Done.
| |
| 33 if ('Active' in property) | 46 if ('Active' in property) |
| 34 return property['Active']; | 47 return property['Active']; |
| 48 // If no Active value is defined, return the effective value. | |
| 49 return getEffectiveValue(property); | |
| 50 } | |
| 51 | |
| 52 /** | |
| 53 * Get the recommended value from a Managed property ONC dictionary. | |
| 54 * @param {object} property The managed property ONC dictionary. | |
| 55 * @return {*} the effective value or undefined. | |
| 56 */ | |
| 57 function getRecommendedValue(property) { | |
| 58 if (property['UserEditable']) | |
| 59 return property['UserPolicy']; | |
| 60 if (property['DeviceEditable']) | |
| 61 return property['DevicePolicy']; | |
| 62 // No value recommended by policy. | |
| 63 return undefined; | |
| 64 } | |
| 65 | |
| 66 /** | |
| 67 * Get the effective value from a Managed property ONC dictionary. | |
| 68 * @param {object} property The managed property ONC dictionary. | |
| 69 * @return {*} The effective value or undefined. | |
| 70 */ | |
| 71 function getEffectiveValue(property) { | |
| 35 if ('Effective' in property) { | 72 if ('Effective' in property) { |
| 36 var effective = property.Effective; | 73 var effective = property.Effective; |
| 37 if (effective in property) | 74 if (effective in property) |
| 38 return property[effective]; | 75 return property[effective]; |
| 39 } | 76 } |
| 40 return undefined; | 77 return undefined; |
| 41 } | 78 } |
| 42 | 79 |
| 43 /** | 80 /** |
| 44 * Helper function for nested ONC properties, e.g. data[WiFi][Strength]. | 81 * Gets either a managed property dictionary or an unmanaged value from |
| 45 * @param {object|string} property The property which must ether be | 82 * dictionary |data| that includes ONC managed properties. This supports |
| 46 * a dictionary object or not be present. | 83 * nested dictionaries, e.g. getManagedProperty(data, 'VPN.Type'). |
| 47 * @return {*} the property value or undefined. | 84 * @param {object} data The properties dictionary. |
| 85 * @param {string} key The property key. | |
| 86 * @return {*} The property value or dictionary if it exists, otherwise | |
| 87 * undefined. | |
| 48 */ | 88 */ |
| 49 function getActiveDictionaryValue(data, dict, key) { | 89 function getManagedProperty(data, key) { |
| 50 if (!(dict in data)) | 90 while (true) { |
| 51 return undefined; | 91 var index = key.indexOf('.'); |
| 52 return getActiveValue(data[dict], key); | 92 if (index < 0) |
| 93 break; | |
| 94 var keyComponent = key.substr(0, index); | |
| 95 if (!(keyComponent in data)) | |
| 96 return undefined; | |
| 97 data = data[keyComponent]; | |
| 98 key = key.substr(index + 1); | |
| 99 } | |
| 100 return data[key]; | |
| 53 } | 101 } |
| 54 | 102 |
| 55 /** | 103 /** |
| 56 * Helper function to set hidden attribute for elements matching a selector. | 104 * Helper function to set hidden attribute for elements matching a selector. |
| 57 * @param {string} selector CSS selector for extracting a list of elements. | 105 * @param {string} selector CSS selector for extracting a list of elements. |
| 58 * @param {bool} hidden New hidden value. | 106 * @param {bool} hidden New hidden value. |
| 59 */ | 107 */ |
| 60 function updateHidden(selector, hidden) { | 108 function updateHidden(selector, hidden) { |
| 61 var elements = cr.doc.querySelectorAll(selector); | 109 var elements = cr.doc.querySelectorAll(selector); |
| 62 for (var i = 0, el; el = elements[i]; i++) { | 110 for (var i = 0, el; el = elements[i]; i++) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 return loadTimeData.getString('OncStateUnknown'); | 176 return loadTimeData.getString('OncStateUnknown'); |
| 129 } | 177 } |
| 130 | 178 |
| 131 /** | 179 /** |
| 132 * Returns the display name for the network represented by 'data'. | 180 * Returns the display name for the network represented by 'data'. |
| 133 * @param {Object} data The network ONC dictionary. | 181 * @param {Object} data The network ONC dictionary. |
| 134 */ | 182 */ |
| 135 function getNetworkName(data) { | 183 function getNetworkName(data) { |
| 136 if (data.type == 'Ethernet') | 184 if (data.type == 'Ethernet') |
| 137 return loadTimeData.getString('ethernetName'); | 185 return loadTimeData.getString('ethernetName'); |
| 138 return getActiveValue(data, 'Name'); | 186 return getManagedValue(data, 'Name'); |
| 139 } | 187 } |
| 140 | 188 |
| 141 ///////////////////////////////////////////////////////////////////////////// | 189 ///////////////////////////////////////////////////////////////////////////// |
| 142 // DetailsInternetPage class: | 190 // DetailsInternetPage class: |
| 143 | 191 |
| 144 /** | 192 /** |
| 145 * Encapsulated handling of ChromeOS internet details overlay page. | 193 * Encapsulated handling of ChromeOS internet details overlay page. |
| 146 * @constructor | 194 * @constructor |
| 147 */ | 195 */ |
| 148 function DetailsInternetPage() { | 196 function DetailsInternetPage() { |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { | 949 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { |
| 902 if (data.type == 'Ethernet') { | 950 if (data.type == 'Ethernet') { |
| 903 // Ethernet can never be connected or disconnected and can always be | 951 // Ethernet can never be connected or disconnected and can always be |
| 904 // configured (e.g. to set security). | 952 // configured (e.g. to set security). |
| 905 $('details-internet-login').hidden = true; | 953 $('details-internet-login').hidden = true; |
| 906 $('details-internet-disconnect').hidden = true; | 954 $('details-internet-disconnect').hidden = true; |
| 907 $('details-internet-configure').hidden = false; | 955 $('details-internet-configure').hidden = false; |
| 908 return; | 956 return; |
| 909 } | 957 } |
| 910 | 958 |
| 911 var connectState = getActiveValue(data, 'ConnectionState'); | 959 var connectState = getManagedValue(data, 'ConnectionState'); |
| 912 if (connectState == 'NotConnected') { | 960 if (connectState == 'NotConnected') { |
| 913 $('details-internet-login').hidden = false; | 961 $('details-internet-login').hidden = false; |
| 914 // Connecting to an unconfigured network might trigger certificate | 962 // Connecting to an unconfigured network might trigger certificate |
| 915 // installation UI. Until that gets handled here, always enable the | 963 // installation UI. Until that gets handled here, always enable the |
| 916 // Connect button. | 964 // Connect button. |
| 917 $('details-internet-login').disabled = false; | 965 $('details-internet-login').disabled = false; |
| 918 $('details-internet-disconnect').hidden = true; | 966 $('details-internet-disconnect').hidden = true; |
| 919 } else { | 967 } else { |
| 920 $('details-internet-login').hidden = true; | 968 $('details-internet-login').hidden = true; |
| 921 $('details-internet-disconnect').hidden = false; | 969 $('details-internet-disconnect').hidden = false; |
| 922 } | 970 } |
| 923 | 971 |
| 924 var connectable = getActiveValue(data, 'Connectable'); | 972 var connectable = getManagedValue(data, 'Connectable'); |
| 925 if (connectState != 'Connected' && | 973 if (connectState != 'Connected' && |
| 926 (!connectable || this.hasSecurity || | 974 (!connectable || this.hasSecurity || |
| 927 (data.type == 'Wimax' || data.type == 'VPN'))) { | 975 (data.type == 'Wimax' || data.type == 'VPN'))) { |
| 928 $('details-internet-configure').hidden = false; | 976 $('details-internet-configure').hidden = false; |
| 929 } else { | 977 } else { |
| 930 $('details-internet-configure').hidden = true; | 978 $('details-internet-configure').hidden = true; |
| 931 } | 979 } |
| 932 }; | 980 }; |
| 933 | 981 |
| 934 DetailsInternetPage.updateConnectionData = function(update) { | 982 DetailsInternetPage.updateConnectionData = function(update) { |
| 935 var detailsPage = DetailsInternetPage.getInstance(); | 983 var detailsPage = DetailsInternetPage.getInstance(); |
| 936 if (!detailsPage.visible) | 984 if (!detailsPage.visible) |
| 937 return; | 985 return; |
| 938 | 986 |
| 939 var data = $('connection-state').data; | 987 var data = $('connection-state').data; |
| 940 if (!data) | 988 if (!data) |
| 941 return; | 989 return; |
| 942 | 990 |
| 943 if (update.servicePath != data.servicePath) | 991 if (update.servicePath != data.servicePath) |
| 944 return; | 992 return; |
| 945 | 993 |
| 946 // Update our cached data object. | 994 // Update our cached data object. |
| 947 updateDataObject(data, update); | 995 updateDataObject(data, update); |
| 948 | 996 |
| 949 var connectionState = getActiveValue(data, 'ConnectionState'); | 997 var connectionState = getManagedValue(data, 'ConnectionState'); |
| 950 var connectionStateString = networkOncStateString(connectionState); | 998 var connectionStateString = networkOncStateString(connectionState); |
| 951 detailsPage.deviceConnected = data.deviceConnected; | 999 detailsPage.deviceConnected = data.deviceConnected; |
| 952 detailsPage.connected = connectionState == 'Connected'; | 1000 detailsPage.connected = connectionState == 'Connected'; |
| 953 $('connection-state').textContent = connectionStateString; | 1001 $('connection-state').textContent = connectionStateString; |
| 954 | 1002 |
| 955 this.updateConnectionButtonVisibilty(data); | 1003 this.updateConnectionButtonVisibilty(data); |
| 956 | 1004 |
| 957 if (data.type == 'WiFi') { | 1005 if (data.type == 'WiFi') { |
| 958 $('wifi-connection-state').textContent = connectionStateString; | 1006 $('wifi-connection-state').textContent = connectionStateString; |
| 959 } else if (data.type == 'Wimax') { | 1007 } else if (data.type == 'Wimax') { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 975 $('change-pin').hidden = !lockEnabled; | 1023 $('change-pin').hidden = !lockEnabled; |
| 976 } | 1024 } |
| 977 } | 1025 } |
| 978 | 1026 |
| 979 $('connection-state').data = data; | 1027 $('connection-state').data = data; |
| 980 }; | 1028 }; |
| 981 | 1029 |
| 982 DetailsInternetPage.showDetailedInfo = function(data) { | 1030 DetailsInternetPage.showDetailedInfo = function(data) { |
| 983 var detailsPage = DetailsInternetPage.getInstance(); | 1031 var detailsPage = DetailsInternetPage.getInstance(); |
| 984 | 1032 |
| 985 data.type = getActiveValue(data, 'Type'); // Get Active Type value. | 1033 data.type = getManagedValue(data, 'Type'); // Get Active Type value. |
| 986 | 1034 |
| 987 // Populate header | 1035 // Populate header |
| 988 $('network-details-title').textContent = getNetworkName(data); | 1036 $('network-details-title').textContent = getNetworkName(data); |
| 989 var connectionState = getActiveValue(data, 'ConnectionState'); | 1037 var connectionState = getManagedValue(data, 'ConnectionState'); |
| 990 var connectionStateString = networkOncStateString(connectionState); | 1038 var connectionStateString = networkOncStateString(connectionState); |
| 991 detailsPage.connected = connectionState == 'Connected'; | 1039 detailsPage.connected = connectionState == 'Connected'; |
| 992 $('network-details-subtitle-status').textContent = connectionStateString; | 1040 $('network-details-subtitle-status').textContent = connectionStateString; |
| 993 var typeKey = null; | 1041 var typeKey = null; |
| 994 switch (data.type) { | 1042 switch (data.type) { |
| 995 case 'Ethernet': | 1043 case 'Ethernet': |
| 996 typeKey = 'ethernetTitle'; | 1044 typeKey = 'ethernetTitle'; |
| 997 break; | 1045 break; |
| 998 case 'WiFi': | 1046 case 'WiFi': |
| 999 typeKey = 'wifiTitle'; | 1047 typeKey = 'wifiTitle'; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1123 nameServerModels.push({value: nameServersUser[i] || ''}); | 1171 nameServerModels.push({value: nameServersUser[i] || ''}); |
| 1124 | 1172 |
| 1125 $(data.nameServerType + '-dns-radio').checked = true; | 1173 $(data.nameServerType + '-dns-radio').checked = true; |
| 1126 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); | 1174 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); |
| 1127 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); | 1175 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); |
| 1128 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); | 1176 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); |
| 1129 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); | 1177 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); |
| 1130 | 1178 |
| 1131 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); | 1179 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); |
| 1132 | 1180 |
| 1133 var macAddress = getActiveValue(data, 'MacAddress'); | 1181 var macAddress = getManagedValue(data, 'MacAddress'); |
| 1134 if (macAddress) { | 1182 if (macAddress) { |
| 1135 $('hardware-address').textContent = macAddress; | 1183 $('hardware-address').textContent = macAddress; |
| 1136 $('hardware-address-row').style.display = 'table-row'; | 1184 $('hardware-address-row').style.display = 'table-row'; |
| 1137 } else { | 1185 } else { |
| 1138 // This is most likely a device without a hardware address. | 1186 // This is most likely a device without a hardware address. |
| 1139 $('hardware-address-row').style.display = 'none'; | 1187 $('hardware-address-row').style.display = 'none'; |
| 1140 } | 1188 } |
| 1141 | 1189 |
| 1142 var setOrHideParent = function(field, property) { | 1190 var setOrHideParent = function(field, property) { |
| 1143 if (property) { | 1191 if (property) { |
| 1144 $(field).textContent = property; | 1192 $(field).textContent = property; |
| 1145 $(field).parentElement.hidden = false; | 1193 $(field).parentElement.hidden = false; |
| 1146 } else { | 1194 } else { |
| 1147 $(field).parentElement.hidden = true; | 1195 $(field).parentElement.hidden = true; |
| 1148 } | 1196 } |
| 1149 }; | 1197 }; |
| 1150 | 1198 |
| 1151 var networkName = getNetworkName(data); | 1199 var networkName = getNetworkName(data); |
| 1152 | 1200 |
| 1153 // Signal strength as percentage (for WiFi and Wimax). | 1201 // Signal strength as percentage (for WiFi and Wimax). |
| 1154 var signalStrength; | 1202 var signalStrength; |
| 1155 if (data.type == 'WiFi' || data.type == 'Wimax') { | 1203 if (data.type == 'WiFi' || data.type == 'Wimax') { |
| 1156 signalStrength = | 1204 signalStrength = getManagedValue(data, data.type + '.SignalStrength'); |
| 1157 getActiveDictionaryValue(data, data.type, 'SignalStrength'); | |
| 1158 } | 1205 } |
| 1159 if (!signalStrength) | 1206 if (!signalStrength) |
| 1160 signalStrength = 0; | 1207 signalStrength = 0; |
| 1161 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1208 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
| 1162 var strengthString = strengthFormat.replace('$1', signalStrength); | 1209 var strengthString = strengthFormat.replace('$1', signalStrength); |
| 1163 | 1210 |
| 1164 detailsPage.type = data.type; | 1211 detailsPage.type = data.type; |
| 1165 if (data.type == 'WiFi') { | 1212 if (data.type == 'WiFi') { |
| 1166 assert(data.WiFi, 'WiFi network has no WiFi object' + networkName); | 1213 assert('WiFi' in data, 'WiFi network has no WiFi object' + networkName); |
| 1167 OptionsPage.showTab($('wifi-network-nav-tab')); | 1214 OptionsPage.showTab($('wifi-network-nav-tab')); |
| 1168 detailsPage.gsm = false; | 1215 detailsPage.gsm = false; |
| 1169 detailsPage.shared = data.shared; | 1216 detailsPage.shared = data.shared; |
| 1170 $('wifi-connection-state').textContent = connectionStateString; | 1217 $('wifi-connection-state').textContent = connectionStateString; |
| 1171 var ssid = getActiveDictionaryValue(data, 'WiFi', 'SSID'); | 1218 var ssid = getManagedValue(data, 'WiFi.SSID'); |
| 1172 $('wifi-ssid').textContent = ssid ? ssid : networkName; | 1219 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
| 1173 setOrHideParent('wifi-bssid', | 1220 setOrHideParent('wifi-bssid', getManagedValue(data, 'WiFi.BSSID')); |
| 1174 getActiveDictionaryValue(data, 'WiFi', 'BSSID')); | 1221 var security = getManagedValue(data, 'WiFi.Security'); |
| 1175 var security = getActiveDictionaryValue(data, 'WiFi', 'Security'); | |
| 1176 if (security == 'None') | 1222 if (security == 'None') |
| 1177 security = undefined; | 1223 security = undefined; |
| 1178 setOrHideParent('wifi-security', security); | 1224 setOrHideParent('wifi-security', security); |
| 1179 // Frequency is in MHz. | 1225 // Frequency is in MHz. |
| 1180 var frequency = getActiveDictionaryValue(data, 'WiFi', 'Frequency'); | 1226 var frequency = getManagedValue(data, 'WiFi.Frequency'); |
| 1181 if (!frequency) | 1227 if (!frequency) |
| 1182 frequency = 0; | 1228 frequency = 0; |
| 1183 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); | 1229 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); |
| 1184 frequencyFormat = frequencyFormat.replace('$1', frequency); | 1230 frequencyFormat = frequencyFormat.replace('$1', frequency); |
| 1185 $('wifi-frequency').textContent = frequencyFormat; | 1231 $('wifi-frequency').textContent = frequencyFormat; |
| 1186 $('wifi-signal-strength').textContent = strengthString; | 1232 $('wifi-signal-strength').textContent = strengthString; |
| 1187 setOrHideParent('wifi-hardware-address', | 1233 setOrHideParent('wifi-hardware-address', |
| 1188 getActiveValue(data, 'MacAddress')); | 1234 getManagedValue(data, 'MacAddress')); |
| 1189 detailsPage.showPreferred = data.remembered; | 1235 detailsPage.showPreferred = data.remembered; |
| 1190 $('prefer-network-wifi').checked = data.preferred.value; | 1236 var priority = getManagedValue(data, 'Priority'); |
| 1237 $('prefer-network-wifi').checked = priority > 0; | |
| 1191 $('prefer-network-wifi').disabled = !data.remembered; | 1238 $('prefer-network-wifi').disabled = !data.remembered; |
| 1192 $('auto-connect-network-wifi').checked = | 1239 $('auto-connect-network-wifi').checked = |
| 1193 getActiveValue(data, 'AutoConnect'); | 1240 getManagedValue(data, 'AutoConnect'); |
| 1194 $('auto-connect-network-wifi').disabled = !data.remembered; | 1241 $('auto-connect-network-wifi').disabled = !data.remembered; |
| 1195 detailsPage.hasSecurity = security != undefined; | 1242 detailsPage.hasSecurity = security != undefined; |
| 1196 } else if (data.type == 'Wimax') { | 1243 } else if (data.type == 'Wimax') { |
| 1197 assert(data.Wimax, 'Wimax network has no Wimax object' + networkName); | 1244 assert('Wimax' in data, |
| 1245 'Wimax network has no Wimax object' + networkName); | |
| 1198 OptionsPage.showTab($('wimax-network-nav-tab')); | 1246 OptionsPage.showTab($('wimax-network-nav-tab')); |
| 1199 detailsPage.gsm = false; | 1247 detailsPage.gsm = false; |
| 1200 detailsPage.shared = data.shared; | 1248 detailsPage.shared = data.shared; |
| 1201 detailsPage.showPreferred = data.remembered; | 1249 detailsPage.showPreferred = data.remembered; |
| 1202 $('wimax-connection-state').textContent = connectionStateString; | 1250 $('wimax-connection-state').textContent = connectionStateString; |
| 1203 $('auto-connect-network-wimax').checked = | 1251 $('auto-connect-network-wimax').checked = |
| 1204 getActiveValue(data, 'AutoConnect'); | 1252 getManagedValue(data, 'AutoConnect'); |
| 1205 $('auto-connect-network-wimax').disabled = !data.remembered; | 1253 $('auto-connect-network-wimax').disabled = !data.remembered; |
| 1206 var identity; | 1254 var identity; |
| 1207 if (data.Wimax.EAP) | 1255 if (data.Wimax.EAP) |
| 1208 identity = getActiveValue(data.Wimax.EAP, 'Identity'); | 1256 identity = getManagedValue(data.Wimax.EAP, 'Identity'); |
| 1209 setOrHideParent('wimax-eap-identity', identity); | 1257 setOrHideParent('wimax-eap-identity', identity); |
| 1210 $('wimax-signal-strength').textContent = strengthString; | 1258 $('wimax-signal-strength').textContent = strengthString; |
| 1211 } else if (data.type == 'Cellular') { | 1259 } else if (data.type == 'Cellular') { |
| 1212 assert(data.Cellular, | 1260 assert('Cellular' in data, |
| 1213 'Cellular network has no Cellular object' + networkName); | 1261 'Cellular network has no Cellular object' + networkName); |
| 1214 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1262 OptionsPage.showTab($('cellular-conn-nav-tab')); |
| 1215 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1263 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
| 1216 var carrierSelector = $('select-carrier'); | 1264 var carrierSelector = $('select-carrier'); |
| 1217 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1265 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
| 1218 carrierSelector.options.length = 0; | 1266 carrierSelector.options.length = 0; |
| 1219 for (var i = 0; i < data.carriers.length; ++i) { | 1267 for (var i = 0; i < data.carriers.length; ++i) { |
| 1220 var option = document.createElement('option'); | 1268 var option = document.createElement('option'); |
| 1221 option.textContent = data.carriers[i]; | 1269 option.textContent = data.carriers[i]; |
| 1222 carrierSelector.add(option); | 1270 carrierSelector.add(option); |
| 1223 } | 1271 } |
| 1224 carrierSelector.selectedIndex = data.currentCarrierIndex; | 1272 carrierSelector.selectedIndex = data.currentCarrierIndex; |
| 1225 } else { | 1273 } else { |
| 1226 $('service-name').textContent = networkName; | 1274 $('service-name').textContent = networkName; |
| 1227 } | 1275 } |
| 1228 | 1276 |
| 1229 $('network-technology').textContent = | 1277 $('network-technology').textContent = |
| 1230 getActiveDictionaryValue(data, 'Cellular', 'NetworkTechnology'); | 1278 getManagedValue(data, 'Cellular.NetworkTechnology'); |
| 1231 $('activation-state').textContent = data.activationState; | 1279 $('activation-state').textContent = data.activationState; |
| 1232 $('roaming-state').textContent = data.roamingState; | 1280 $('roaming-state').textContent = data.roamingState; |
| 1233 $('restricted-pool').textContent = data.restrictedPool; | 1281 $('restricted-pool').textContent = data.restrictedPool; |
| 1234 $('error-state').textContent = data.errorMessage; | 1282 $('error-state').textContent = data.errorMessage; |
| 1235 $('manufacturer').textContent = | 1283 $('manufacturer').textContent = |
| 1236 getActiveDictionaryValue(data, 'Cellular', 'Manufacturer'); | 1284 getManagedValue(data, 'Cellular.Manufacturer'); |
| 1237 $('model-id').textContent = | 1285 $('model-id').textContent = getManagedValue(data, 'Cellular.ModelID'); |
| 1238 getActiveDictionaryValue(data, 'Cellular', 'ModelID'); | |
| 1239 $('firmware-revision').textContent = | 1286 $('firmware-revision').textContent = |
| 1240 getActiveDictionaryValue(data, 'Cellular', 'FirmwareRevision'); | 1287 getManagedValue(data, 'Cellular.FirmwareRevision'); |
| 1241 $('hardware-revision').textContent = | 1288 $('hardware-revision').textContent = |
| 1242 getActiveDictionaryValue(data, 'Cellular', 'HardwareRevision'); | 1289 getManagedValue(data, 'Cellular.HardwareRevision'); |
| 1243 $('mdn').textContent = getActiveDictionaryValue(data, 'Cellular', 'MDN'); | 1290 $('mdn').textContent = getManagedValue(data, 'Cellular.MDN'); |
| 1244 | 1291 |
| 1245 // Show ServingOperator properties only if available. | 1292 // Show ServingOperator properties only if available. |
| 1246 if (data.Cellular.ServingOperator) { | 1293 var servingOperatorName = |
| 1247 $('operator-name').textContent = | 1294 getManagedValue(data, 'Cellular.ServingOperator.Name'); |
| 1248 getActiveValue(data.Cellular.ServingOperator, 'Name'); | 1295 var servingOperatorCode = |
| 1249 $('operator-code').textContent = | 1296 getManagedValue(data, 'Cellular.ServingOperator.Code'); |
| 1250 getActiveValue(data.Cellular.ServingOperator, 'Code'); | 1297 if (servingOperatorName != undefined && |
| 1298 servingOperatorCode != undefined) { | |
| 1299 $('operator-name').textContent = servingOperatorName; | |
| 1300 $('operator-code').textContent = servingOperatorCode; | |
| 1251 } else { | 1301 } else { |
| 1252 $('operator-name').parentElement.hidden = true; | 1302 $('operator-name').parentElement.hidden = true; |
| 1253 $('operator-code').parentElement.hidden = true; | 1303 $('operator-code').parentElement.hidden = true; |
| 1254 } | 1304 } |
| 1255 // Make sure that GSM/CDMA specific properties that shouldn't be hidden | 1305 // Make sure that GSM/CDMA specific properties that shouldn't be hidden |
| 1256 // are visible. | 1306 // are visible. |
| 1257 updateHidden('#details-internet-page .gsm-only', false); | 1307 updateHidden('#details-internet-page .gsm-only', false); |
| 1258 updateHidden('#details-internet-page .cdma-only', false); | 1308 updateHidden('#details-internet-page .cdma-only', false); |
| 1259 | 1309 |
| 1260 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. | 1310 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. |
| 1261 setOrHideParent('esn', getActiveDictionaryValue(data, 'Cellular', 'ESN')); | 1311 setOrHideParent('esn', getManagedValue(data, 'Cellular.ESN')); |
| 1262 setOrHideParent( | 1312 setOrHideParent('imei', getManagedValue(data, 'Cellular.IMEI')); |
| 1263 'imei', getActiveDictionaryValue(data, 'Cellular', 'IMEI')); | 1313 setOrHideParent('meid', getManagedValue(data, 'Cellular.MEID')); |
| 1264 setOrHideParent( | 1314 setOrHideParent('min', getManagedValue(data, 'Cellular.MIN')); |
| 1265 'meid', getActiveDictionaryValue(data, 'Cellular', 'MEID')); | 1315 setOrHideParent('prl-version', |
| 1266 setOrHideParent('min', getActiveDictionaryValue(data, 'Cellular', 'MIN')); | 1316 getManagedValue(data, 'Cellular.PRLVersion')); |
| 1267 setOrHideParent( | |
| 1268 'prl-version', | |
| 1269 getActiveDictionaryValue(data, 'Cellular', 'PRLVersion')); | |
| 1270 | 1317 |
| 1271 var family = getActiveDictionaryValue(data, 'Cellular', 'GSM'); | 1318 var family = getManagedValue(data, 'Cellular.GSM'); |
| 1272 detailsPage.gsm = family == 'GSM'; | 1319 detailsPage.gsm = family == 'GSM'; |
| 1273 if (detailsPage.gsm) { | 1320 if (detailsPage.gsm) { |
| 1274 $('iccid').textContent = | 1321 $('iccid').textContent = getManagedValue(data, 'Cellular.ICCID'); |
| 1275 getActiveDictionaryValue(data, 'Cellular', 'ICCID'); | 1322 $('imsi').textContent = getManagedValue(data, 'Cellular.IMSI'); |
| 1276 $('imsi').textContent = | |
| 1277 getActiveDictionaryValue(data, 'Cellular', 'IMSI'); | |
| 1278 | 1323 |
| 1279 var apnSelector = $('select-apn'); | 1324 var apnSelector = $('select-apn'); |
| 1280 // Clear APN lists, keep only last element that "other". | 1325 // Clear APN lists, keep only last element that "other". |
| 1281 while (apnSelector.length != 1) | 1326 while (apnSelector.length != 1) |
| 1282 apnSelector.remove(0); | 1327 apnSelector.remove(0); |
| 1283 var otherOption = apnSelector[0]; | 1328 var otherOption = apnSelector[0]; |
| 1284 data.selectedApn = -1; | 1329 data.selectedApn = -1; |
| 1285 data.userApnIndex = -1; | 1330 data.userApnIndex = -1; |
| 1286 var apnList = data.providerApnList.value; | 1331 var apnList = data.providerApnList.value; |
| 1287 for (var i = 0; i < apnList.length; i++) { | 1332 for (var i = 0; i < apnList.length; i++) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1317 } | 1362 } |
| 1318 apnSelector.selectedIndex = data.selectedApn; | 1363 apnSelector.selectedIndex = data.selectedApn; |
| 1319 updateHidden('.apn-list-view', false); | 1364 updateHidden('.apn-list-view', false); |
| 1320 updateHidden('.apn-details-view', true); | 1365 updateHidden('.apn-details-view', true); |
| 1321 // TODO(stevenjb): Used managed properties for policy controlled value. | 1366 // TODO(stevenjb): Used managed properties for policy controlled value. |
| 1322 var lockEnabled = data.simCardLockEnabled.value; | 1367 var lockEnabled = data.simCardLockEnabled.value; |
| 1323 $('sim-card-lock-enabled').checked = lockEnabled; | 1368 $('sim-card-lock-enabled').checked = lockEnabled; |
| 1324 $('change-pin').hidden = !lockEnabled; | 1369 $('change-pin').hidden = !lockEnabled; |
| 1325 } | 1370 } |
| 1326 $('auto-connect-network-cellular').checked = | 1371 $('auto-connect-network-cellular').checked = |
| 1327 getActiveValue(data, 'AutoConnect'); | 1372 getManagedValue(data, 'AutoConnect'); |
| 1328 $('auto-connect-network-cellular').disabled = false; | 1373 $('auto-connect-network-cellular').disabled = false; |
| 1329 | 1374 |
| 1330 $('buyplan-details').hidden = !data.showBuyButton; | 1375 $('buyplan-details').hidden = !data.showBuyButton; |
| 1331 $('view-account-details').hidden = !data.showViewAccountButton; | 1376 $('view-account-details').hidden = !data.showViewAccountButton; |
| 1332 $('activate-details').hidden = !data.showActivateButton; | 1377 $('activate-details').hidden = !data.showActivateButton; |
| 1333 if (data.showActivateButton) { | 1378 if (data.showActivateButton) { |
| 1334 $('details-internet-login').hidden = true; | 1379 $('details-internet-login').hidden = true; |
| 1335 } | 1380 } |
| 1336 } else if (data.type == 'VPN') { | 1381 } else if (data.type == 'VPN') { |
| 1337 OptionsPage.showTab($('vpn-nav-tab')); | 1382 OptionsPage.showTab($('vpn-nav-tab')); |
| 1338 detailsPage.gsm = false; | 1383 detailsPage.gsm = false; |
| 1339 $('inet-service-name').textContent = networkName; | 1384 $('inet-service-name').textContent = networkName; |
| 1340 $('inet-provider-type').textContent = data.providerType; | 1385 $('inet-provider-type').textContent = |
| 1341 $('inet-username').textContent = data.username; | 1386 getManagedValue(data, 'VPN.Type', GetManagedTypes.TRANSLATED); |
| 1387 var providerType = | |
| 1388 getManagedValue(data, 'VPN.Type', GetManagedTypes.ACTIVE); | |
| 1389 var providerKey = 'VPN.' + providerType; | |
| 1390 $('inet-username').textContent = | |
| 1391 getManagedValue(data, providerKey + '.Username'); | |
| 1342 var inetServerHostname = $('inet-server-hostname'); | 1392 var inetServerHostname = $('inet-server-hostname'); |
| 1343 inetServerHostname.value = data.serverHostname.value; | 1393 inetServerHostname.value = getManagedValue(data, 'VPN.Host'); |
| 1344 inetServerHostname.resetHandler = function() { | 1394 inetServerHostname.resetHandler = function() { |
| 1345 PageManager.hideBubble(); | 1395 PageManager.hideBubble(); |
| 1346 inetServerHostname.value = data.serverHostname.recommendedValue; | 1396 var recommended = |
| 1397 getManagedValue(data, 'VPN.Host', GetManagedTypes.RECOMMENDED); | |
| 1398 if (recommended != undefined) | |
| 1399 inetServerHostname.value = recommended; | |
| 1347 }; | 1400 }; |
| 1348 $('auto-connect-network-vpn').checked = | 1401 $('auto-connect-network-vpn').checked = |
| 1349 getActiveValue(data, 'AutoConnect'); | 1402 getManagedValue(data, 'AutoConnect'); |
| 1350 $('auto-connect-network-vpn').disabled = false; | 1403 $('auto-connect-network-vpn').disabled = false; |
| 1351 } else { | 1404 } else { |
| 1352 OptionsPage.showTab($('internet-nav-tab')); | 1405 OptionsPage.showTab($('internet-nav-tab')); |
| 1353 } | 1406 } |
| 1354 | 1407 |
| 1355 // Update controlled option indicators. | 1408 // Update controlled option indicators. |
| 1356 var indicators = cr.doc.querySelectorAll( | 1409 var indicators = cr.doc.querySelectorAll( |
| 1357 '#details-internet-page .controlled-setting-indicator'); | 1410 '#details-internet-page .controlled-setting-indicator'); |
| 1358 for (var i = 0; i < indicators.length; i++) { | 1411 for (var i = 0; i < indicators.length; i++) { |
| 1359 var attributeName = | 1412 var managed = indicators[i].hasAttribute('managed'); |
| 1360 indicators[i].hasAttribute('managed') ? 'managed' : 'data'; | 1413 var attributeName = managed ? 'managed' : 'data'; |
| 1361 var propName = indicators[i].getAttribute(attributeName); | 1414 var propName = indicators[i].getAttribute(attributeName); |
| 1362 if (!propName || !data[propName]) | 1415 if (!propName) |
| 1416 continue; | |
| 1417 var propValue = | |
| 1418 managed ? getManagedProperty(data, propName) : data[propName]; | |
| 1419 if (propValue == undefined) | |
| 1363 continue; | 1420 continue; |
| 1364 var event; | 1421 var event; |
| 1365 if (attributeName == 'managed') | 1422 if (managed) |
| 1366 event = detailsPage.createManagedEvent_(propName, data[propName]); | 1423 event = detailsPage.createManagedEvent_(propName, propValue); |
| 1367 else | 1424 else |
| 1368 event = detailsPage.createControlledEvent_(propName, data[propName]); | 1425 event = detailsPage.createControlledEvent_(propName, propValue); |
| 1369 indicators[i].handlePrefChange(event); | 1426 indicators[i].handlePrefChange(event); |
| 1370 var forElement = $(indicators[i].getAttribute('for')); | 1427 var forElement = $(indicators[i].getAttribute('for')); |
| 1371 if (forElement) { | 1428 if (forElement) { |
| 1372 if (event.value.controlledBy == 'policy') | 1429 if (event.value.controlledBy == 'policy') |
| 1373 forElement.disabled = true; | 1430 forElement.disabled = true; |
| 1374 if (forElement.resetHandler) | 1431 if (forElement.resetHandler) |
| 1375 indicators[i].resetHandler = forElement.resetHandler; | 1432 indicators[i].resetHandler = forElement.resetHandler; |
| 1376 } | 1433 } |
| 1377 } | 1434 } |
| 1378 | 1435 |
| 1379 detailsPage.updateControls(); | 1436 detailsPage.updateControls(); |
| 1380 | 1437 |
| 1381 // Don't show page name in address bar and in history to prevent people | 1438 // Don't show page name in address bar and in history to prevent people |
| 1382 // navigate here by hand and solve issue with page session restore. | 1439 // navigate here by hand and solve issue with page session restore. |
| 1383 PageManager.showPageByName('detailsInternetPage', false); | 1440 PageManager.showPageByName('detailsInternetPage', false); |
| 1384 }; | 1441 }; |
| 1385 | 1442 |
| 1386 return { | 1443 return { |
| 1387 DetailsInternetPage: DetailsInternetPage | 1444 DetailsInternetPage: DetailsInternetPage |
| 1388 }; | 1445 }; |
| 1389 }); | 1446 }); |
| OLD | NEW |