| 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 chrome.networkingPrivate calls. | 10 // * chrome.send calls will be replaced with chrome.networkingPrivate calls. |
| 11 // See crbug.com/279351 for more info. | 11 // See crbug.com/279351 for more info. |
| 12 | 12 |
| 13 cr.define('options.internet', function() { | 13 cr.define('options.internet', function() { |
| 14 var OncData = cr.onc.OncData; | 14 var OncData = cr.onc.OncData; |
| 15 var Page = cr.ui.pageManager.Page; | 15 var Page = cr.ui.pageManager.Page; |
| 16 var PageManager = cr.ui.pageManager.PageManager; | 16 var PageManager = cr.ui.pageManager.PageManager; |
| 17 /** @const */ var IPAddressField = options.internet.IPAddressField; | 17 /** @const */ var IPAddressField = options.internet.IPAddressField; |
| 18 | 18 |
| 19 /** @const */ var GoogleNameServers = ['8.8.4.4', '8.8.8.8']; | 19 /** @const */ var GoogleNameServers = ['8.8.4.4', '8.8.8.8']; |
| 20 /** @const */ var CarrierGenericUMTS = 'Generic UMTS'; | |
| 21 /** @const */ var CarrierSprint = 'Sprint'; | 20 /** @const */ var CarrierSprint = 'Sprint'; |
| 22 /** @const */ var CarrierVerizon = 'Verizon Wireless'; | 21 /** @const */ var CarrierVerizon = 'Verizon Wireless'; |
| 23 | 22 |
| 24 /** | 23 /** |
| 25 * Helper function to set hidden attribute for elements matching a selector. | 24 * Helper function to set hidden attribute for elements matching a selector. |
| 26 * @param {string} selector CSS selector for extracting a list of elements. | 25 * @param {string} selector CSS selector for extracting a list of elements. |
| 27 * @param {boolean} hidden New hidden value. | 26 * @param {boolean} hidden New hidden value. |
| 28 */ | 27 */ |
| 29 function updateHidden(selector, hidden) { | 28 function updateHidden(selector, hidden) { |
| 30 var elements = cr.doc.querySelectorAll(selector); | 29 var elements = cr.doc.querySelectorAll(selector); |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 'activate-details', | 1081 'activate-details', |
| 1083 'view-account-details'); | 1082 'view-account-details'); |
| 1084 | 1083 |
| 1085 for (var i = 0; i < buttonsToDisableList.length; ++i) { | 1084 for (var i = 0; i < buttonsToDisableList.length; ++i) { |
| 1086 var button = $(buttonsToDisableList[i]); | 1085 var button = $(buttonsToDisableList[i]); |
| 1087 button.disabled = disable; | 1086 button.disabled = disable; |
| 1088 } | 1087 } |
| 1089 }; | 1088 }; |
| 1090 | 1089 |
| 1091 /** | 1090 /** |
| 1092 * Shows a spinner while the carrier is changed. | |
| 1093 */ | |
| 1094 DetailsInternetPage.showCarrierChangeSpinner = function(visible) { | |
| 1095 if (!DetailsInternetPage.getInstance().visible) | |
| 1096 return; | |
| 1097 $('switch-carrier-spinner').hidden = !visible; | |
| 1098 // Disable any buttons that allow us to operate on cellular networks. | |
| 1099 DetailsInternetPage.changeCellularButtonsState(visible); | |
| 1100 }; | |
| 1101 | |
| 1102 /** | |
| 1103 * Changes the network carrier. | |
| 1104 */ | |
| 1105 DetailsInternetPage.handleCarrierChanged = function() { | |
| 1106 var carrierSelector = $('select-carrier'); | |
| 1107 var carrier = carrierSelector[carrierSelector.selectedIndex].textContent; | |
| 1108 DetailsInternetPage.showCarrierChangeSpinner(true); | |
| 1109 var guid = DetailsInternetPage.getInstance().onc_.guid(); | |
| 1110 var oncData = new OncData({}); | |
| 1111 oncData.setProperty('Cellular.Carrier', carrier); | |
| 1112 chrome.networkingPrivate.setProperties(guid, oncData.getData(), function() { | |
| 1113 // Start activation or show the activation UI after changing carriers. | |
| 1114 DetailsInternetPage.activateCellular(guid); | |
| 1115 }); | |
| 1116 }; | |
| 1117 | |
| 1118 /** | |
| 1119 * If the network is not already activated, starts the activation process or | 1091 * If the network is not already activated, starts the activation process or |
| 1120 * shows the activation UI. Otherwise does nothing. | 1092 * shows the activation UI. Otherwise does nothing. |
| 1121 */ | 1093 */ |
| 1122 DetailsInternetPage.activateCellular = function(guid) { | 1094 DetailsInternetPage.activateCellular = function(guid) { |
| 1123 chrome.networkingPrivate.getProperties(guid, function(properties) { | 1095 chrome.networkingPrivate.getProperties(guid, function(properties) { |
| 1124 var oncData = new OncData(properties); | 1096 var oncData = new OncData(properties); |
| 1125 if (oncData.getActiveValue('Cellular.ActivationState') == 'Activated') { | 1097 if (oncData.getActiveValue('Cellular.ActivationState') == 'Activated') { |
| 1126 DetailsInternetPage.showCarrierChangeSpinner(false); | |
| 1127 return; | 1098 return; |
| 1128 } | 1099 } |
| 1129 var carrier = oncData.getActiveValue('Cellular.Carrier'); | 1100 var carrier = oncData.getActiveValue('Cellular.Carrier'); |
| 1130 if (carrier == CarrierSprint) { | 1101 if (carrier == CarrierSprint) { |
| 1131 // Sprint is directly ativated, call startActivate(). | 1102 // Sprint is directly ativated, call startActivate(). |
| 1132 chrome.networkingPrivate.startActivate(guid, '', function() { | 1103 chrome.networkingPrivate.startActivate(guid, ''); |
| 1133 DetailsInternetPage.showCarrierChangeSpinner(false); | |
| 1134 }); | |
| 1135 } else { | 1104 } else { |
| 1136 DetailsInternetPage.showCarrierChangeSpinner(false); | |
| 1137 chrome.send('showMorePlanInfo', [guid]); | 1105 chrome.send('showMorePlanInfo', [guid]); |
| 1138 } | 1106 } |
| 1139 }); | 1107 }); |
| 1140 }; | 1108 }; |
| 1141 | 1109 |
| 1142 /** | 1110 /** |
| 1143 * Performs minimal initialization of the InternetDetails dialog in | 1111 * Performs minimal initialization of the InternetDetails dialog in |
| 1144 * preparation for showing proxy-settings. | 1112 * preparation for showing proxy-settings. |
| 1145 */ | 1113 */ |
| 1146 DetailsInternetPage.initializeProxySettings = function() { | 1114 DetailsInternetPage.initializeProxySettings = function() { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 onc.getActiveValue('WiMAX.AutoConnect'); | 1650 onc.getActiveValue('WiMAX.AutoConnect'); |
| 1683 $('auto-connect-network-wimax').disabled = !remembered; | 1651 $('auto-connect-network-wimax').disabled = !remembered; |
| 1684 var identity = onc.getActiveValue('WiMAX.EAP.Identity'); | 1652 var identity = onc.getActiveValue('WiMAX.EAP.Identity'); |
| 1685 setOrHideParent('wimax-eap-identity', identity); | 1653 setOrHideParent('wimax-eap-identity', identity); |
| 1686 $('wimax-signal-strength').textContent = strengthString; | 1654 $('wimax-signal-strength').textContent = strengthString; |
| 1687 } else if (type == 'Cellular') { | 1655 } else if (type == 'Cellular') { |
| 1688 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1656 OptionsPage.showTab($('cellular-conn-nav-tab')); |
| 1689 | 1657 |
| 1690 var isGsm = onc.getActiveValue('Cellular.Family') == 'GSM'; | 1658 var isGsm = onc.getActiveValue('Cellular.Family') == 'GSM'; |
| 1691 | 1659 |
| 1692 var currentCarrierIndex = -1; | 1660 $('service-name').textContent = networkName; |
| 1693 if (loadTimeData.getValue('showCarrierSelect')) { | |
| 1694 var currentCarrier = | |
| 1695 isGsm ? CarrierGenericUMTS : onc.getActiveValue('Cellular.Carrier'); | |
| 1696 var supportedCarriers = | |
| 1697 onc.getActiveValue('Cellular.SupportedCarriers'); | |
| 1698 for (var c1 = 0; c1 < supportedCarriers.length; ++c1) { | |
| 1699 if (supportedCarriers[c1] == currentCarrier) { | |
| 1700 currentCarrierIndex = c1; | |
| 1701 break; | |
| 1702 } | |
| 1703 } | |
| 1704 if (currentCarrierIndex != -1) { | |
| 1705 var carrierSelector = $('select-carrier'); | |
| 1706 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | |
| 1707 carrierSelector.options.length = 0; | |
| 1708 for (var c2 = 0; c2 < supportedCarriers.length; ++c2) { | |
| 1709 var option = document.createElement('option'); | |
| 1710 option.textContent = supportedCarriers[c2]; | |
| 1711 carrierSelector.add(option); | |
| 1712 } | |
| 1713 carrierSelector.selectedIndex = currentCarrierIndex; | |
| 1714 } | |
| 1715 } | |
| 1716 if (currentCarrierIndex == -1) | |
| 1717 $('service-name').textContent = networkName; | |
| 1718 | 1661 |
| 1719 // TODO(stevenjb): Ideally many of these should be localized. | 1662 // TODO(stevenjb): Ideally many of these should be localized. |
| 1720 $('network-technology').textContent = | 1663 $('network-technology').textContent = |
| 1721 onc.getActiveValue('Cellular.NetworkTechnology'); | 1664 onc.getActiveValue('Cellular.NetworkTechnology'); |
| 1722 $('roaming-state').textContent = | 1665 $('roaming-state').textContent = |
| 1723 onc.getTranslatedValue('Cellular.RoamingState'); | 1666 onc.getTranslatedValue('Cellular.RoamingState'); |
| 1724 $('cellular-restricted-connectivity').textContent = restrictedString; | 1667 $('cellular-restricted-connectivity').textContent = restrictedString; |
| 1725 $('error-state').textContent = onc.getActiveValue('ErrorState'); | 1668 $('error-state').textContent = onc.getActiveValue('ErrorState'); |
| 1726 $('manufacturer').textContent = | 1669 $('manufacturer').textContent = |
| 1727 onc.getActiveValue('Cellular.Manufacturer'); | 1670 onc.getActiveValue('Cellular.Manufacturer'); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 | 1795 |
| 1853 // Don't show page name in address bar and in history to prevent people | 1796 // Don't show page name in address bar and in history to prevent people |
| 1854 // navigate here by hand and solve issue with page session restore. | 1797 // navigate here by hand and solve issue with page session restore. |
| 1855 PageManager.showPageByName('detailsInternetPage', false); | 1798 PageManager.showPageByName('detailsInternetPage', false); |
| 1856 }; | 1799 }; |
| 1857 | 1800 |
| 1858 return { | 1801 return { |
| 1859 DetailsInternetPage: DetailsInternetPage | 1802 DetailsInternetPage: DetailsInternetPage |
| 1860 }; | 1803 }; |
| 1861 }); | 1804 }); |
| OLD | NEW |