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 // require: onc_data.js | 5 // require: onc_data.js |
6 | 6 |
7 // NOTE(stevenjb): This code is in the process of being converted to be | 7 // NOTE(stevenjb): This code is in the process of being converted to be |
8 // compatible with the networkingPrivate extension API: | 8 // compatible with the networkingPrivate extension API: |
9 // * The network property dictionaries are being converted to use ONC values. | 9 // * The network property dictionaries are being converted to use ONC values. |
10 // * chrome.send calls will be replaced with an API object that simulates the | 10 // * chrome.send calls will be replaced with an API object that simulates the |
11 // networkingPrivate API. See network_config.js. | 11 // networkingPrivate API. See network_config.js. |
12 // See crbug.com/279351 for more info. | 12 // See crbug.com/279351 for more info. |
13 | 13 |
14 /** | 14 /** |
15 * InternetDetailedInfo argument passed to showDetailedInfo. | 15 * InternetDetailedInfo argument passed to showDetailedInfo. |
16 * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc | 16 * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc |
17 * @typedef {{ | 17 * @typedef {{ |
18 * carriers: (Array.<string>|undefined), | |
19 * currentCarrierIndex: (number|undefined), | |
20 * deviceConnected: (boolean|undefined), | 18 * deviceConnected: (boolean|undefined), |
21 * errorMessage: (string|undefined), | 19 * errorMessage: (string|undefined), |
22 * servicePath: string, | 20 * servicePath: string, |
23 * showCarrierSelect: (boolean|undefined), | 21 * showCarrierSelect: (boolean|undefined), |
24 * showViewAccountButton: (boolean|undefined) | 22 * showViewAccountButton: (boolean|undefined) |
25 * }} | 23 * }} |
26 */ | 24 */ |
27 var InternetDetailedInfo; | 25 var InternetDetailedInfo; |
28 | 26 |
29 cr.define('options.internet', function() { | 27 cr.define('options.internet', function() { |
30 var OncData = cr.onc.OncData; | 28 var OncData = cr.onc.OncData; |
31 var Page = cr.ui.pageManager.Page; | 29 var Page = cr.ui.pageManager.Page; |
32 var PageManager = cr.ui.pageManager.PageManager; | 30 var PageManager = cr.ui.pageManager.PageManager; |
33 /** @const */ var IPAddressField = options.internet.IPAddressField; | 31 /** @const */ var IPAddressField = options.internet.IPAddressField; |
34 | 32 |
35 /** @const */ var GoogleNameServersString = '8.8.4.4,8.8.8.8'; | 33 /** @const */ var GoogleNameServersString = '8.8.4.4,8.8.8.8'; |
| 34 /** @const */ var CarrierGenericUMTS = 'Generic UMTS'; |
36 | 35 |
37 /** | 36 /** |
38 * Helper function to set hidden attribute for elements matching a selector. | 37 * Helper function to set hidden attribute for elements matching a selector. |
39 * @param {string} selector CSS selector for extracting a list of elements. | 38 * @param {string} selector CSS selector for extracting a list of elements. |
40 * @param {boolean} hidden New hidden value. | 39 * @param {boolean} hidden New hidden value. |
41 */ | 40 */ |
42 function updateHidden(selector, hidden) { | 41 function updateHidden(selector, hidden) { |
43 var elements = cr.doc.querySelectorAll(selector); | 42 var elements = cr.doc.querySelectorAll(selector); |
44 for (var i = 0, el; el = elements[i]; i++) { | 43 for (var i = 0, el; el = elements[i]; i++) { |
45 el.hidden = hidden; | 44 el.hidden = hidden; |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 $('wimax-restricted-connectivity').textContent = restrictedString; | 1348 $('wimax-restricted-connectivity').textContent = restrictedString; |
1350 | 1349 |
1351 $('auto-connect-network-wimax').checked = | 1350 $('auto-connect-network-wimax').checked = |
1352 onc.getActiveValue('Wimax.AutoConnect'); | 1351 onc.getActiveValue('Wimax.AutoConnect'); |
1353 $('auto-connect-network-wimax').disabled = !remembered; | 1352 $('auto-connect-network-wimax').disabled = !remembered; |
1354 var identity = onc.getActiveValue('Wimax.EAP.Identity'); | 1353 var identity = onc.getActiveValue('Wimax.EAP.Identity'); |
1355 setOrHideParent('wimax-eap-identity', identity); | 1354 setOrHideParent('wimax-eap-identity', identity); |
1356 $('wimax-signal-strength').textContent = strengthString; | 1355 $('wimax-signal-strength').textContent = strengthString; |
1357 } else if (type == 'Cellular') { | 1356 } else if (type == 'Cellular') { |
1358 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1357 OptionsPage.showTab($('cellular-conn-nav-tab')); |
1359 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1358 |
1360 var carrierSelector = $('select-carrier'); | 1359 var isGsm = onc.getActiveValue('Cellular.Family') == 'GSM'; |
1361 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1360 |
1362 carrierSelector.options.length = 0; | 1361 var currentCarrierIndex = -1; |
1363 for (var i = 0; i < data.carriers.length; ++i) { | 1362 if (data.showCarrierSelect) { |
1364 var option = document.createElement('option'); | 1363 var currentCarrier = |
1365 option.textContent = data.carriers[i]; | 1364 isGsm ? CarrierGenericUMTS : onc.getActiveValue('Cellular.Carrier'); |
1366 carrierSelector.add(option); | 1365 var supportedCarriers = |
| 1366 onc.getActiveValue('Cellular.SupportedCarriers'); |
| 1367 for (var c1 = 0; c1 < supportedCarriers.length; ++c1) { |
| 1368 if (supportedCarriers[c1] == currentCarrier) { |
| 1369 currentCarrierIndex = c1; |
| 1370 break; |
| 1371 } |
1367 } | 1372 } |
1368 carrierSelector.selectedIndex = data.currentCarrierIndex; | 1373 if (currentCarrierIndex != -1) { |
1369 } else { | 1374 var carrierSelector = $('select-carrier'); |
| 1375 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
| 1376 carrierSelector.options.length = 0; |
| 1377 for (var c2 = 0; c2 < supportedCarriers.length; ++c2) { |
| 1378 var option = document.createElement('option'); |
| 1379 option.textContent = supportedCarriers[c2]; |
| 1380 carrierSelector.add(option); |
| 1381 } |
| 1382 carrierSelector.selectedIndex = currentCarrierIndex; |
| 1383 } |
| 1384 } |
| 1385 if (currentCarrierIndex == -1) |
1370 $('service-name').textContent = networkName; | 1386 $('service-name').textContent = networkName; |
1371 } | |
1372 | 1387 |
1373 $('network-technology').textContent = | 1388 $('network-technology').textContent = |
1374 onc.getActiveValue('Cellular.NetworkTechnology'); | 1389 onc.getActiveValue('Cellular.NetworkTechnology'); |
1375 $('roaming-state').textContent = | 1390 $('roaming-state').textContent = |
1376 onc.getTranslatedValue('Cellular.RoamingState'); | 1391 onc.getTranslatedValue('Cellular.RoamingState'); |
1377 $('cellular-restricted-connectivity').textContent = restrictedString; | 1392 $('cellular-restricted-connectivity').textContent = restrictedString; |
1378 if ('errorMessage' in data) | 1393 if ('errorMessage' in data) |
1379 $('error-state').textContent = data.errorMessage; | 1394 $('error-state').textContent = data.errorMessage; |
1380 $('manufacturer').textContent = | 1395 $('manufacturer').textContent = |
1381 onc.getActiveValue('Cellular.Manufacturer'); | 1396 onc.getActiveValue('Cellular.Manufacturer'); |
(...skipping 22 matching lines...) Expand all Loading... |
1404 updateHidden('#details-internet-page .gsm-only', false); | 1419 updateHidden('#details-internet-page .gsm-only', false); |
1405 updateHidden('#details-internet-page .cdma-only', false); | 1420 updateHidden('#details-internet-page .cdma-only', false); |
1406 | 1421 |
1407 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. | 1422 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. |
1408 setOrHideParent('esn', onc.getActiveValue('Cellular.ESN')); | 1423 setOrHideParent('esn', onc.getActiveValue('Cellular.ESN')); |
1409 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI')); | 1424 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI')); |
1410 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID')); | 1425 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID')); |
1411 setOrHideParent('min', onc.getActiveValue('Cellular.MIN')); | 1426 setOrHideParent('min', onc.getActiveValue('Cellular.MIN')); |
1412 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion')); | 1427 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion')); |
1413 | 1428 |
1414 if (onc.getActiveValue('Cellular.Family') == 'GSM') { | 1429 if (isGsm) { |
1415 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); | 1430 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); |
1416 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); | 1431 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); |
1417 detailsPage.initializeApnList_(); | 1432 detailsPage.initializeApnList_(); |
1418 } | 1433 } |
1419 $('auto-connect-network-cellular').checked = | 1434 $('auto-connect-network-cellular').checked = |
1420 onc.getActiveValue('Cellular.AutoConnect'); | 1435 onc.getActiveValue('Cellular.AutoConnect'); |
1421 $('auto-connect-network-cellular').disabled = false; | 1436 $('auto-connect-network-cellular').disabled = false; |
1422 } else if (type == 'VPN') { | 1437 } else if (type == 'VPN') { |
1423 OptionsPage.showTab($('vpn-nav-tab')); | 1438 OptionsPage.showTab($('vpn-nav-tab')); |
1424 $('inet-service-name').textContent = networkName; | 1439 $('inet-service-name').textContent = networkName; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 | 1500 |
1486 // Don't show page name in address bar and in history to prevent people | 1501 // Don't show page name in address bar and in history to prevent people |
1487 // navigate here by hand and solve issue with page session restore. | 1502 // navigate here by hand and solve issue with page session restore. |
1488 PageManager.showPageByName('detailsInternetPage', false); | 1503 PageManager.showPageByName('detailsInternetPage', false); |
1489 }; | 1504 }; |
1490 | 1505 |
1491 return { | 1506 return { |
1492 DetailsInternetPage: DetailsInternetPage | 1507 DetailsInternetPage: DetailsInternetPage |
1493 }; | 1508 }; |
1494 }); | 1509 }); |
OLD | NEW |