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 /** @const */ var GoogleNameServers = '8.8.4.4,8.8.8.8'; | |
19 | |
18 var GetManagedTypes = { | 20 var GetManagedTypes = { |
19 ACTIVE: 0, | 21 ACTIVE: 0, |
20 TRANSLATED: 1, | 22 TRANSLATED: 1, |
21 RECOMMENDED: 2 | 23 RECOMMENDED: 2 |
22 }; | 24 }; |
23 | 25 |
24 /** | 26 /** |
25 * Gets the value of a property from a dictionary |data| that includes ONC | 27 * Gets the value of a property from a dictionary |data| that includes ONC |
26 * managed properties, e.g. getManagedValue(data, 'Name'). See notes for | 28 * managed properties, e.g. getManagedValue(data, 'Name'). See notes for |
27 * getManagedProperty. | 29 * getManagedProperty. |
28 * @param {object} data The properties dictionary. | 30 * @param {object} data The properties dictionary. |
29 * @param {string} key The property key. | 31 * @param {string} key The property key. |
30 * @param {string} type (Optional) The type of property to get as defined in | 32 * @param {string} type (Optional) The type of property to get as defined in |
31 * GetManagedTypes: | 33 * GetManagedTypes: |
32 * 'ACTIVE' (default) - gets the active value | 34 * 'ACTIVE' (default) - gets the active value |
33 * 'TRANSLATED' - gets the traslated or active value | 35 * 'TRANSLATED' - gets the traslated or active value |
34 * 'RECOMMENDED' - gets the recommended value | 36 * 'RECOMMENDED' - gets the recommended value |
35 * @return {*} The property value or undefined. | 37 * @return {*} The property value or undefined. |
36 */ | 38 */ |
37 function getManagedValue(data, key, type) { | 39 function getManagedValue(data, key, type) { |
38 var property = getManagedProperty(data, key); | 40 var property = getManagedProperty(data, key); |
39 if (Array.isArray(property) || typeof property != 'object') | 41 if (Array.isArray(property) || typeof property != 'object') |
40 return property; | 42 return property; |
41 if (type == GetManagedTypes.RECOMMENDED) | 43 if (type == GetManagedTypes.RECOMMENDED) |
42 return getRecommendedValue(property); | 44 return getRecommendedValue(property); |
43 if (type == GetManagedTypes.TRANSLATED && 'Translated' in property) | 45 if (type == GetManagedTypes.TRANSLATED && 'Translated' in property) |
44 return property['Translated']; | 46 return property['Translated']; |
45 // Otherwise get the Active value (defalt behavior). | 47 // Otherwise get the Active value (default behavior). |
46 if ('Active' in property) | 48 if ('Active' in property) |
47 return property['Active']; | 49 return property['Active']; |
48 // If no Active value is defined, return the effective value if present. | 50 // If no Active value is defined, return the effective value if present. |
49 var effective = getEffectiveValue(property); | 51 var effective = getEffectiveValue(property); |
50 if (effective != undefined) | 52 if (effective != undefined) |
51 return effective; | 53 return effective; |
52 // Otherwise this is an Object but not a Managed one. | 54 // Otherwise this is an Object but not a Managed one. |
53 return property; | 55 return property; |
54 } | 56 } |
55 | 57 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 /** | 205 /** |
204 * Returns the display name for the network represented by 'data'. | 206 * Returns the display name for the network represented by 'data'. |
205 * @param {Object} data The network ONC dictionary. | 207 * @param {Object} data The network ONC dictionary. |
206 */ | 208 */ |
207 function getNetworkName(data) { | 209 function getNetworkName(data) { |
208 if (data.type == 'Ethernet') | 210 if (data.type == 'Ethernet') |
209 return loadTimeData.getString('ethernetName'); | 211 return loadTimeData.getString('ethernetName'); |
210 return getManagedValue(data, 'Name'); | 212 return getManagedValue(data, 'Name'); |
211 } | 213 } |
212 | 214 |
215 /** | |
216 * Returns the netmask as a string for a given prefix length. | |
217 * @param {string} prefixLength The ONC routing prefix length. | |
218 * @return {string} The corresponding netmask. | |
219 */ | |
220 function PrefixLengthToNetmask(prefixLength) { | |
221 var netmask = ''; | |
222 // Return the empty string for invalid inputs. | |
223 if (prefixLength < 0 || prefixLength > 32) | |
224 return netmask; | |
225 for (var i = 0; i < 4; ++i) { | |
226 var remainder = 8; | |
227 if (prefixLength >= 8) { | |
228 prefixLength -= 8; | |
229 } else { | |
230 remainder = prefixLength; | |
231 prefixLength = 0; | |
232 } | |
233 if (i > 0) | |
234 netmask += '.'; | |
235 var value = | |
236 remainder == 0 ? 0 : ((2 << (remainder - 1)) - 1) << (8 - remainder); | |
237 netmask += value; | |
238 } | |
239 return netmask; | |
240 } | |
241 | |
213 ///////////////////////////////////////////////////////////////////////////// | 242 ///////////////////////////////////////////////////////////////////////////// |
214 // DetailsInternetPage class: | 243 // DetailsInternetPage class: |
215 | 244 |
216 /** | 245 /** |
217 * Encapsulated handling of ChromeOS internet details overlay page. | 246 * Encapsulated handling of ChromeOS internet details overlay page. |
218 * @constructor | 247 * @constructor |
219 */ | 248 */ |
220 function DetailsInternetPage() { | 249 function DetailsInternetPage() { |
221 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); | 250 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); |
222 } | 251 } |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1124 detailsPage.showProxy = true; | 1153 detailsPage.showProxy = true; |
1125 chrome.send('selectNetwork', [data.servicePath]); | 1154 chrome.send('selectNetwork', [data.servicePath]); |
1126 } else { | 1155 } else { |
1127 detailsPage.showProxy = false; | 1156 detailsPage.showProxy = false; |
1128 } | 1157 } |
1129 $('connection-state').textContent = connectionStateString; | 1158 $('connection-state').textContent = connectionStateString; |
1130 var restricted = getManagedValue(data, 'Restricted'); | 1159 var restricted = getManagedValue(data, 'Restricted'); |
1131 var restrictedString = | 1160 var restrictedString = |
1132 loadTimeData.getString(restricted ? 'restrictedYes' : 'restrictedNo'); | 1161 loadTimeData.getString(restricted ? 'restrictedYes' : 'restrictedNo'); |
1133 | 1162 |
1134 var ipAutoConfig = data.ipAutoConfig ? 'automatic' : 'user'; | 1163 var ipAutoConfig = 'automatic'; |
1135 $('ip-automatic-configuration-checkbox').checked = data.ipAutoConfig; | 1164 var staticIpconfig = getManagedValue(data, 'StaticIPConfig'); |
1165 if (staticIpconfig && Object.keys(staticIpconfig).length > 0) | |
pneubeck (no reviews)
2014/09/03 15:14:28
maybe add a comment that explains what the intenti
stevenjb
2014/09/03 21:28:06
Done.
| |
1166 ipAutoConfig = 'user'; | |
1167 $('ip-automatic-configuration-checkbox').checked = ipAutoConfig; | |
pneubeck (no reviews)
2014/09/03 15:14:28
before this was assigned a boolean. Not sure what
stevenjb
2014/09/03 21:28:05
Good catch. Done.
| |
1136 var inetAddress = {autoConfig: ipAutoConfig}; | 1168 var inetAddress = {autoConfig: ipAutoConfig}; |
1137 var inetNetmask = {autoConfig: ipAutoConfig}; | 1169 var inetNetmask = {autoConfig: ipAutoConfig}; |
1138 var inetGateway = {autoConfig: ipAutoConfig}; | 1170 var inetGateway = {autoConfig: ipAutoConfig}; |
1139 | 1171 |
1140 if (data.ipconfig.value) { | 1172 var inetNameServers = ''; |
1141 inetAddress.automatic = data.ipconfig.value.address; | 1173 var nameServerType = 'automatic'; |
1142 inetAddress.value = data.ipconfig.value.address; | 1174 |
1143 inetNetmask.automatic = data.ipconfig.value.netmask; | 1175 if ('IPConfigs' in data) { |
1144 inetNetmask.value = data.ipconfig.value.netmask; | 1176 var ipconfigList = getManagedValue(data, 'IPConfigs'); |
1145 inetGateway.automatic = data.ipconfig.value.gateway; | 1177 for (var i = 0; i < ipconfigList.length; ++i) { |
1146 inetGateway.value = data.ipconfig.value.gateway; | 1178 var ipconfig = ipconfigList[i]; |
1147 if (data.ipconfig.value.webProxyAutoDiscoveryUrl) { | 1179 var type = ipconfig['Type']; |
1148 $('web-proxy-auto-discovery').hidden = false; | 1180 if (type != 'IPv4') { |
1149 $('web-proxy-auto-discovery-url').value = | 1181 // TODO(stevenjb): Handle IPv6 properties. |
1150 data.ipconfig.value.webProxyAutoDiscoveryUrl; | 1182 continue; |
1183 } | |
1184 inetAddress.automatic = ipconfig['IPAddress']; | |
1185 inetAddress.value = ipconfig['IPAddress']; | |
1186 var netmask = PrefixLengthToNetmask(ipconfig['RoutingPrefix']); | |
1187 inetNetmask.automatic = netmask; | |
1188 inetNetmask.value = netmask; | |
1189 inetGateway.automatic = ipconfig['Gateway']; | |
1190 inetGateway.value = ipconfig['Gateway']; | |
1191 if ('WebProxyAutoDiscoveryUrl' in ipconfig) { | |
1192 $('web-proxy-auto-discovery').hidden = false; | |
1193 $('web-proxy-auto-discovery-url').value = | |
1194 ipconfig['WebProxyAutoDiscoveryUrl']; | |
1195 } | |
1196 if ('NameServers' in ipconfig) | |
1197 inetNameServers = ipconfig['NameServers']; | |
1198 break; // Use the first IPv4 entry. | |
1151 } | 1199 } |
1152 } | 1200 } |
1153 | 1201 |
1154 // Override the "automatic" values with the real saved DHCP values, | 1202 // Override the "automatic" values with the real saved DHCP values, |
1155 // if they are set. | 1203 // if they are set. |
1156 if (data.savedIP.address) { | 1204 var savedNameServers; |
1157 inetAddress.automatic = data.savedIP.address; | 1205 if ('SavedIPConfig' in data) { |
1158 inetAddress.value = data.savedIP.address; | 1206 var savedIpAddress = getManagedValue(data, 'SavedIPConfig.IPAddress'); |
1159 } | 1207 if (savedIpAddress != undefined) { |
1160 if (data.savedIP.netmask) { | 1208 inetAddress.automatic = savedIpAddress; |
1161 inetNetmask.automatic = data.savedIP.netmask; | 1209 inetAddress.value = savedIpAddress; |
1162 inetNetmask.value = data.savedIP.netmask; | 1210 } |
1163 } | 1211 var savedPrefix = getManagedValue(data, 'SavedIPConfig.RoutingPrefix'); |
1164 if (data.savedIP.gateway) { | 1212 if (savedPrefix != undefined) { |
1165 inetGateway.automatic = data.savedIP.gateway; | 1213 var savedNetmask = PrefixLengthToNetmask(savedPrefix); |
1166 inetGateway.value = data.savedIP.gateway; | 1214 inetNetmask.automatic = savedNetmask; |
1215 inetNetmask.value = savedNetmask; | |
1216 } | |
1217 var savedGateway = getManagedValue(data, 'SavedIPConfig.Gateway'); | |
1218 if (savedGateway != undefined) { | |
1219 inetGateway.automatic = savedGateway; | |
1220 inetGateway.value = savedGateway; | |
1221 } | |
1222 savedNameServers = getManagedValue(data, 'SavedIPConfig.NameServers'); | |
1167 } | 1223 } |
1168 | 1224 |
1169 if (ipAutoConfig == 'user') { | 1225 var staticNameServers; |
1170 if (data.staticIP.value.address) { | 1226 if (ipAutoConfig == 'user' && 'StaticIPConfig' in data) { |
pneubeck (no reviews)
2014/09/03 15:14:28
optional nit:
second check is redundant. ipAutoCon
stevenjb
2014/09/03 21:28:05
Done.
| |
1171 inetAddress.value = data.staticIP.value.address; | 1227 var staticIpAddress = getManagedValue(data, 'StaticIPConfig.IPAddress'); |
1172 inetAddress.user = data.staticIP.value.address; | 1228 if (staticIpAddress != undefined) { |
1229 inetAddress.user = staticIpAddress; | |
1230 inetAddress.value = staticIpAddress; | |
1173 } | 1231 } |
1174 if (data.staticIP.value.netmask) { | 1232 var staticPrefix = getManagedValue(data, 'StaticIPConfig.RoutingPrefix'); |
1175 inetNetmask.value = data.staticIP.value.netmask; | 1233 if (staticPrefix != undefined) { |
1176 inetNetmask.user = data.staticIP.value.netmask; | 1234 var staticNetmask = PrefixLengthToNetmask(staticPrefix); |
1235 inetNetmask.user = staticNetmask; | |
1236 inetNetmask.value = staticNetmask; | |
1177 } | 1237 } |
1178 if (data.staticIP.value.gateway) { | 1238 var staticGateway = getManagedValue(data, 'StaticIPConfig.Gateway'); |
1179 inetGateway.value = data.staticIP.value.gateway; | 1239 if (staticGateway != undefined) { |
1180 inetGateway.user = data.staticIP.value.gateway; | 1240 inetGateway.user = staticGateway; |
1241 inetGateway.value = staticGateway; | |
1181 } | 1242 } |
1243 staticNameServers = getManagedValue(data, 'StaticIPConfig.NameServers'); | |
1244 if (staticNameServers == inetNameServers) | |
pneubeck (no reviews)
2014/09/03 15:14:28
note that this comparison fails if the order of th
stevenjb
2014/09/03 21:28:06
Hmm. This should be the same as the existing C++ l
| |
1245 nameServerType = 'user'; | |
1182 } | 1246 } |
1183 | 1247 |
1248 if (inetNameServers == GoogleNameServers) | |
1249 nameServerType = 'google'; | |
1250 | |
1184 var configureAddressField = function(field, model) { | 1251 var configureAddressField = function(field, model) { |
1185 IPAddressField.decorate(field); | 1252 IPAddressField.decorate(field); |
1186 field.model = model; | 1253 field.model = model; |
1187 field.editable = model.autoConfig == 'user'; | 1254 field.editable = model.autoConfig == 'user'; |
1188 }; | 1255 }; |
1189 | 1256 |
1190 configureAddressField($('ip-address'), inetAddress); | 1257 configureAddressField($('ip-address'), inetAddress); |
1191 configureAddressField($('ip-netmask'), inetNetmask); | 1258 configureAddressField($('ip-netmask'), inetNetmask); |
1192 configureAddressField($('ip-gateway'), inetGateway); | 1259 configureAddressField($('ip-gateway'), inetGateway); |
1193 | 1260 |
1194 var inetNameServers = ''; | 1261 if (savedNameServers) |
1195 if (data.ipconfig.value && data.ipconfig.value.nameServers) { | 1262 $('automatic-dns-display').textContent = savedNameServers; |
1196 inetNameServers = data.ipconfig.value.nameServers; | 1263 else |
1197 $('automatic-dns-display').textContent = inetNameServers; | 1264 $('automatic-dns-display').textContent = inetNameServers; |
1198 } | |
1199 | 1265 |
1200 if (data.savedIP && data.savedIP.nameServers) | 1266 $('google-dns-display').textContent = GoogleNameServers; |
1201 $('automatic-dns-display').textContent = data.savedIP.nameServers; | |
1202 | |
1203 if (data.nameServersGoogle) | |
1204 $('google-dns-display').textContent = data.nameServersGoogle; | |
1205 | 1267 |
1206 var nameServersUser = []; | 1268 var nameServersUser = []; |
1207 if (data.staticIP.value.nameServers) | 1269 if (staticNameServers != undefined) |
1208 nameServersUser = data.staticIP.value.nameServers.split(','); | 1270 nameServersUser = staticNameServers.split(','); |
1209 | 1271 |
1210 var nameServerModels = []; | 1272 var nameServerModels = []; |
1211 for (var i = 0; i < 4; ++i) | 1273 for (var i = 0; i < 4; ++i) |
1212 nameServerModels.push({value: nameServersUser[i] || ''}); | 1274 nameServerModels.push({value: nameServersUser[i] || ''}); |
1213 | 1275 |
1214 $(data.nameServerType + '-dns-radio').checked = true; | 1276 $(nameServerType + '-dns-radio').checked = true; |
1215 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); | 1277 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); |
1216 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); | 1278 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); |
1217 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); | 1279 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); |
1218 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); | 1280 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); |
1219 | 1281 |
1220 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); | 1282 DetailsInternetPage.updateNameServerDisplay(nameServerType); |
1221 | 1283 |
1222 var macAddress = getManagedValue(data, 'MacAddress'); | 1284 var macAddress = getManagedValue(data, 'MacAddress'); |
1223 if (macAddress) { | 1285 if (macAddress) { |
1224 $('hardware-address').textContent = macAddress; | 1286 $('hardware-address').textContent = macAddress; |
1225 $('hardware-address-row').style.display = 'table-row'; | 1287 $('hardware-address-row').style.display = 'table-row'; |
1226 } else { | 1288 } else { |
1227 // This is most likely a device without a hardware address. | 1289 // This is most likely a device without a hardware address. |
1228 $('hardware-address-row').style.display = 'none'; | 1290 $('hardware-address-row').style.display = 'none'; |
1229 } | 1291 } |
1230 | 1292 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 'Wimax network has no Wimax object' + networkName); | 1349 'Wimax network has no Wimax object' + networkName); |
1288 OptionsPage.showTab($('wimax-network-nav-tab')); | 1350 OptionsPage.showTab($('wimax-network-nav-tab')); |
1289 detailsPage.gsm = false; | 1351 detailsPage.gsm = false; |
1290 detailsPage.shared = data.shared; | 1352 detailsPage.shared = data.shared; |
1291 detailsPage.showPreferred = data.remembered; | 1353 detailsPage.showPreferred = data.remembered; |
1292 $('wimax-connection-state').textContent = connectionStateString; | 1354 $('wimax-connection-state').textContent = connectionStateString; |
1293 $('wimax-restricted-pool').textContent = restrictedString; | 1355 $('wimax-restricted-pool').textContent = restrictedString; |
1294 $('auto-connect-network-wimax').checked = | 1356 $('auto-connect-network-wimax').checked = |
1295 getManagedValue(data, 'AutoConnect'); | 1357 getManagedValue(data, 'AutoConnect'); |
1296 $('auto-connect-network-wimax').disabled = !data.remembered; | 1358 $('auto-connect-network-wimax').disabled = !data.remembered; |
1297 var identity; | 1359 var identity = getManagedValue(data, 'Wimax.EAP.Identity'); |
1298 if (data.Wimax.EAP) | |
1299 identity = getManagedValue(data.Wimax.EAP, 'Identity'); | |
1300 setOrHideParent('wimax-eap-identity', identity); | 1360 setOrHideParent('wimax-eap-identity', identity); |
1301 $('wimax-signal-strength').textContent = strengthString; | 1361 $('wimax-signal-strength').textContent = strengthString; |
1302 } else if (data.type == 'Cellular') { | 1362 } else if (data.type == 'Cellular') { |
1303 assert('Cellular' in data, | 1363 assert('Cellular' in data, |
1304 'Cellular network has no Cellular object' + networkName); | 1364 'Cellular network has no Cellular object' + networkName); |
1305 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1365 OptionsPage.showTab($('cellular-conn-nav-tab')); |
1306 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1366 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
1307 var carrierSelector = $('select-carrier'); | 1367 var carrierSelector = $('select-carrier'); |
1308 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1368 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
1309 carrierSelector.options.length = 0; | 1369 carrierSelector.options.length = 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1366 $('iccid').textContent = getManagedValue(data, 'Cellular.ICCID'); | 1426 $('iccid').textContent = getManagedValue(data, 'Cellular.ICCID'); |
1367 $('imsi').textContent = getManagedValue(data, 'Cellular.IMSI'); | 1427 $('imsi').textContent = getManagedValue(data, 'Cellular.IMSI'); |
1368 | 1428 |
1369 var apnSelector = $('select-apn'); | 1429 var apnSelector = $('select-apn'); |
1370 // Clear APN lists, keep only last element that "other". | 1430 // Clear APN lists, keep only last element that "other". |
1371 while (apnSelector.length != 1) | 1431 while (apnSelector.length != 1) |
1372 apnSelector.remove(0); | 1432 apnSelector.remove(0); |
1373 var otherOption = apnSelector[0]; | 1433 var otherOption = apnSelector[0]; |
1374 data.selectedApn = -1; | 1434 data.selectedApn = -1; |
1375 data.userApnIndex = -1; | 1435 data.userApnIndex = -1; |
1376 var activeApn = getManagedValue(data, 'Cellular.APN'); | 1436 var activeApn = getManagedValue(data, 'Cellular.APN.AccessPointName'); |
1377 var lastGoodApn = getManagedValue(data, 'Cellular.LastGoodAPN'); | 1437 var activeUsername = getManagedValue(data, 'Cellular.APN.Username'); |
1438 var activePassword = getManagedValue(data, 'Cellular.APN.Password'); | |
1439 var lastGoodApn = | |
1440 getManagedValue(data, 'Cellular.LastGoodAPN.AccessPointName'); | |
1441 var lastGoodUsername = | |
1442 getManagedValue(data, 'Cellular.LastGoodAPN.Username'); | |
1443 var lastGoodPassword = | |
1444 getManagedValue(data, 'Cellular.LastGoodAPN.Password'); | |
1378 var apnList = getManagedValue(data, 'Cellular.APNList'); | 1445 var apnList = getManagedValue(data, 'Cellular.APNList'); |
1379 for (var i = 0; i < apnList.length; i++) { | 1446 for (var i = 0; i < apnList.length; i++) { |
1380 var apnDict = apnList[i]; | 1447 var apnDict = apnList[i]; |
1381 var option = document.createElement('option'); | 1448 var option = document.createElement('option'); |
1382 var localizedName = apnDict['LocalizedName']; | 1449 var localizedName = apnDict['LocalizedName']; |
1383 var name = localizedName ? localizedName : apnDict['Name']; | 1450 var name = localizedName ? localizedName : apnDict['Name']; |
1384 var accessPointName = apnDict['AccessPointName']; | 1451 var accessPointName = apnDict['AccessPointName']; |
1385 option.textContent = | 1452 option.textContent = |
1386 name ? (name + ' (' + accessPointName + ')') : accessPointName; | 1453 name ? (name + ' (' + accessPointName + ')') : accessPointName; |
1387 option.value = i; | 1454 option.value = i; |
1388 // If this matches the active Apn, or LastGoodApn, set it as the | 1455 // If this matches the active Apn, or LastGoodApn, set it as the |
1389 // selected Apn. | 1456 // selected Apn. |
1390 if ((activeApn != undefined && | 1457 if ((activeApn == accessPointName && |
1391 activeApn['AccessPointName'] == accessPointName && | 1458 activeUsername == apnDict['Username'] && |
1392 activeApn['Username'] == apnDict['Username'] && | 1459 activePassword == apnDict['Password']) || |
1393 activeApn['Password'] == apnDict['Password']) || | 1460 (!activeApn && |
1394 ((activeApn == undefined || !activeApn['AccessPointName']) && | 1461 lastGoodApn == accessPointName && |
1395 lastGoodApn != undefined && | 1462 lastGoodUsername == apnDict['Username'] && |
1396 lastGoodApn['AccessPointName'] == accessPointName && | 1463 lastGoodPassword == apnDict['Password'])) { |
1397 lastGoodApn['Username'] == apnDict['Username'] && | |
1398 lastGoodApn['Password'] == apnDict['Password'])) { | |
1399 data.selectedApn = i; | 1464 data.selectedApn = i; |
1400 } | 1465 } |
1401 // Insert new option before "other" option. | 1466 // Insert new option before "other" option. |
1402 apnSelector.add(option, otherOption); | 1467 apnSelector.add(option, otherOption); |
1403 } | 1468 } |
1404 if (data.selectedApn == -1 && | 1469 if (data.selectedApn == -1 && activeApn) { |
1405 activeApn != undefined && activeApn['AccessPointName']) { | |
1406 var option = document.createElement('option'); | 1470 var option = document.createElement('option'); |
1407 option.textContent = activeApn['AccessPointName']; | 1471 option.textContent = activeApn; |
1408 option.value = -1; | 1472 option.value = -1; |
1409 apnSelector.add(option, otherOption); | 1473 apnSelector.add(option, otherOption); |
1410 data.selectedApn = apnSelector.length - 2; | 1474 data.selectedApn = apnSelector.length - 2; |
1411 data.userApnIndex = data.selectedApn; | 1475 data.userApnIndex = data.selectedApn; |
1412 } | 1476 } |
1413 apnSelector.selectedIndex = data.selectedApn; | 1477 apnSelector.selectedIndex = data.selectedApn; |
1414 updateHidden('.apn-list-view', false); | 1478 updateHidden('.apn-list-view', false); |
1415 updateHidden('.apn-details-view', true); | 1479 updateHidden('.apn-details-view', true); |
1416 var lockEnabled = | 1480 var lockEnabled = |
1417 getManagedValue(data, 'Cellular.SIMLockStatus.LockEnabled'); | 1481 getManagedValue(data, 'Cellular.SIMLockStatus.LockEnabled'); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1487 | 1551 |
1488 // Don't show page name in address bar and in history to prevent people | 1552 // Don't show page name in address bar and in history to prevent people |
1489 // navigate here by hand and solve issue with page session restore. | 1553 // navigate here by hand and solve issue with page session restore. |
1490 PageManager.showPageByName('detailsInternetPage', false); | 1554 PageManager.showPageByName('detailsInternetPage', false); |
1491 }; | 1555 }; |
1492 | 1556 |
1493 return { | 1557 return { |
1494 DetailsInternetPage: DetailsInternetPage | 1558 DetailsInternetPage: DetailsInternetPage |
1495 }; | 1559 }; |
1496 }); | 1560 }); |
OLD | NEW |