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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 event.value.controlledBy = 'policy'; | 372 event.value.controlledBy = 'policy'; |
373 } | 373 } |
374 | 374 |
375 return event; | 375 return event; |
376 }, | 376 }, |
377 | 377 |
378 /** | 378 /** |
379 * Update details page controls. | 379 * Update details page controls. |
380 */ | 380 */ |
381 updateControls: function() { | 381 updateControls: function() { |
382 var onc = this.onc_; | |
383 | |
382 // Only show ipconfig section if network is connected OR if nothing on | 384 // Only show ipconfig section if network is connected OR if nothing on |
383 // this device is connected. This is so that you can fix the ip configs | 385 // this device is connected. This is so that you can fix the ip configs |
384 // if you can't connect to any network. | 386 // if you can't connect to any network. |
385 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, | 387 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, |
386 // we need to redo this logic to allow configuration of all networks. | 388 // we need to redo this logic to allow configuration of all networks. |
387 $('ipconfig-section').hidden = !this.connected && this.deviceConnected; | 389 var connected = onc.getActiveValue('ConnectionState') == 'Connected'; |
388 $('ipconfig-dns-section').hidden = | 390 $('ipconfig-section').hidden = !connected && this.deviceConnected; |
389 !this.connected && this.deviceConnected; | 391 $('ipconfig-dns-section').hidden = !connected && this.deviceConnected; |
390 | 392 |
391 // Network type related. | 393 // Network type related. |
392 updateHidden('#details-internet-page .cellular-details', | 394 updateHidden('#details-internet-page .cellular-details', |
393 this.type_ != 'Cellular'); | 395 this.type_ != 'Cellular'); |
394 updateHidden('#details-internet-page .wifi-details', | 396 updateHidden('#details-internet-page .wifi-details', |
395 this.type_ != 'WiFi'); | 397 this.type_ != 'WiFi'); |
396 updateHidden('#details-internet-page .wimax-details', | 398 updateHidden('#details-internet-page .wimax-details', |
397 this.type_ != 'Wimax'); | 399 this.type_ != 'Wimax'); |
398 updateHidden('#details-internet-page .vpn-details', this.type_ != 'VPN'); | 400 updateHidden('#details-internet-page .vpn-details', this.type_ != 'VPN'); |
399 updateHidden('#details-internet-page .proxy-details', !this.showProxy); | 401 updateHidden('#details-internet-page .proxy-details', !this.showProxy); |
400 | 402 |
401 // Cellular | 403 // Cellular |
402 | 404 |
403 // Conditionally call updateHidden on .gsm-only, so that we don't unhide | 405 // Conditionally call updateHidden on .gsm-only, so that we don't unhide |
404 // a previously hidden element. | 406 // a previously hidden element. |
405 if (this.gsm) | 407 if (this.gsm) |
406 updateHidden('#details-internet-page .cdma-only', true); | 408 updateHidden('#details-internet-page .cdma-only', true); |
407 else | 409 else |
408 updateHidden('#details-internet-page .gsm-only', true); | 410 updateHidden('#details-internet-page .gsm-only', true); |
409 | 411 |
410 // Wifi | 412 // Wifi |
411 | 413 |
412 // Hide network tab for VPN. | 414 // Hide network tab for VPN. |
413 updateHidden('#details-internet-page .network-details', | 415 updateHidden('#details-internet-page .network-details', |
414 this.type_ == 'VPN'); | 416 this.type_ == 'VPN'); |
415 | 417 |
416 // Password and shared. | 418 // Password and shared. |
419 var source = onc.getSource(); | |
420 var shared = source == 'Device'; | |
pneubeck (no reviews)
2014/09/09 19:35:31
previously the meaning of shared was
source !=
stevenjb
2014/09/10 00:00:55
That was deliberate, I think the new logic is bett
| |
417 updateHidden('#details-internet-page #password-details', | 421 updateHidden('#details-internet-page #password-details', |
418 this.type_ != 'WiFi' || !this.hasSecurity); | 422 this.type_ != 'WiFi' || onc.getWiFiSecurity() == 'None'); |
419 updateHidden('#details-internet-page #wifi-shared-network', | 423 updateHidden('#details-internet-page #wifi-shared-network', !shared); |
420 !this.shared); | 424 updateHidden('#details-internet-page #prefer-network', source == 'None'); |
421 updateHidden('#details-internet-page #prefer-network', | |
422 !this.showPreferred); | |
423 | 425 |
424 // WiMAX. | 426 // WiMAX. |
425 updateHidden('#details-internet-page #wimax-shared-network', | 427 updateHidden('#details-internet-page #wimax-shared-network', !shared); |
426 !this.shared); | |
427 | 428 |
428 // Proxy | 429 // Proxy |
429 this.updateProxyBannerVisibility_(); | 430 this.updateProxyBannerVisibility_(); |
430 this.toggleSingleProxy_(); | 431 this.toggleSingleProxy_(); |
431 if ($('manual-proxy').checked) | 432 if ($('manual-proxy').checked) |
432 this.enableManualProxy_(); | 433 this.enableManualProxy_(); |
433 else | 434 else |
434 this.disableManualProxy_(); | 435 this.disableManualProxy_(); |
435 }, | 436 }, |
436 | 437 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 // Connect button. | 572 // Connect button. |
572 $('details-internet-login').disabled = false; | 573 $('details-internet-login').disabled = false; |
573 $('details-internet-disconnect').hidden = true; | 574 $('details-internet-disconnect').hidden = true; |
574 } else { | 575 } else { |
575 $('details-internet-login').hidden = true; | 576 $('details-internet-login').hidden = true; |
576 $('details-internet-disconnect').hidden = false; | 577 $('details-internet-disconnect').hidden = false; |
577 } | 578 } |
578 | 579 |
579 var connectable = onc.getActiveValue('Connectable'); | 580 var connectable = onc.getActiveValue('Connectable'); |
580 if (connectState != 'Connected' && | 581 if (connectState != 'Connected' && |
581 (!connectable || this.hasSecurity || | 582 (!connectable || onc.getWiFiSecurity() != 'None' || |
582 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) { | 583 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) { |
583 $('details-internet-configure').hidden = false; | 584 $('details-internet-configure').hidden = false; |
584 } else { | 585 } else { |
585 $('details-internet-configure').hidden = true; | 586 $('details-internet-configure').hidden = true; |
586 } | 587 } |
587 }, | 588 }, |
588 | 589 |
589 populateHeader_: function() { | 590 populateHeader_: function() { |
590 var onc = this.onc_; | 591 var onc = this.onc_; |
591 | 592 |
592 $('network-details-title').textContent = onc.getTranslatedValue('Name'); | 593 $('network-details-title').textContent = onc.getTranslatedValue('Name'); |
593 var connectionState = onc.getActiveValue('ConnectionState'); | 594 var connectionState = onc.getActiveValue('ConnectionState'); |
594 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | 595 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
595 this.connected = connectionState == 'Connected'; | |
596 $('network-details-subtitle-status').textContent = connectionStateString; | 596 $('network-details-subtitle-status').textContent = connectionStateString; |
597 var typeKey; | 597 var typeKey; |
598 var type = this.type_; | 598 var type = this.type_; |
599 if (type == 'Ethernet') | 599 if (type == 'Ethernet') |
600 typeKey = 'ethernetTitle'; | 600 typeKey = 'ethernetTitle'; |
601 else if (type == 'WiFi') | 601 else if (type == 'WiFi') |
602 typeKey = 'wifiTitle'; | 602 typeKey = 'wifiTitle'; |
603 else if (type == 'Wimax') | 603 else if (type == 'Wimax') |
604 typeKey = 'wimaxTitle'; | 604 typeKey = 'wimaxTitle'; |
605 else if (type == 'Cellular') | 605 else if (type == 'Cellular') |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 // Update our cached data object. | 1017 // Update our cached data object. |
1018 var onc = detailsPage.onc_; | 1018 var onc = detailsPage.onc_; |
1019 onc.updateData(update); | 1019 onc.updateData(update); |
1020 | 1020 |
1021 detailsPage.populateHeader_(); | 1021 detailsPage.populateHeader_(); |
1022 | 1022 |
1023 var connectionState = onc.getActiveValue('ConnectionState'); | 1023 var connectionState = onc.getActiveValue('ConnectionState'); |
1024 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | 1024 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
1025 if ('deviceConnected' in update) | 1025 if ('deviceConnected' in update) |
1026 detailsPage.deviceConnected = update.deviceConnected; | 1026 detailsPage.deviceConnected = update.deviceConnected; |
1027 detailsPage.connected = connectionState == 'Connected'; | |
1028 $('connection-state').textContent = connectionStateString; | 1027 $('connection-state').textContent = connectionStateString; |
1029 | 1028 |
1030 detailsPage.updateConnectionButtonVisibilty_(); | 1029 detailsPage.updateConnectionButtonVisibilty_(); |
1031 | 1030 |
1032 var type = detailsPage.type_; | 1031 var type = detailsPage.type_; |
1033 if (type == 'WiFi') { | 1032 if (type == 'WiFi') { |
1034 $('wifi-connection-state').textContent = connectionStateString; | 1033 $('wifi-connection-state').textContent = connectionStateString; |
1035 } else if (type == 'Wimax') { | 1034 } else if (type == 'Wimax') { |
1036 $('wimax-connection-state').textContent = connectionStateString; | 1035 $('wimax-connection-state').textContent = connectionStateString; |
1037 } else if (type == 'Cellular') { | 1036 } else if (type == 'Cellular') { |
(...skipping 26 matching lines...) Expand all Loading... | |
1064 detailsPage.populateHeader_(); | 1063 detailsPage.populateHeader_(); |
1065 | 1064 |
1066 $('activate-details').hidden = true; | 1065 $('activate-details').hidden = true; |
1067 $('view-account-details').hidden = true; | 1066 $('view-account-details').hidden = true; |
1068 | 1067 |
1069 detailsPage.updateConnectionButtonVisibilty_(); | 1068 detailsPage.updateConnectionButtonVisibilty_(); |
1070 | 1069 |
1071 $('web-proxy-auto-discovery').hidden = true; | 1070 $('web-proxy-auto-discovery').hidden = true; |
1072 | 1071 |
1073 detailsPage.deviceConnected = data.deviceConnected; | 1072 detailsPage.deviceConnected = data.deviceConnected; |
1074 detailsPage.connected = | |
1075 onc.getActiveValue('ConnectionState') == 'Connected'; | |
1076 | 1073 |
1077 // Only show proxy for remembered networks. | 1074 // Only show proxy for remembered networks. |
1078 if (data.remembered) { | 1075 var remembered = onc.getSource() != 'None'; |
1076 if (remembered) { | |
1079 detailsPage.showProxy = true; | 1077 detailsPage.showProxy = true; |
1080 chrome.send('selectNetwork', [detailsPage.servicePath_]); | 1078 chrome.send('selectNetwork', [detailsPage.servicePath_]); |
1081 } else { | 1079 } else { |
1082 detailsPage.showProxy = false; | 1080 detailsPage.showProxy = false; |
1083 } | 1081 } |
1084 | 1082 |
1085 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | 1083 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
1086 $('connection-state').textContent = connectionStateString; | 1084 $('connection-state').textContent = connectionStateString; |
1087 var restricted = onc.getActiveValue('RestrictedConnectivity'); | 1085 var restricted = onc.getActiveValue('RestrictedConnectivity'); |
1088 var restrictedString = loadTimeData.getString( | 1086 var restrictedString = loadTimeData.getString( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 var macAddress = onc.getActiveValue('MacAddress'); | 1222 var macAddress = onc.getActiveValue('MacAddress'); |
1225 if (macAddress) { | 1223 if (macAddress) { |
1226 $('hardware-address').textContent = macAddress; | 1224 $('hardware-address').textContent = macAddress; |
1227 $('hardware-address-row').style.display = 'table-row'; | 1225 $('hardware-address-row').style.display = 'table-row'; |
1228 } else { | 1226 } else { |
1229 // This is most likely a device without a hardware address. | 1227 // This is most likely a device without a hardware address. |
1230 $('hardware-address-row').style.display = 'none'; | 1228 $('hardware-address-row').style.display = 'none'; |
1231 } | 1229 } |
1232 | 1230 |
1233 var setOrHideParent = function(field, property) { | 1231 var setOrHideParent = function(field, property) { |
1234 if (property) { | 1232 if (property != undefined) { |
1235 $(field).textContent = property; | 1233 $(field).textContent = property; |
1236 $(field).parentElement.hidden = false; | 1234 $(field).parentElement.hidden = false; |
1237 } else { | 1235 } else { |
1238 $(field).parentElement.hidden = true; | 1236 $(field).parentElement.hidden = true; |
1239 } | 1237 } |
1240 }; | 1238 }; |
1241 | 1239 |
1242 var networkName = onc.getTranslatedValue('Name'); | 1240 var networkName = onc.getTranslatedValue('Name'); |
1243 | 1241 |
1244 // Signal strength as percentage (for WiFi and Wimax). | 1242 // Signal strength as percentage (for WiFi and Wimax). |
1245 var signalStrength; | 1243 var signalStrength; |
1246 if (type == 'WiFi' || type == 'Wimax') | 1244 if (type == 'WiFi' || type == 'Wimax') |
1247 signalStrength = onc.getActiveValue(type + '.SignalStrength'); | 1245 signalStrength = onc.getActiveValue(type + '.SignalStrength'); |
1248 if (!signalStrength) | 1246 if (!signalStrength) |
1249 signalStrength = 0; | 1247 signalStrength = 0; |
1250 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1248 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
1251 var strengthString = strengthFormat.replace('$1', signalStrength); | 1249 var strengthString = strengthFormat.replace('$1', signalStrength); |
1252 | 1250 |
1253 if (type == 'WiFi') { | 1251 if (type == 'WiFi') { |
1254 OptionsPage.showTab($('wifi-network-nav-tab')); | 1252 OptionsPage.showTab($('wifi-network-nav-tab')); |
1255 detailsPage.gsm = false; | 1253 detailsPage.gsm = false; |
1256 detailsPage.shared = data.shared; | |
1257 $('wifi-connection-state').textContent = connectionStateString; | 1254 $('wifi-connection-state').textContent = connectionStateString; |
1258 $('wifi-restricted-connectivity').textContent = restrictedString; | 1255 $('wifi-restricted-connectivity').textContent = restrictedString; |
1259 var ssid = onc.getActiveValue('WiFi.SSID'); | 1256 var ssid = onc.getActiveValue('WiFi.SSID'); |
1260 $('wifi-ssid').textContent = ssid ? ssid : networkName; | 1257 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
1261 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); | 1258 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); |
1262 var security = onc.getActiveValue('WiFi.Security'); | 1259 var security = onc.getWiFiSecurity(); |
1263 if (security == 'None') | 1260 if (security == 'None') |
1264 security = undefined; | 1261 security = undefined; |
pneubeck (no reviews)
2014/09/09 19:35:31
this is somehow the inverse of the new function :-
stevenjb
2014/09/10 00:00:55
Yes, I know, but I don't like getWiFiSecurity retu
| |
1265 setOrHideParent('wifi-security', security); | 1262 setOrHideParent('wifi-security', security); |
1266 // Frequency is in MHz. | 1263 // Frequency is in MHz. |
1267 var frequency = onc.getActiveValue('WiFi.Frequency'); | 1264 var frequency = onc.getActiveValue('WiFi.Frequency'); |
1268 if (!frequency) | 1265 if (!frequency) |
1269 frequency = 0; | 1266 frequency = 0; |
1270 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); | 1267 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); |
1271 frequencyFormat = frequencyFormat.replace('$1', frequency); | 1268 frequencyFormat = frequencyFormat.replace('$1', frequency); |
1272 $('wifi-frequency').textContent = frequencyFormat; | 1269 $('wifi-frequency').textContent = frequencyFormat; |
1273 $('wifi-signal-strength').textContent = strengthString; | 1270 $('wifi-signal-strength').textContent = strengthString; |
1274 setOrHideParent('wifi-hardware-address', | 1271 setOrHideParent('wifi-hardware-address', |
1275 onc.getActiveValue('MacAddress')); | 1272 onc.getActiveValue('MacAddress')); |
1276 detailsPage.showPreferred = data.remembered; | |
1277 var priority = onc.getActiveValue('Priority'); | 1273 var priority = onc.getActiveValue('Priority'); |
1278 $('prefer-network-wifi').checked = priority > 0; | 1274 $('prefer-network-wifi').checked = priority > 0; |
1279 $('prefer-network-wifi').disabled = !data.remembered; | 1275 $('prefer-network-wifi').disabled = !remembered; |
1280 $('auto-connect-network-wifi').checked = | 1276 $('auto-connect-network-wifi').checked = |
1281 onc.getActiveValue('AutoConnect'); | 1277 onc.getActiveValue('AutoConnect'); |
1282 $('auto-connect-network-wifi').disabled = !data.remembered; | 1278 $('auto-connect-network-wifi').disabled = !remembered; |
1283 detailsPage.hasSecurity = security != undefined; | |
1284 } else if (type == 'Wimax') { | 1279 } else if (type == 'Wimax') { |
1285 OptionsPage.showTab($('wimax-network-nav-tab')); | 1280 OptionsPage.showTab($('wimax-network-nav-tab')); |
1286 detailsPage.gsm = false; | 1281 detailsPage.gsm = false; |
1287 detailsPage.shared = data.shared; | |
1288 detailsPage.showPreferred = data.remembered; | |
1289 $('wimax-connection-state').textContent = connectionStateString; | 1282 $('wimax-connection-state').textContent = connectionStateString; |
1290 $('wimax-restricted-connectivity').textContent = restrictedString; | 1283 $('wimax-restricted-connectivity').textContent = restrictedString; |
1291 $('auto-connect-network-wimax').checked = | 1284 $('auto-connect-network-wimax').checked = |
1292 onc.getActiveValue('AutoConnect'); | 1285 onc.getActiveValue('AutoConnect'); |
1293 $('auto-connect-network-wimax').disabled = !data.remembered; | 1286 $('auto-connect-network-wimax').disabled = !remembered; |
1294 var identity = onc.getActiveValue('Wimax.EAP.Identity'); | 1287 var identity = onc.getActiveValue('Wimax.EAP.Identity'); |
1295 setOrHideParent('wimax-eap-identity', identity); | 1288 setOrHideParent('wimax-eap-identity', identity); |
1296 $('wimax-signal-strength').textContent = strengthString; | 1289 $('wimax-signal-strength').textContent = strengthString; |
1297 } else if (type == 'Cellular') { | 1290 } else if (type == 'Cellular') { |
1298 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1291 OptionsPage.showTab($('cellular-conn-nav-tab')); |
1299 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1292 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
1300 var carrierSelector = $('select-carrier'); | 1293 var carrierSelector = $('select-carrier'); |
1301 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1294 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
1302 carrierSelector.options.length = 0; | 1295 carrierSelector.options.length = 0; |
1303 for (var i = 0; i < data.carriers.length; ++i) { | 1296 for (var i = 0; i < data.carriers.length; ++i) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 | 1422 |
1430 // Don't show page name in address bar and in history to prevent people | 1423 // Don't show page name in address bar and in history to prevent people |
1431 // navigate here by hand and solve issue with page session restore. | 1424 // navigate here by hand and solve issue with page session restore. |
1432 PageManager.showPageByName('detailsInternetPage', false); | 1425 PageManager.showPageByName('detailsInternetPage', false); |
1433 }; | 1426 }; |
1434 | 1427 |
1435 return { | 1428 return { |
1436 DetailsInternetPage: DetailsInternetPage | 1429 DetailsInternetPage: DetailsInternetPage |
1437 }; | 1430 }; |
1438 }); | 1431 }); |
OLD | NEW |