Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/resources/options/chromeos/internet_detail.js

Issue 535283002: Translate activation/romaing state, restricted pool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_7b
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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'); 976
944 var connectionState = onc.getActiveValue('ConnectionState'); 977 var connectionState = onc.getActiveValue('ConnectionState');
pneubeck (no reviews) 2014/09/05 16:05:44 nit: i see only one usage, could be inlined / the
stevenjb 2014/09/05 16:54:21 Done.
945 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 978 var connectionStateString = onc.getTranslatedValue('ConnectionState');
pneubeck (no reviews) 2014/09/05 16:05:44 nit: move it a bit down, nearer to the first usage
stevenjb 2014/09/05 16:54:21 Done.
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 979
977 // TODO(stevenjb): Find a more appropriate place to cache data. 980 // TODO(stevenjb): Find a more appropriate place to cache data.
978 $('connection-state').data = data; 981 $('connection-state').data = data;
979 $('connection-state').onc = onc; 982 $('connection-state').onc = onc;
980 983
981 $('buyplan-details').hidden = true; 984 $('buyplan-details').hidden = true;
982 $('activate-details').hidden = true; 985 $('activate-details').hidden = true;
983 $('view-account-details').hidden = true; 986 $('view-account-details').hidden = true;
984 987
985 this.updateConnectionButtonVisibilty(onc); 988 this.updateConnectionButtonVisibilty(onc);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 signalStrength = 0; 1118 signalStrength = 0;
1116 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); 1119 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat');
1117 var strengthString = strengthFormat.replace('$1', signalStrength); 1120 var strengthString = strengthFormat.replace('$1', signalStrength);
1118 1121
1119 detailsPage.type = onc.type; 1122 detailsPage.type = onc.type;
1120 if (onc.type == 'WiFi') { 1123 if (onc.type == 'WiFi') {
1121 OptionsPage.showTab($('wifi-network-nav-tab')); 1124 OptionsPage.showTab($('wifi-network-nav-tab'));
1122 detailsPage.gsm = false; 1125 detailsPage.gsm = false;
1123 detailsPage.shared = data.shared; 1126 detailsPage.shared = data.shared;
1124 $('wifi-connection-state').textContent = connectionStateString; 1127 $('wifi-connection-state').textContent = connectionStateString;
1128 $('wifi-restricted-pool').textContent =
1129 onc.getTranslatedValue('Restricted');
1125 var ssid = onc.getActiveValue('WiFi.SSID'); 1130 var ssid = onc.getActiveValue('WiFi.SSID');
1126 $('wifi-ssid').textContent = ssid ? ssid : networkName; 1131 $('wifi-ssid').textContent = ssid ? ssid : networkName;
1127 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); 1132 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID'));
1128 var security = onc.getActiveValue('WiFi.Security'); 1133 var security = onc.getActiveValue('WiFi.Security');
1129 if (security == 'None') 1134 if (security == 'None')
1130 security = undefined; 1135 security = undefined;
1131 setOrHideParent('wifi-security', security); 1136 setOrHideParent('wifi-security', security);
1132 // Frequency is in MHz. 1137 // Frequency is in MHz.
1133 var frequency = onc.getActiveValue('WiFi.Frequency'); 1138 var frequency = onc.getActiveValue('WiFi.Frequency');
1134 if (!frequency) 1139 if (!frequency)
(...skipping 11 matching lines...) Expand all
1146 $('auto-connect-network-wifi').checked = 1151 $('auto-connect-network-wifi').checked =
1147 onc.getActiveValue('AutoConnect'); 1152 onc.getActiveValue('AutoConnect');
1148 $('auto-connect-network-wifi').disabled = !data.remembered; 1153 $('auto-connect-network-wifi').disabled = !data.remembered;
1149 detailsPage.hasSecurity = security != undefined; 1154 detailsPage.hasSecurity = security != undefined;
1150 } else if (onc.type == 'Wimax') { 1155 } else if (onc.type == 'Wimax') {
1151 OptionsPage.showTab($('wimax-network-nav-tab')); 1156 OptionsPage.showTab($('wimax-network-nav-tab'));
1152 detailsPage.gsm = false; 1157 detailsPage.gsm = false;
1153 detailsPage.shared = data.shared; 1158 detailsPage.shared = data.shared;
1154 detailsPage.showPreferred = data.remembered; 1159 detailsPage.showPreferred = data.remembered;
1155 $('wimax-connection-state').textContent = connectionStateString; 1160 $('wimax-connection-state').textContent = connectionStateString;
1161 $('wimax-restricted-pool').textContent =
1162 onc.getTranslatedValue('Restricted');
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-pool').textContent =
1192 onc.getTranslatedValue('Restricted');
1183 $('error-state').textContent = data.errorMessage; 1193 $('error-state').textContent = data.errorMessage;
1184 $('manufacturer').textContent = 1194 $('manufacturer').textContent =
1185 onc.getActiveValue('Cellular.Manufacturer'); 1195 onc.getActiveValue('Cellular.Manufacturer');
1186 $('model-id').textContent = onc.getActiveValue('Cellular.ModelID'); 1196 $('model-id').textContent = onc.getActiveValue('Cellular.ModelID');
1187 $('firmware-revision').textContent = 1197 $('firmware-revision').textContent =
1188 onc.getActiveValue('Cellular.FirmwareRevision'); 1198 onc.getActiveValue('Cellular.FirmwareRevision');
1189 $('hardware-revision').textContent = 1199 $('hardware-revision').textContent =
1190 onc.getActiveValue('Cellular.HardwareRevision'); 1200 onc.getActiveValue('Cellular.HardwareRevision');
1191 $('mdn').textContent = onc.getActiveValue('Cellular.MDN'); 1201 $('mdn').textContent = onc.getActiveValue('Cellular.MDN');
1192 1202
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 1351
1342 // Don't show page name in address bar and in history to prevent people 1352 // 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. 1353 // navigate here by hand and solve issue with page session restore.
1344 PageManager.showPageByName('detailsInternetPage', false); 1354 PageManager.showPageByName('detailsInternetPage', false);
1345 }; 1355 };
1346 1356
1347 return { 1357 return {
1348 DetailsInternetPage: DetailsInternetPage 1358 DetailsInternetPage: DetailsInternetPage
1349 }; 1359 };
1350 }); 1360 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698