Chromium Code Reviews| 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 /** | 18 /** |
| 19 * Helper function to get the "Active" value of a property from a dictionary | 19 * Gets the value of a property from a dictionary |data| that includes ONC |
| 20 * that includes ONC managed properties, e.g. getActiveValue(data, 'Name'). | 20 * managed properties, e.g. getManagedValue(data, 'Name'). See notes for |
| 21 * We use (data, key) instead of getActiveValue(data[key]) so that we can | 21 * getManagedProperty. |
| 22 * (possibly) add ONC key validation once all properties use ONC. | |
| 23 * @param {object} data The properties dictionary. | 22 * @param {object} data The properties dictionary. |
| 24 * @param {string} key The property key. | 23 * @param {string} key The property key. |
| 25 * @return {*} the property value or undefined. | 24 * @param {string} type (Optional) The type of property to get: |
| 25 * 'active' (default) - gets the active value | |
|
pneubeck (no reviews)
2014/08/19 19:26:37
These type strings could be more enum like (e.g. u
stevenjb
2014/08/19 23:20:17
The reason I didn't use separate functions was to
| |
| 26 * 'translated' - gets the traslated or active value | |
| 27 * 'recommended' - gets the recommended value | |
| 28 * @return {*} The property value or undefined. | |
| 26 */ | 29 */ |
| 27 function getActiveValue(data, key) { | 30 function getManagedValue(data, key, type) { |
| 28 if (!(key in data)) | 31 var property = getManagedProperty(data, key); |
| 29 return undefined; | |
| 30 var property = data[key]; | |
| 31 if (typeof property != 'object') | 32 if (typeof property != 'object') |
| 32 return property; | 33 return property; |
| 34 if (type == 'recommended') | |
| 35 return getRecommendedValue(property); | |
| 36 if (type == 'translated' && 'Translated' in property) | |
| 37 return property['Translated']; | |
| 38 // Otherwise get the Active value (defalt behavior). | |
| 33 if ('Active' in property) | 39 if ('Active' in property) |
| 34 return property['Active']; | 40 return property['Active']; |
| 41 // If no Active value is defined, return the effective value. | |
| 42 return getEffectiveValue(property); | |
| 43 } | |
| 44 | |
| 45 /** | |
| 46 * Get the recommended value from a Managed property ONC dictionary. | |
| 47 * @param {object} property The managed property ONC dictionary. | |
| 48 * @return {*} the effective value or undefined. | |
| 49 */ | |
| 50 function getRecommendedValue(property) { | |
| 51 if (property['UserEditable']) | |
| 52 return property['UserPolicy']; | |
| 53 if (property['DeviceEditable']) | |
| 54 return property['DevicePolicy']; | |
| 55 // No value recommended by policy. | |
| 56 return undefined; | |
| 57 } | |
| 58 | |
| 59 /** | |
| 60 * Get the effective value from a Managed property ONC dictionary. | |
| 61 * @param {object} property The managed property ONC dictionary. | |
| 62 * @return {*} The effective value or undefined. | |
| 63 */ | |
| 64 function getEffectiveValue(property) { | |
| 35 if ('Effective' in property) { | 65 if ('Effective' in property) { |
| 36 var effective = property.Effective; | 66 var effective = property.Effective; |
| 37 if (effective in property) | 67 if (effective in property) |
| 38 return property[effective]; | 68 return property[effective]; |
| 39 } | 69 } |
| 40 return undefined; | 70 return undefined; |
| 41 } | 71 } |
| 42 | 72 |
| 43 /** | 73 /** |
| 44 * Helper function for nested ONC properties, e.g. data[WiFi][Strength]. | 74 * Gets either a managed property dictionary or an unmanaged value from |
| 45 * @param {object|string} property The property which must ether be | 75 * dictionary |data| that includes ONC managed properties. This supports |
| 46 * a dictionary object or not be present. | 76 * nested dictionaries, e.g. getManagedProperty(data, 'VPN.Type'). |
| 47 * @return {*} the property value or undefined. | 77 * @param {object} data The properties dictionary. |
| 78 * @param {string} key The property key. | |
| 79 * @return {*} The property value or dictionary if it exists, otherwise | |
| 80 * undefined. | |
| 48 */ | 81 */ |
| 49 function getActiveDictionaryValue(data, dict, key) { | 82 function getManagedProperty(data, key) { |
| 50 if (!(dict in data)) | 83 while (true) { |
| 51 return undefined; | 84 var index = key.indexOf('.'); |
| 52 return getActiveValue(data[dict], key); | 85 if (index < 0) |
| 86 break; | |
| 87 var keyComponent = key.substr(0, index); | |
| 88 if (!(keyComponent in data)) | |
| 89 return undefined; | |
| 90 data = data[keyComponent]; | |
| 91 key = key.substr(index + 1); | |
| 92 } | |
| 93 return data[key]; | |
| 53 } | 94 } |
| 54 | 95 |
| 55 /** | 96 /** |
| 56 * Helper function to set hidden attribute for elements matching a selector. | 97 * Helper function to set hidden attribute for elements matching a selector. |
| 57 * @param {string} selector CSS selector for extracting a list of elements. | 98 * @param {string} selector CSS selector for extracting a list of elements. |
| 58 * @param {bool} hidden New hidden value. | 99 * @param {bool} hidden New hidden value. |
| 59 */ | 100 */ |
| 60 function updateHidden(selector, hidden) { | 101 function updateHidden(selector, hidden) { |
| 61 var elements = cr.doc.querySelectorAll(selector); | 102 var elements = cr.doc.querySelectorAll(selector); |
| 62 for (var i = 0, el; el = elements[i]; i++) { | 103 for (var i = 0, el; el = elements[i]; i++) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 return loadTimeData.getString('OncStateUnknown'); | 169 return loadTimeData.getString('OncStateUnknown'); |
| 129 } | 170 } |
| 130 | 171 |
| 131 /** | 172 /** |
| 132 * Returns the display name for the network represented by 'data'. | 173 * Returns the display name for the network represented by 'data'. |
| 133 * @param {Object} data The network ONC dictionary. | 174 * @param {Object} data The network ONC dictionary. |
| 134 */ | 175 */ |
| 135 function getNetworkName(data) { | 176 function getNetworkName(data) { |
| 136 if (data.type == 'Ethernet') | 177 if (data.type == 'Ethernet') |
| 137 return loadTimeData.getString('ethernetName'); | 178 return loadTimeData.getString('ethernetName'); |
| 138 return getActiveValue(data, 'Name'); | 179 return getManagedValue(data, 'Name'); |
| 139 } | 180 } |
| 140 | 181 |
| 141 ///////////////////////////////////////////////////////////////////////////// | 182 ///////////////////////////////////////////////////////////////////////////// |
| 142 // DetailsInternetPage class: | 183 // DetailsInternetPage class: |
| 143 | 184 |
| 144 /** | 185 /** |
| 145 * Encapsulated handling of ChromeOS internet details overlay page. | 186 * Encapsulated handling of ChromeOS internet details overlay page. |
| 146 * @constructor | 187 * @constructor |
| 147 */ | 188 */ |
| 148 function DetailsInternetPage() { | 189 function DetailsInternetPage() { |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { | 942 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { |
| 902 if (data.type == 'Ethernet') { | 943 if (data.type == 'Ethernet') { |
| 903 // Ethernet can never be connected or disconnected and can always be | 944 // Ethernet can never be connected or disconnected and can always be |
| 904 // configured (e.g. to set security). | 945 // configured (e.g. to set security). |
| 905 $('details-internet-login').hidden = true; | 946 $('details-internet-login').hidden = true; |
| 906 $('details-internet-disconnect').hidden = true; | 947 $('details-internet-disconnect').hidden = true; |
| 907 $('details-internet-configure').hidden = false; | 948 $('details-internet-configure').hidden = false; |
| 908 return; | 949 return; |
| 909 } | 950 } |
| 910 | 951 |
| 911 var connectState = getActiveValue(data, 'ConnectionState'); | 952 var connectState = getManagedValue(data, 'ConnectionState'); |
| 912 if (connectState == 'NotConnected') { | 953 if (connectState == 'NotConnected') { |
| 913 $('details-internet-login').hidden = false; | 954 $('details-internet-login').hidden = false; |
| 914 // Connecting to an unconfigured network might trigger certificate | 955 // Connecting to an unconfigured network might trigger certificate |
| 915 // installation UI. Until that gets handled here, always enable the | 956 // installation UI. Until that gets handled here, always enable the |
| 916 // Connect button. | 957 // Connect button. |
| 917 $('details-internet-login').disabled = false; | 958 $('details-internet-login').disabled = false; |
| 918 $('details-internet-disconnect').hidden = true; | 959 $('details-internet-disconnect').hidden = true; |
| 919 } else { | 960 } else { |
| 920 $('details-internet-login').hidden = true; | 961 $('details-internet-login').hidden = true; |
| 921 $('details-internet-disconnect').hidden = false; | 962 $('details-internet-disconnect').hidden = false; |
| 922 } | 963 } |
| 923 | 964 |
| 924 var connectable = getActiveValue(data, 'Connectable'); | 965 var connectable = getManagedValue(data, 'Connectable'); |
| 925 if (connectState != 'Connected' && | 966 if (connectState != 'Connected' && |
| 926 (!connectable || this.hasSecurity || | 967 (!connectable || this.hasSecurity || |
| 927 (data.type == 'Wimax' || data.type == 'VPN'))) { | 968 (data.type == 'Wimax' || data.type == 'VPN'))) { |
| 928 $('details-internet-configure').hidden = false; | 969 $('details-internet-configure').hidden = false; |
| 929 } else { | 970 } else { |
| 930 $('details-internet-configure').hidden = true; | 971 $('details-internet-configure').hidden = true; |
| 931 } | 972 } |
| 932 }; | 973 }; |
| 933 | 974 |
| 934 DetailsInternetPage.updateConnectionData = function(update) { | 975 DetailsInternetPage.updateConnectionData = function(update) { |
| 935 var detailsPage = DetailsInternetPage.getInstance(); | 976 var detailsPage = DetailsInternetPage.getInstance(); |
| 936 if (!detailsPage.visible) | 977 if (!detailsPage.visible) |
| 937 return; | 978 return; |
| 938 | 979 |
| 939 var data = $('connection-state').data; | 980 var data = $('connection-state').data; |
| 940 if (!data) | 981 if (!data) |
| 941 return; | 982 return; |
| 942 | 983 |
| 943 if (update.servicePath != data.servicePath) | 984 if (update.servicePath != data.servicePath) |
| 944 return; | 985 return; |
| 945 | 986 |
| 946 // Update our cached data object. | 987 // Update our cached data object. |
| 947 updateDataObject(data, update); | 988 updateDataObject(data, update); |
| 948 | 989 |
| 949 var connectionState = getActiveValue(data, 'ConnectionState'); | 990 var connectionState = getManagedValue(data, 'ConnectionState'); |
| 950 var connectionStateString = networkOncStateString(connectionState); | 991 var connectionStateString = networkOncStateString(connectionState); |
| 951 detailsPage.deviceConnected = data.deviceConnected; | 992 detailsPage.deviceConnected = data.deviceConnected; |
| 952 detailsPage.connected = connectionState == 'Connected'; | 993 detailsPage.connected = connectionState == 'Connected'; |
| 953 $('connection-state').textContent = connectionStateString; | 994 $('connection-state').textContent = connectionStateString; |
| 954 | 995 |
| 955 this.updateConnectionButtonVisibilty(data); | 996 this.updateConnectionButtonVisibilty(data); |
| 956 | 997 |
| 957 if (data.type == 'WiFi') { | 998 if (data.type == 'WiFi') { |
| 958 $('wifi-connection-state').textContent = connectionStateString; | 999 $('wifi-connection-state').textContent = connectionStateString; |
| 959 } else if (data.type == 'Wimax') { | 1000 } else if (data.type == 'Wimax') { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 975 $('change-pin').hidden = !lockEnabled; | 1016 $('change-pin').hidden = !lockEnabled; |
| 976 } | 1017 } |
| 977 } | 1018 } |
| 978 | 1019 |
| 979 $('connection-state').data = data; | 1020 $('connection-state').data = data; |
| 980 }; | 1021 }; |
| 981 | 1022 |
| 982 DetailsInternetPage.showDetailedInfo = function(data) { | 1023 DetailsInternetPage.showDetailedInfo = function(data) { |
| 983 var detailsPage = DetailsInternetPage.getInstance(); | 1024 var detailsPage = DetailsInternetPage.getInstance(); |
| 984 | 1025 |
| 985 data.type = getActiveValue(data, 'Type'); // Get Active Type value. | 1026 data.type = getManagedValue(data, 'Type'); // Get Active Type value. |
| 986 | 1027 |
| 987 // Populate header | 1028 // Populate header |
| 988 $('network-details-title').textContent = getNetworkName(data); | 1029 $('network-details-title').textContent = getNetworkName(data); |
| 989 var connectionState = getActiveValue(data, 'ConnectionState'); | 1030 var connectionState = getManagedValue(data, 'ConnectionState'); |
| 990 var connectionStateString = networkOncStateString(connectionState); | 1031 var connectionStateString = networkOncStateString(connectionState); |
| 991 detailsPage.connected = connectionState == 'Connected'; | 1032 detailsPage.connected = connectionState == 'Connected'; |
| 992 $('network-details-subtitle-status').textContent = connectionStateString; | 1033 $('network-details-subtitle-status').textContent = connectionStateString; |
| 993 var typeKey = null; | 1034 var typeKey = null; |
| 994 switch (data.type) { | 1035 switch (data.type) { |
| 995 case 'Ethernet': | 1036 case 'Ethernet': |
| 996 typeKey = 'ethernetTitle'; | 1037 typeKey = 'ethernetTitle'; |
| 997 break; | 1038 break; |
| 998 case 'WiFi': | 1039 case 'WiFi': |
| 999 typeKey = 'wifiTitle'; | 1040 typeKey = 'wifiTitle'; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1123 nameServerModels.push({value: nameServersUser[i] || ''}); | 1164 nameServerModels.push({value: nameServersUser[i] || ''}); |
| 1124 | 1165 |
| 1125 $(data.nameServerType + '-dns-radio').checked = true; | 1166 $(data.nameServerType + '-dns-radio').checked = true; |
| 1126 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); | 1167 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); |
| 1127 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); | 1168 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); |
| 1128 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); | 1169 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); |
| 1129 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); | 1170 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); |
| 1130 | 1171 |
| 1131 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); | 1172 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); |
| 1132 | 1173 |
| 1133 var macAddress = getActiveValue(data, 'MacAddress'); | 1174 var macAddress = getManagedValue(data, 'MacAddress'); |
| 1134 if (macAddress) { | 1175 if (macAddress) { |
| 1135 $('hardware-address').textContent = macAddress; | 1176 $('hardware-address').textContent = macAddress; |
| 1136 $('hardware-address-row').style.display = 'table-row'; | 1177 $('hardware-address-row').style.display = 'table-row'; |
| 1137 } else { | 1178 } else { |
| 1138 // This is most likely a device without a hardware address. | 1179 // This is most likely a device without a hardware address. |
| 1139 $('hardware-address-row').style.display = 'none'; | 1180 $('hardware-address-row').style.display = 'none'; |
| 1140 } | 1181 } |
| 1141 | 1182 |
| 1142 var setOrHideParent = function(field, property) { | 1183 var setOrHideParent = function(field, property) { |
| 1143 if (property) { | 1184 if (property) { |
| 1144 $(field).textContent = property; | 1185 $(field).textContent = property; |
| 1145 $(field).parentElement.hidden = false; | 1186 $(field).parentElement.hidden = false; |
| 1146 } else { | 1187 } else { |
| 1147 $(field).parentElement.hidden = true; | 1188 $(field).parentElement.hidden = true; |
| 1148 } | 1189 } |
| 1149 }; | 1190 }; |
| 1150 | 1191 |
| 1151 var networkName = getNetworkName(data); | 1192 var networkName = getNetworkName(data); |
| 1152 | 1193 |
| 1153 // Signal strength as percentage (for WiFi and Wimax). | 1194 // Signal strength as percentage (for WiFi and Wimax). |
| 1154 var signalStrength; | 1195 var signalStrength; |
| 1155 if (data.type == 'WiFi' || data.type == 'Wimax') { | 1196 if (data.type == 'WiFi' || data.type == 'Wimax') { |
| 1156 signalStrength = | 1197 signalStrength = getManagedValue(data, data.type + '.SignalStrength'); |
| 1157 getActiveDictionaryValue(data, data.type, 'SignalStrength'); | |
| 1158 } | 1198 } |
| 1159 if (!signalStrength) | 1199 if (!signalStrength) |
| 1160 signalStrength = 0; | 1200 signalStrength = 0; |
| 1161 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1201 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
| 1162 var strengthString = strengthFormat.replace('$1', signalStrength); | 1202 var strengthString = strengthFormat.replace('$1', signalStrength); |
| 1163 | 1203 |
| 1164 detailsPage.type = data.type; | 1204 detailsPage.type = data.type; |
| 1165 if (data.type == 'WiFi') { | 1205 if (data.type == 'WiFi') { |
| 1166 assert(data.WiFi, 'WiFi network has no WiFi object' + networkName); | 1206 assert('WiFi' in data, 'WiFi network has no WiFi object' + networkName); |
| 1167 OptionsPage.showTab($('wifi-network-nav-tab')); | 1207 OptionsPage.showTab($('wifi-network-nav-tab')); |
| 1168 detailsPage.gsm = false; | 1208 detailsPage.gsm = false; |
| 1169 detailsPage.shared = data.shared; | 1209 detailsPage.shared = data.shared; |
| 1170 $('wifi-connection-state').textContent = connectionStateString; | 1210 $('wifi-connection-state').textContent = connectionStateString; |
| 1171 var ssid = getActiveDictionaryValue(data, 'WiFi', 'SSID'); | 1211 var ssid = getManagedValue(data, 'WiFi.SSID'); |
| 1172 $('wifi-ssid').textContent = ssid ? ssid : networkName; | 1212 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
| 1173 setOrHideParent('wifi-bssid', | 1213 setOrHideParent('wifi-bssid', getManagedValue(data, 'WiFi.BSSID')); |
| 1174 getActiveDictionaryValue(data, 'WiFi', 'BSSID')); | 1214 var security = getManagedValue(data, 'WiFi.Security'); |
| 1175 var security = getActiveDictionaryValue(data, 'WiFi', 'Security'); | |
| 1176 if (security == 'None') | 1215 if (security == 'None') |
| 1177 security = undefined; | 1216 security = undefined; |
| 1178 setOrHideParent('wifi-security', security); | 1217 setOrHideParent('wifi-security', security); |
| 1179 // Frequency is in MHz. | 1218 // Frequency is in MHz. |
| 1180 var frequency = getActiveDictionaryValue(data, 'WiFi', 'Frequency'); | 1219 var frequency = getManagedValue(data, 'WiFi.Frequency'); |
| 1181 if (!frequency) | 1220 if (!frequency) |
| 1182 frequency = 0; | 1221 frequency = 0; |
| 1183 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); | 1222 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); |
| 1184 frequencyFormat = frequencyFormat.replace('$1', frequency); | 1223 frequencyFormat = frequencyFormat.replace('$1', frequency); |
| 1185 $('wifi-frequency').textContent = frequencyFormat; | 1224 $('wifi-frequency').textContent = frequencyFormat; |
| 1186 $('wifi-signal-strength').textContent = strengthString; | 1225 $('wifi-signal-strength').textContent = strengthString; |
| 1187 setOrHideParent('wifi-hardware-address', | 1226 setOrHideParent('wifi-hardware-address', |
| 1188 getActiveValue(data, 'MacAddress')); | 1227 getManagedValue(data, 'MacAddress')); |
| 1189 detailsPage.showPreferred = data.remembered; | 1228 detailsPage.showPreferred = data.remembered; |
| 1190 $('prefer-network-wifi').checked = data.preferred.value; | 1229 var priority = getManagedValue(data, 'Priority'); |
| 1230 $('prefer-network-wifi').checked = priority > 0; | |
| 1191 $('prefer-network-wifi').disabled = !data.remembered; | 1231 $('prefer-network-wifi').disabled = !data.remembered; |
| 1192 $('auto-connect-network-wifi').checked = | 1232 $('auto-connect-network-wifi').checked = |
| 1193 getActiveValue(data, 'AutoConnect'); | 1233 getManagedValue(data, 'AutoConnect'); |
| 1194 $('auto-connect-network-wifi').disabled = !data.remembered; | 1234 $('auto-connect-network-wifi').disabled = !data.remembered; |
| 1195 detailsPage.hasSecurity = security != undefined; | 1235 detailsPage.hasSecurity = security != undefined; |
| 1196 } else if (data.type == 'Wimax') { | 1236 } else if (data.type == 'Wimax') { |
| 1197 assert(data.Wimax, 'Wimax network has no Wimax object' + networkName); | 1237 assert('Wimax' in data, |
| 1238 'Wimax network has no Wimax object' + networkName); | |
| 1198 OptionsPage.showTab($('wimax-network-nav-tab')); | 1239 OptionsPage.showTab($('wimax-network-nav-tab')); |
| 1199 detailsPage.gsm = false; | 1240 detailsPage.gsm = false; |
| 1200 detailsPage.shared = data.shared; | 1241 detailsPage.shared = data.shared; |
| 1201 detailsPage.showPreferred = data.remembered; | 1242 detailsPage.showPreferred = data.remembered; |
| 1202 $('wimax-connection-state').textContent = connectionStateString; | 1243 $('wimax-connection-state').textContent = connectionStateString; |
| 1203 $('auto-connect-network-wimax').checked = | 1244 $('auto-connect-network-wimax').checked = |
| 1204 getActiveValue(data, 'AutoConnect'); | 1245 getManagedValue(data, 'AutoConnect'); |
| 1205 $('auto-connect-network-wimax').disabled = !data.remembered; | 1246 $('auto-connect-network-wimax').disabled = !data.remembered; |
| 1206 var identity; | 1247 var identity; |
| 1207 if (data.Wimax.EAP) | 1248 if (data.Wimax.EAP) |
| 1208 identity = getActiveValue(data.Wimax.EAP, 'Identity'); | 1249 identity = getManagedValue(data.Wimax.EAP, 'Identity'); |
| 1209 setOrHideParent('wimax-eap-identity', identity); | 1250 setOrHideParent('wimax-eap-identity', identity); |
| 1210 $('wimax-signal-strength').textContent = strengthString; | 1251 $('wimax-signal-strength').textContent = strengthString; |
| 1211 } else if (data.type == 'Cellular') { | 1252 } else if (data.type == 'Cellular') { |
| 1212 assert(data.Cellular, | 1253 assert('Cellular' in data, |
| 1213 'Cellular network has no Cellular object' + networkName); | 1254 'Cellular network has no Cellular object' + networkName); |
| 1214 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1255 OptionsPage.showTab($('cellular-conn-nav-tab')); |
| 1215 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1256 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
| 1216 var carrierSelector = $('select-carrier'); | 1257 var carrierSelector = $('select-carrier'); |
| 1217 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1258 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
| 1218 carrierSelector.options.length = 0; | 1259 carrierSelector.options.length = 0; |
| 1219 for (var i = 0; i < data.carriers.length; ++i) { | 1260 for (var i = 0; i < data.carriers.length; ++i) { |
| 1220 var option = document.createElement('option'); | 1261 var option = document.createElement('option'); |
| 1221 option.textContent = data.carriers[i]; | 1262 option.textContent = data.carriers[i]; |
| 1222 carrierSelector.add(option); | 1263 carrierSelector.add(option); |
| 1223 } | 1264 } |
| 1224 carrierSelector.selectedIndex = data.currentCarrierIndex; | 1265 carrierSelector.selectedIndex = data.currentCarrierIndex; |
| 1225 } else { | 1266 } else { |
| 1226 $('service-name').textContent = networkName; | 1267 $('service-name').textContent = networkName; |
| 1227 } | 1268 } |
| 1228 | 1269 |
| 1229 $('network-technology').textContent = | 1270 $('network-technology').textContent = |
| 1230 getActiveDictionaryValue(data, 'Cellular', 'NetworkTechnology'); | 1271 getManagedValue(data, 'Cellular.NetworkTechnology'); |
| 1231 $('activation-state').textContent = data.activationState; | 1272 $('activation-state').textContent = data.activationState; |
| 1232 $('roaming-state').textContent = data.roamingState; | 1273 $('roaming-state').textContent = data.roamingState; |
| 1233 $('restricted-pool').textContent = data.restrictedPool; | 1274 $('restricted-pool').textContent = data.restrictedPool; |
| 1234 $('error-state').textContent = data.errorMessage; | 1275 $('error-state').textContent = data.errorMessage; |
| 1235 $('manufacturer').textContent = | 1276 $('manufacturer').textContent = |
| 1236 getActiveDictionaryValue(data, 'Cellular', 'Manufacturer'); | 1277 getManagedValue(data, 'Cellular.Manufacturer'); |
| 1237 $('model-id').textContent = | 1278 $('model-id').textContent = getManagedValue(data, 'Cellular.ModelID'); |
| 1238 getActiveDictionaryValue(data, 'Cellular', 'ModelID'); | |
| 1239 $('firmware-revision').textContent = | 1279 $('firmware-revision').textContent = |
| 1240 getActiveDictionaryValue(data, 'Cellular', 'FirmwareRevision'); | 1280 getManagedValue(data, 'Cellular.FirmwareRevision'); |
| 1241 $('hardware-revision').textContent = | 1281 $('hardware-revision').textContent = |
| 1242 getActiveDictionaryValue(data, 'Cellular', 'HardwareRevision'); | 1282 getManagedValue(data, 'Cellular.HardwareRevision'); |
| 1243 $('mdn').textContent = getActiveDictionaryValue(data, 'Cellular', 'MDN'); | 1283 $('mdn').textContent = getManagedValue(data, 'Cellular.MDN'); |
| 1244 | 1284 |
| 1245 // Show ServingOperator properties only if available. | 1285 // Show ServingOperator properties only if available. |
| 1246 if (data.Cellular.ServingOperator) { | 1286 var servingOperatorName = |
| 1247 $('operator-name').textContent = | 1287 getManagedValue(data, 'Cellular.ServingOperator.Name'); |
| 1248 getActiveValue(data.Cellular.ServingOperator, 'Name'); | 1288 var servingOperatorCode = |
| 1249 $('operator-code').textContent = | 1289 getManagedValue(data, 'Cellular.ServingOperator.Code'); |
| 1250 getActiveValue(data.Cellular.ServingOperator, 'Code'); | 1290 if (servingOperatorName != undefined && |
| 1291 servingOperatorCode != undefined) { | |
| 1292 $('operator-name').textContent = servingOperatorName; | |
| 1293 $('operator-code').textContent = servingOperatorCode; | |
| 1251 } else { | 1294 } else { |
| 1252 $('operator-name').parentElement.hidden = true; | 1295 $('operator-name').parentElement.hidden = true; |
| 1253 $('operator-code').parentElement.hidden = true; | 1296 $('operator-code').parentElement.hidden = true; |
| 1254 } | 1297 } |
| 1255 // Make sure that GSM/CDMA specific properties that shouldn't be hidden | 1298 // Make sure that GSM/CDMA specific properties that shouldn't be hidden |
| 1256 // are visible. | 1299 // are visible. |
| 1257 updateHidden('#details-internet-page .gsm-only', false); | 1300 updateHidden('#details-internet-page .gsm-only', false); |
| 1258 updateHidden('#details-internet-page .cdma-only', false); | 1301 updateHidden('#details-internet-page .cdma-only', false); |
| 1259 | 1302 |
| 1260 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. | 1303 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. |
| 1261 setOrHideParent('esn', getActiveDictionaryValue(data, 'Cellular', 'ESN')); | 1304 setOrHideParent('esn', getManagedValue(data, 'Cellular.ESN')); |
| 1262 setOrHideParent( | 1305 setOrHideParent('imei', getManagedValue(data, 'Cellular.IMEI')); |
| 1263 'imei', getActiveDictionaryValue(data, 'Cellular', 'IMEI')); | 1306 setOrHideParent('meid', getManagedValue(data, 'Cellular.MEID')); |
| 1264 setOrHideParent( | 1307 setOrHideParent('min', getManagedValue(data, 'Cellular.MIN')); |
| 1265 'meid', getActiveDictionaryValue(data, 'Cellular', 'MEID')); | 1308 setOrHideParent('prl-version', |
| 1266 setOrHideParent('min', getActiveDictionaryValue(data, 'Cellular', 'MIN')); | 1309 getManagedValue(data, 'Cellular.PRLVersion')); |
| 1267 setOrHideParent( | |
| 1268 'prl-version', | |
| 1269 getActiveDictionaryValue(data, 'Cellular', 'PRLVersion')); | |
| 1270 | 1310 |
| 1271 var family = getActiveDictionaryValue(data, 'Cellular', 'GSM'); | 1311 var family = getManagedValue(data, 'Cellular.GSM'); |
| 1272 detailsPage.gsm = family == 'GSM'; | 1312 detailsPage.gsm = family == 'GSM'; |
| 1273 if (detailsPage.gsm) { | 1313 if (detailsPage.gsm) { |
| 1274 $('iccid').textContent = | 1314 $('iccid').textContent = getManagedValue(data, 'Cellular.ICCID'); |
| 1275 getActiveDictionaryValue(data, 'Cellular', 'ICCID'); | 1315 $('imsi').textContent = getManagedValue(data, 'Cellular.IMSI'); |
| 1276 $('imsi').textContent = | |
| 1277 getActiveDictionaryValue(data, 'Cellular', 'IMSI'); | |
| 1278 | 1316 |
| 1279 var apnSelector = $('select-apn'); | 1317 var apnSelector = $('select-apn'); |
| 1280 // Clear APN lists, keep only last element that "other". | 1318 // Clear APN lists, keep only last element that "other". |
| 1281 while (apnSelector.length != 1) | 1319 while (apnSelector.length != 1) |
| 1282 apnSelector.remove(0); | 1320 apnSelector.remove(0); |
| 1283 var otherOption = apnSelector[0]; | 1321 var otherOption = apnSelector[0]; |
| 1284 data.selectedApn = -1; | 1322 data.selectedApn = -1; |
| 1285 data.userApnIndex = -1; | 1323 data.userApnIndex = -1; |
| 1286 var apnList = data.providerApnList.value; | 1324 var apnList = data.providerApnList.value; |
| 1287 for (var i = 0; i < apnList.length; i++) { | 1325 for (var i = 0; i < apnList.length; i++) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1317 } | 1355 } |
| 1318 apnSelector.selectedIndex = data.selectedApn; | 1356 apnSelector.selectedIndex = data.selectedApn; |
| 1319 updateHidden('.apn-list-view', false); | 1357 updateHidden('.apn-list-view', false); |
| 1320 updateHidden('.apn-details-view', true); | 1358 updateHidden('.apn-details-view', true); |
| 1321 // TODO(stevenjb): Used managed properties for policy controlled value. | 1359 // TODO(stevenjb): Used managed properties for policy controlled value. |
| 1322 var lockEnabled = data.simCardLockEnabled.value; | 1360 var lockEnabled = data.simCardLockEnabled.value; |
| 1323 $('sim-card-lock-enabled').checked = lockEnabled; | 1361 $('sim-card-lock-enabled').checked = lockEnabled; |
| 1324 $('change-pin').hidden = !lockEnabled; | 1362 $('change-pin').hidden = !lockEnabled; |
| 1325 } | 1363 } |
| 1326 $('auto-connect-network-cellular').checked = | 1364 $('auto-connect-network-cellular').checked = |
| 1327 getActiveValue(data, 'AutoConnect'); | 1365 getManagedValue(data, 'AutoConnect'); |
| 1328 $('auto-connect-network-cellular').disabled = false; | 1366 $('auto-connect-network-cellular').disabled = false; |
| 1329 | 1367 |
| 1330 $('buyplan-details').hidden = !data.showBuyButton; | 1368 $('buyplan-details').hidden = !data.showBuyButton; |
| 1331 $('view-account-details').hidden = !data.showViewAccountButton; | 1369 $('view-account-details').hidden = !data.showViewAccountButton; |
| 1332 $('activate-details').hidden = !data.showActivateButton; | 1370 $('activate-details').hidden = !data.showActivateButton; |
| 1333 if (data.showActivateButton) { | 1371 if (data.showActivateButton) { |
| 1334 $('details-internet-login').hidden = true; | 1372 $('details-internet-login').hidden = true; |
| 1335 } | 1373 } |
| 1336 } else if (data.type == 'VPN') { | 1374 } else if (data.type == 'VPN') { |
| 1337 OptionsPage.showTab($('vpn-nav-tab')); | 1375 OptionsPage.showTab($('vpn-nav-tab')); |
| 1338 detailsPage.gsm = false; | 1376 detailsPage.gsm = false; |
| 1339 $('inet-service-name').textContent = networkName; | 1377 $('inet-service-name').textContent = networkName; |
| 1340 $('inet-provider-type').textContent = data.providerType; | 1378 $('inet-provider-type').textContent = |
| 1341 $('inet-username').textContent = data.username; | 1379 getManagedValue(data, 'VPN.Type', 'translated'); |
| 1380 var providerType = getManagedValue(data, 'VPN.Type', 'active'); | |
| 1381 var providerKey = 'VPN.' + providerType; | |
| 1382 $('inet-username').textContent = | |
| 1383 getManagedValue(data, providerKey + '.Username'); | |
| 1342 var inetServerHostname = $('inet-server-hostname'); | 1384 var inetServerHostname = $('inet-server-hostname'); |
| 1343 inetServerHostname.value = data.serverHostname.value; | 1385 inetServerHostname.value = getManagedValue(data, 'VPN.Host'); |
| 1344 inetServerHostname.resetHandler = function() { | 1386 inetServerHostname.resetHandler = function() { |
| 1345 PageManager.hideBubble(); | 1387 PageManager.hideBubble(); |
| 1346 inetServerHostname.value = data.serverHostname.recommendedValue; | 1388 var recommended = getManagedValue(data, 'VPN.Host', 'recommended'); |
| 1389 if (recommended) | |
|
pneubeck (no reviews)
2014/08/19 19:26:37
... recommended != undefined
stevenjb
2014/08/19 23:20:17
Sigh. Thanks. Done.
| |
| 1390 inetServerHostname.value = recommended; | |
| 1347 }; | 1391 }; |
| 1348 $('auto-connect-network-vpn').checked = | 1392 $('auto-connect-network-vpn').checked = |
| 1349 getActiveValue(data, 'AutoConnect'); | 1393 getManagedValue(data, 'AutoConnect'); |
| 1350 $('auto-connect-network-vpn').disabled = false; | 1394 $('auto-connect-network-vpn').disabled = false; |
| 1351 } else { | 1395 } else { |
| 1352 OptionsPage.showTab($('internet-nav-tab')); | 1396 OptionsPage.showTab($('internet-nav-tab')); |
| 1353 } | 1397 } |
| 1354 | 1398 |
| 1355 // Update controlled option indicators. | 1399 // Update controlled option indicators. |
| 1356 var indicators = cr.doc.querySelectorAll( | 1400 var indicators = cr.doc.querySelectorAll( |
| 1357 '#details-internet-page .controlled-setting-indicator'); | 1401 '#details-internet-page .controlled-setting-indicator'); |
| 1358 for (var i = 0; i < indicators.length; i++) { | 1402 for (var i = 0; i < indicators.length; i++) { |
| 1359 var attributeName = | 1403 var managed = indicators[i].hasAttribute('managed'); |
| 1360 indicators[i].hasAttribute('managed') ? 'managed' : 'data'; | 1404 var attributeName = managed ? 'managed' : 'data'; |
| 1361 var propName = indicators[i].getAttribute(attributeName); | 1405 var propName = indicators[i].getAttribute(attributeName); |
| 1362 if (!propName || !data[propName]) | 1406 if (!propName) |
| 1407 continue; | |
| 1408 var propValue = | |
| 1409 managed ? getManagedProperty(data, propName) : data[propName]; | |
| 1410 if (propValue == undefined) | |
| 1363 continue; | 1411 continue; |
| 1364 var event; | 1412 var event; |
| 1365 if (attributeName == 'managed') | 1413 if (managed) |
| 1366 event = detailsPage.createManagedEvent_(propName, data[propName]); | 1414 event = detailsPage.createManagedEvent_(propName, propValue); |
| 1367 else | 1415 else |
| 1368 event = detailsPage.createControlledEvent_(propName, data[propName]); | 1416 event = detailsPage.createControlledEvent_(propName, propValue); |
| 1369 indicators[i].handlePrefChange(event); | 1417 indicators[i].handlePrefChange(event); |
| 1370 var forElement = $(indicators[i].getAttribute('for')); | 1418 var forElement = $(indicators[i].getAttribute('for')); |
| 1371 if (forElement) { | 1419 if (forElement) { |
| 1372 if (event.value.controlledBy == 'policy') | 1420 if (event.value.controlledBy == 'policy') |
| 1373 forElement.disabled = true; | 1421 forElement.disabled = true; |
| 1374 if (forElement.resetHandler) | 1422 if (forElement.resetHandler) |
| 1375 indicators[i].resetHandler = forElement.resetHandler; | 1423 indicators[i].resetHandler = forElement.resetHandler; |
| 1376 } | 1424 } |
| 1377 } | 1425 } |
| 1378 | 1426 |
| 1379 detailsPage.updateControls(); | 1427 detailsPage.updateControls(); |
| 1380 | 1428 |
| 1381 // Don't show page name in address bar and in history to prevent people | 1429 // Don't show page name in address bar and in history to prevent people |
| 1382 // navigate here by hand and solve issue with page session restore. | 1430 // navigate here by hand and solve issue with page session restore. |
| 1383 PageManager.showPageByName('detailsInternetPage', false); | 1431 PageManager.showPageByName('detailsInternetPage', false); |
| 1384 }; | 1432 }; |
| 1385 | 1433 |
| 1386 return { | 1434 return { |
| 1387 DetailsInternetPage: DetailsInternetPage | 1435 DetailsInternetPage: DetailsInternetPage |
| 1388 }; | 1436 }; |
| 1389 }); | 1437 }); |
| OLD | NEW |