| 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 |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 var connectable = onc.getActiveValue('Connectable'); | 876 var connectable = onc.getActiveValue('Connectable'); |
| 877 if (connectState != 'Connected' && | 877 if (connectState != 'Connected' && |
| 878 (!connectable || this.hasSecurity || | 878 (!connectable || this.hasSecurity || |
| 879 (onc.type == 'Wimax' || onc.type == 'VPN'))) { | 879 (onc.type == 'Wimax' || onc.type == 'VPN'))) { |
| 880 $('details-internet-configure').hidden = false; | 880 $('details-internet-configure').hidden = false; |
| 881 } else { | 881 } else { |
| 882 $('details-internet-configure').hidden = true; | 882 $('details-internet-configure').hidden = true; |
| 883 } | 883 } |
| 884 }; | 884 }; |
| 885 | 885 |
| 886 DetailsInternetPage.populateHeader = function(detailsPage, onc) { |
| 887 $('network-details-title').textContent = onc.getTranslatedValue('Name'); |
| 888 var connectionState = onc.getActiveValue('ConnectionState'); |
| 889 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 890 detailsPage.connected = connectionState == 'Connected'; |
| 891 $('network-details-subtitle-status').textContent = connectionStateString; |
| 892 var typeKey; |
| 893 if (onc.type == 'Ethernet') |
| 894 typeKey = 'ethernetTitle'; |
| 895 else if (onc.type == 'WiFi') |
| 896 typeKey = 'wifiTitle'; |
| 897 else if (onc.type == 'Wimax') |
| 898 typeKey = 'wimaxTitle'; |
| 899 else if (onc.type == 'Cellular') |
| 900 typeKey = 'cellularTitle'; |
| 901 else if (onc.type == 'VPN') |
| 902 typeKey = 'vpnTitle'; |
| 903 else |
| 904 typeKey = null; |
| 905 var typeLabel = $('network-details-subtitle-type'); |
| 906 var typeSeparator = $('network-details-subtitle-separator'); |
| 907 if (typeKey) { |
| 908 typeLabel.textContent = loadTimeData.getString(typeKey); |
| 909 typeLabel.hidden = false; |
| 910 typeSeparator.hidden = false; |
| 911 } else { |
| 912 typeLabel.hidden = true; |
| 913 typeSeparator.hidden = true; |
| 914 } |
| 915 }; |
| 916 |
| 886 DetailsInternetPage.updateConnectionData = function(update) { | 917 DetailsInternetPage.updateConnectionData = function(update) { |
| 887 var detailsPage = DetailsInternetPage.getInstance(); | 918 var detailsPage = DetailsInternetPage.getInstance(); |
| 888 if (!detailsPage.visible) | 919 if (!detailsPage.visible) |
| 889 return; | 920 return; |
| 890 | 921 |
| 891 var data = $('connection-state').data; | 922 var data = $('connection-state').data; |
| 892 if (!data) | 923 if (!data) |
| 893 return; | 924 return; |
| 894 | 925 |
| 895 if (update.servicePath != data.servicePath) | 926 if (update.servicePath != data.servicePath) |
| 896 return; | 927 return; |
| 897 | 928 |
| 898 // Update our cached data object. | 929 // Update our cached data object. |
| 899 updateDataObject(data, update); | 930 updateDataObject(data, update); |
| 900 var onc = new OncData(data); | 931 var onc = new OncData(data); |
| 901 | 932 |
| 933 this.populateHeader(detailsPage, onc); |
| 934 |
| 902 var connectionState = onc.getActiveValue('ConnectionState'); | 935 var connectionState = onc.getActiveValue('ConnectionState'); |
| 903 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | 936 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 904 detailsPage.deviceConnected = data.deviceConnected; | 937 detailsPage.deviceConnected = data.deviceConnected; |
| 905 detailsPage.connected = connectionState == 'Connected'; | 938 detailsPage.connected = connectionState == 'Connected'; |
| 906 $('connection-state').textContent = connectionStateString; | 939 $('connection-state').textContent = connectionStateString; |
| 907 | 940 |
| 908 this.updateConnectionButtonVisibilty(onc); | 941 this.updateConnectionButtonVisibilty(onc); |
| 909 | 942 |
| 910 if (onc.type == 'WiFi') { | 943 if (onc.type == 'WiFi') { |
| 911 $('wifi-connection-state').textContent = connectionStateString; | 944 $('wifi-connection-state').textContent = connectionStateString; |
| 912 } else if (onc.type == 'Wimax') { | 945 } else if (onc.type == 'Wimax') { |
| 913 $('wimax-connection-state').textContent = connectionStateString; | 946 $('wimax-connection-state').textContent = connectionStateString; |
| 914 } else if (onc.type == 'Cellular') { | 947 } else if (onc.type == 'Cellular') { |
| 915 $('activation-state').textContent = data.activationState; | 948 $('activation-state').textContent = |
| 916 | 949 onc.getTranslatedValue('Cellular.ActivationState'); |
| 917 $('buyplan-details').hidden = !data.showBuyButton; | 950 $('buyplan-details').hidden = !data.showBuyButton; |
| 918 $('view-account-details').hidden = !data.showViewAccountButton; | 951 $('view-account-details').hidden = !data.showViewAccountButton; |
| 919 | 952 |
| 920 $('activate-details').hidden = !data.showActivateButton; | 953 $('activate-details').hidden = !data.showActivateButton; |
| 921 if (data.showActivateButton) | 954 if (data.showActivateButton) |
| 922 $('details-internet-login').hidden = true; | 955 $('details-internet-login').hidden = true; |
| 923 | 956 |
| 924 if (detailsPage.gsm) { | 957 if (detailsPage.gsm) { |
| 925 var lockEnabled = | 958 var lockEnabled = |
| 926 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); | 959 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); |
| 927 $('sim-card-lock-enabled').checked = lockEnabled; | 960 $('sim-card-lock-enabled').checked = lockEnabled; |
| 928 $('change-pin').hidden = !lockEnabled; | 961 $('change-pin').hidden = !lockEnabled; |
| 929 } | 962 } |
| 930 } | 963 } |
| 931 | 964 |
| 932 $('connection-state').data = data; | 965 $('connection-state').data = data; |
| 933 $('connection-state').onc = onc; | 966 $('connection-state').onc = onc; |
| 934 }; | 967 }; |
| 935 | 968 |
| 936 DetailsInternetPage.showDetailedInfo = function(data) { | 969 DetailsInternetPage.showDetailedInfo = function(data) { |
| 937 var detailsPage = DetailsInternetPage.getInstance(); | 970 var detailsPage = DetailsInternetPage.getInstance(); |
| 938 | 971 |
| 939 var onc = new OncData(data); | 972 var onc = new OncData(data); |
| 940 data.type = onc.type; | 973 data.type = onc.type; |
| 941 | 974 |
| 942 // Populate header | 975 this.populateHeader(detailsPage, onc); |
| 943 $('network-details-title').textContent = onc.getTranslatedValue('Name'); | |
| 944 var connectionState = onc.getActiveValue('ConnectionState'); | |
| 945 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | |
| 946 detailsPage.connected = connectionState == 'Connected'; | |
| 947 $('network-details-subtitle-status').textContent = connectionStateString; | |
| 948 var typeKey = null; | |
| 949 switch (onc.type) { | |
| 950 case 'Ethernet': | |
| 951 typeKey = 'ethernetTitle'; | |
| 952 break; | |
| 953 case 'WiFi': | |
| 954 typeKey = 'wifiTitle'; | |
| 955 break; | |
| 956 case 'Wimax': | |
| 957 typeKey = 'wimaxTitle'; | |
| 958 break; | |
| 959 case 'Cellular': | |
| 960 typeKey = 'cellularTitle'; | |
| 961 break; | |
| 962 case 'VPN': | |
| 963 typeKey = 'vpnTitle'; | |
| 964 break; | |
| 965 } | |
| 966 var typeLabel = $('network-details-subtitle-type'); | |
| 967 var typeSeparator = $('network-details-subtitle-separator'); | |
| 968 if (typeKey) { | |
| 969 typeLabel.textContent = loadTimeData.getString(typeKey); | |
| 970 typeLabel.hidden = false; | |
| 971 typeSeparator.hidden = false; | |
| 972 } else { | |
| 973 typeLabel.hidden = true; | |
| 974 typeSeparator.hidden = true; | |
| 975 } | |
| 976 | 976 |
| 977 // TODO(stevenjb): Find a more appropriate place to cache data. | 977 // TODO(stevenjb): Find a more appropriate place to cache data. |
| 978 $('connection-state').data = data; | 978 $('connection-state').data = data; |
| 979 $('connection-state').onc = onc; | 979 $('connection-state').onc = onc; |
| 980 | 980 |
| 981 $('buyplan-details').hidden = true; | 981 $('buyplan-details').hidden = true; |
| 982 $('activate-details').hidden = true; | 982 $('activate-details').hidden = true; |
| 983 $('view-account-details').hidden = true; | 983 $('view-account-details').hidden = true; |
| 984 | 984 |
| 985 this.updateConnectionButtonVisibilty(onc); | 985 this.updateConnectionButtonVisibilty(onc); |
| 986 | 986 |
| 987 $('web-proxy-auto-discovery').hidden = true; | 987 $('web-proxy-auto-discovery').hidden = true; |
| 988 | 988 |
| 989 detailsPage.deviceConnected = data.deviceConnected; | 989 detailsPage.deviceConnected = data.deviceConnected; |
| 990 detailsPage.connected = connectionState == 'Connected'; | 990 detailsPage.connected = |
| 991 onc.getActiveValue('ConnectionState') == 'Connected'; |
| 991 | 992 |
| 992 // Only show proxy for remembered networks. | 993 // Only show proxy for remembered networks. |
| 993 if (data.remembered) { | 994 if (data.remembered) { |
| 994 detailsPage.showProxy = true; | 995 detailsPage.showProxy = true; |
| 995 chrome.send('selectNetwork', [data.servicePath]); | 996 chrome.send('selectNetwork', [data.servicePath]); |
| 996 } else { | 997 } else { |
| 997 detailsPage.showProxy = false; | 998 detailsPage.showProxy = false; |
| 998 } | 999 } |
| 1000 |
| 1001 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 999 $('connection-state').textContent = connectionStateString; | 1002 $('connection-state').textContent = connectionStateString; |
| 1000 | 1003 var restricted = onc.getActiveValue('RestrictedConnectivity'); |
| 1004 var restrictedString = loadTimeData.getString( |
| 1005 restricted ? 'restrictedYes' : 'restrictedNo'); |
| 1001 var ipAutoConfig = data.ipAutoConfig ? 'automatic' : 'user'; | 1006 var ipAutoConfig = data.ipAutoConfig ? 'automatic' : 'user'; |
| 1002 $('ip-automatic-configuration-checkbox').checked = data.ipAutoConfig; | 1007 $('ip-automatic-configuration-checkbox').checked = data.ipAutoConfig; |
| 1003 var inetAddress = {autoConfig: ipAutoConfig}; | 1008 var inetAddress = {autoConfig: ipAutoConfig}; |
| 1004 var inetNetmask = {autoConfig: ipAutoConfig}; | 1009 var inetNetmask = {autoConfig: ipAutoConfig}; |
| 1005 var inetGateway = {autoConfig: ipAutoConfig}; | 1010 var inetGateway = {autoConfig: ipAutoConfig}; |
| 1006 | 1011 |
| 1007 if (data.ipconfig.value) { | 1012 if (data.ipconfig.value) { |
| 1008 inetAddress.automatic = data.ipconfig.value.address; | 1013 inetAddress.automatic = data.ipconfig.value.address; |
| 1009 inetAddress.value = data.ipconfig.value.address; | 1014 inetAddress.value = data.ipconfig.value.address; |
| 1010 inetNetmask.automatic = data.ipconfig.value.netmask; | 1015 inetNetmask.automatic = data.ipconfig.value.netmask; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 signalStrength = 0; | 1120 signalStrength = 0; |
| 1116 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1121 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
| 1117 var strengthString = strengthFormat.replace('$1', signalStrength); | 1122 var strengthString = strengthFormat.replace('$1', signalStrength); |
| 1118 | 1123 |
| 1119 detailsPage.type = onc.type; | 1124 detailsPage.type = onc.type; |
| 1120 if (onc.type == 'WiFi') { | 1125 if (onc.type == 'WiFi') { |
| 1121 OptionsPage.showTab($('wifi-network-nav-tab')); | 1126 OptionsPage.showTab($('wifi-network-nav-tab')); |
| 1122 detailsPage.gsm = false; | 1127 detailsPage.gsm = false; |
| 1123 detailsPage.shared = data.shared; | 1128 detailsPage.shared = data.shared; |
| 1124 $('wifi-connection-state').textContent = connectionStateString; | 1129 $('wifi-connection-state').textContent = connectionStateString; |
| 1130 $('wifi-restricted-connectivity').textContent = restrictedString; |
| 1125 var ssid = onc.getActiveValue('WiFi.SSID'); | 1131 var ssid = onc.getActiveValue('WiFi.SSID'); |
| 1126 $('wifi-ssid').textContent = ssid ? ssid : networkName; | 1132 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
| 1127 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); | 1133 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); |
| 1128 var security = onc.getActiveValue('WiFi.Security'); | 1134 var security = onc.getActiveValue('WiFi.Security'); |
| 1129 if (security == 'None') | 1135 if (security == 'None') |
| 1130 security = undefined; | 1136 security = undefined; |
| 1131 setOrHideParent('wifi-security', security); | 1137 setOrHideParent('wifi-security', security); |
| 1132 // Frequency is in MHz. | 1138 // Frequency is in MHz. |
| 1133 var frequency = onc.getActiveValue('WiFi.Frequency'); | 1139 var frequency = onc.getActiveValue('WiFi.Frequency'); |
| 1134 if (!frequency) | 1140 if (!frequency) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1146 $('auto-connect-network-wifi').checked = | 1152 $('auto-connect-network-wifi').checked = |
| 1147 onc.getActiveValue('AutoConnect'); | 1153 onc.getActiveValue('AutoConnect'); |
| 1148 $('auto-connect-network-wifi').disabled = !data.remembered; | 1154 $('auto-connect-network-wifi').disabled = !data.remembered; |
| 1149 detailsPage.hasSecurity = security != undefined; | 1155 detailsPage.hasSecurity = security != undefined; |
| 1150 } else if (onc.type == 'Wimax') { | 1156 } else if (onc.type == 'Wimax') { |
| 1151 OptionsPage.showTab($('wimax-network-nav-tab')); | 1157 OptionsPage.showTab($('wimax-network-nav-tab')); |
| 1152 detailsPage.gsm = false; | 1158 detailsPage.gsm = false; |
| 1153 detailsPage.shared = data.shared; | 1159 detailsPage.shared = data.shared; |
| 1154 detailsPage.showPreferred = data.remembered; | 1160 detailsPage.showPreferred = data.remembered; |
| 1155 $('wimax-connection-state').textContent = connectionStateString; | 1161 $('wimax-connection-state').textContent = connectionStateString; |
| 1162 $('wimax-restricted-connectivity').textContent = restrictedString; |
| 1156 $('auto-connect-network-wimax').checked = | 1163 $('auto-connect-network-wimax').checked = |
| 1157 onc.getActiveValue('AutoConnect'); | 1164 onc.getActiveValue('AutoConnect'); |
| 1158 $('auto-connect-network-wimax').disabled = !data.remembered; | 1165 $('auto-connect-network-wimax').disabled = !data.remembered; |
| 1159 var identity = onc.getActiveValue('Wimax.EAP.Identity'); | 1166 var identity = onc.getActiveValue('Wimax.EAP.Identity'); |
| 1160 setOrHideParent('wimax-eap-identity', identity); | 1167 setOrHideParent('wimax-eap-identity', identity); |
| 1161 $('wimax-signal-strength').textContent = strengthString; | 1168 $('wimax-signal-strength').textContent = strengthString; |
| 1162 } else if (onc.type == 'Cellular') { | 1169 } else if (onc.type == 'Cellular') { |
| 1163 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1170 OptionsPage.showTab($('cellular-conn-nav-tab')); |
| 1164 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1171 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
| 1165 var carrierSelector = $('select-carrier'); | 1172 var carrierSelector = $('select-carrier'); |
| 1166 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1173 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
| 1167 carrierSelector.options.length = 0; | 1174 carrierSelector.options.length = 0; |
| 1168 for (var i = 0; i < data.carriers.length; ++i) { | 1175 for (var i = 0; i < data.carriers.length; ++i) { |
| 1169 var option = document.createElement('option'); | 1176 var option = document.createElement('option'); |
| 1170 option.textContent = data.carriers[i]; | 1177 option.textContent = data.carriers[i]; |
| 1171 carrierSelector.add(option); | 1178 carrierSelector.add(option); |
| 1172 } | 1179 } |
| 1173 carrierSelector.selectedIndex = data.currentCarrierIndex; | 1180 carrierSelector.selectedIndex = data.currentCarrierIndex; |
| 1174 } else { | 1181 } else { |
| 1175 $('service-name').textContent = networkName; | 1182 $('service-name').textContent = networkName; |
| 1176 } | 1183 } |
| 1177 | 1184 |
| 1178 $('network-technology').textContent = | 1185 $('network-technology').textContent = |
| 1179 onc.getActiveValue('Cellular.NetworkTechnology'); | 1186 onc.getActiveValue('Cellular.NetworkTechnology'); |
| 1180 $('activation-state').textContent = data.activationState; | 1187 $('activation-state').textContent = |
| 1181 $('roaming-state').textContent = data.roamingState; | 1188 onc.getTranslatedValue('Cellular.ActivationState'); |
| 1182 $('restricted-pool').textContent = data.restrictedPool; | 1189 $('roaming-state').textContent = |
| 1190 onc.getTranslatedValue('Cellular.RoamingState'); |
| 1191 $('cellular-restricted-connectivity').textContent = restrictedString; |
| 1183 $('error-state').textContent = data.errorMessage; | 1192 $('error-state').textContent = data.errorMessage; |
| 1184 $('manufacturer').textContent = | 1193 $('manufacturer').textContent = |
| 1185 onc.getActiveValue('Cellular.Manufacturer'); | 1194 onc.getActiveValue('Cellular.Manufacturer'); |
| 1186 $('model-id').textContent = onc.getActiveValue('Cellular.ModelID'); | 1195 $('model-id').textContent = onc.getActiveValue('Cellular.ModelID'); |
| 1187 $('firmware-revision').textContent = | 1196 $('firmware-revision').textContent = |
| 1188 onc.getActiveValue('Cellular.FirmwareRevision'); | 1197 onc.getActiveValue('Cellular.FirmwareRevision'); |
| 1189 $('hardware-revision').textContent = | 1198 $('hardware-revision').textContent = |
| 1190 onc.getActiveValue('Cellular.HardwareRevision'); | 1199 onc.getActiveValue('Cellular.HardwareRevision'); |
| 1191 $('mdn').textContent = onc.getActiveValue('Cellular.MDN'); | 1200 $('mdn').textContent = onc.getActiveValue('Cellular.MDN'); |
| 1192 | 1201 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 | 1350 |
| 1342 // Don't show page name in address bar and in history to prevent people | 1351 // Don't show page name in address bar and in history to prevent people |
| 1343 // navigate here by hand and solve issue with page session restore. | 1352 // navigate here by hand and solve issue with page session restore. |
| 1344 PageManager.showPageByName('detailsInternetPage', false); | 1353 PageManager.showPageByName('detailsInternetPage', false); |
| 1345 }; | 1354 }; |
| 1346 | 1355 |
| 1347 return { | 1356 return { |
| 1348 DetailsInternetPage: DetailsInternetPage | 1357 DetailsInternetPage: DetailsInternetPage |
| 1349 }; | 1358 }; |
| 1350 }); | 1359 }); |
| OLD | NEW |