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 /* | 19 * Helper function to get the "Active" value of a property from a dictionary |
20 * that includes ONC managed properties, e.g. getActiveValue(data, 'Name'). | |
21 * We use (data, key) instead of getActiveValue(data[key]) so that we can | |
22 * (possibly) add ONC key validation once all properties use ONC. | |
23 * @param {object} data The properties dictionary. | |
24 * @param {string} key The property key. | |
25 * @return {*} the property value or undefined. | |
26 */ | |
27 function getActiveValue(data, key) { | |
28 if (!(key in data)) | |
29 return undefined; | |
30 var property = data[key]; | |
31 if (typeof property != 'object') | |
32 return property; | |
33 if ('Active' in property) | |
34 return property['Active']; | |
35 if ('Effective' in property) { | |
36 var effective = property.Effective; | |
37 if (effective in property) | |
38 return property[effective]; | |
39 } | |
40 return undefined; | |
41 } | |
42 | |
43 /** | |
44 * Helper function for nested ONC properties, e.g. data[WiFi][Strength]. | |
45 * @param {object|string} property The property which must ether be | |
46 * a dictionary object or not be present. | |
47 * @return {*} the property value or undefined. | |
48 */ | |
49 function getActiveDictionaryValue(data, dict, key) { | |
50 if (!(dict in data)) | |
51 return undefined; | |
52 return getActiveValue(data[dict], key); | |
53 } | |
54 | |
55 /** | |
20 * Helper function to set hidden attribute for elements matching a selector. | 56 * Helper function to set hidden attribute for elements matching a selector. |
21 * @param {string} selector CSS selector for extracting a list of elements. | 57 * @param {string} selector CSS selector for extracting a list of elements. |
22 * @param {bool} hidden New hidden value. | 58 * @param {bool} hidden New hidden value. |
23 */ | 59 */ |
24 function updateHidden(selector, hidden) { | 60 function updateHidden(selector, hidden) { |
25 var elements = cr.doc.querySelectorAll(selector); | 61 var elements = cr.doc.querySelectorAll(selector); |
26 for (var i = 0, el; el = elements[i]; i++) { | 62 for (var i = 0, el; el = elements[i]; i++) { |
27 el.hidden = hidden; | 63 el.hidden = hidden; |
28 } | 64 } |
29 } | 65 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 else if (state == 'Connected') | 126 else if (state == 'Connected') |
91 return loadTimeData.getString('OncStateConnected'); | 127 return loadTimeData.getString('OncStateConnected'); |
92 return loadTimeData.getString('OncStateUnknown'); | 128 return loadTimeData.getString('OncStateUnknown'); |
93 } | 129 } |
94 | 130 |
95 /** | 131 /** |
96 * Returns the display name for the network represented by 'data'. | 132 * Returns the display name for the network represented by 'data'. |
97 * @param {Object} data The network ONC dictionary. | 133 * @param {Object} data The network ONC dictionary. |
98 */ | 134 */ |
99 function getNetworkName(data) { | 135 function getNetworkName(data) { |
100 if (data.Type == 'Ethernet') | 136 if (data.type == 'Ethernet') |
101 return loadTimeData.getString('ethernetName'); | 137 return loadTimeData.getString('ethernetName'); |
102 return data.Name; | 138 return getActiveValue(data, 'Name'); |
103 } | |
104 | |
105 /** | |
106 * Returns True if the network represented by 'data' is a secure WiFi network. | |
107 * @param {Object} data The network ONC dictionary. | |
108 */ | |
109 function isSecureWiFiNetwork(data) { | |
110 return data.WiFi && data.WiFi.Security && data.WiFi.Security != 'None'; | |
111 } | 139 } |
112 | 140 |
113 ///////////////////////////////////////////////////////////////////////////// | 141 ///////////////////////////////////////////////////////////////////////////// |
114 // DetailsInternetPage class: | 142 // DetailsInternetPage class: |
115 | 143 |
116 /** | 144 /** |
117 * Encapsulated handling of ChromeOS internet details overlay page. | 145 * Encapsulated handling of ChromeOS internet details overlay page. |
118 * @constructor | 146 * @constructor |
119 */ | 147 */ |
120 function DetailsInternetPage() { | 148 function DetailsInternetPage() { |
(...skipping 18 matching lines...) Expand all Loading... | |
139 * is included in the URL. | 167 * is included in the URL. |
140 */ | 168 */ |
141 showNetworkDetails_: function(params) { | 169 showNetworkDetails_: function(params) { |
142 var servicePath = params.servicePath; | 170 var servicePath = params.servicePath; |
143 if (!servicePath || !servicePath.length) | 171 if (!servicePath || !servicePath.length) |
144 return; | 172 return; |
145 var networkType = ''; // ignored for 'options' | 173 var networkType = ''; // ignored for 'options' |
146 chrome.send('networkCommand', [networkType, servicePath, 'options']); | 174 chrome.send('networkCommand', [networkType, servicePath, 'options']); |
147 }, | 175 }, |
148 | 176 |
149 | |
150 /** | 177 /** |
151 * Initializes the contents of the page. | 178 * Initializes the contents of the page. |
152 */ | 179 */ |
153 initializePageContents_: function(params) { | 180 initializePageContents_: function(params) { |
154 $('details-internet-dismiss').addEventListener('click', function(event) { | 181 $('details-internet-dismiss').addEventListener('click', function(event) { |
155 DetailsInternetPage.setDetails(); | 182 DetailsInternetPage.setDetails(); |
156 }); | 183 }); |
157 | 184 |
158 $('details-internet-login').addEventListener('click', function(event) { | 185 $('details-internet-login').addEventListener('click', function(event) { |
159 DetailsInternetPage.setDetails(); | 186 DetailsInternetPage.setDetails(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 * Handler for when the name server selection changes. | 431 * Handler for when the name server selection changes. |
405 * @param {Event} e The click event. | 432 * @param {Event} e The click event. |
406 * @private | 433 * @private |
407 */ | 434 */ |
408 handleNameServerTypeChange_: function(event) { | 435 handleNameServerTypeChange_: function(event) { |
409 var type = event.target.value; | 436 var type = event.target.value; |
410 DetailsInternetPage.updateNameServerDisplay(type); | 437 DetailsInternetPage.updateNameServerDisplay(type); |
411 }, | 438 }, |
412 | 439 |
413 /** | 440 /** |
441 * Creates an indicator event for controlled properties using | |
442 * the same dictionary format as CoreOptionsHandler::CreateValueForPref. | |
443 * @param {string} name The name for the Event. | |
444 * @param {Object} data Property dictionary with |value|, |controlledBy|, | |
445 * and |recommendedValue| properties set. | |
446 * @private | |
447 */ | |
448 createControlledEvent_: function(name, propData) { | |
449 var event = new Event(name); | |
450 event.value = { | |
451 value: propData.value, | |
452 controlledBy: propData.controlledBy, | |
453 recommendedValue: propData.recommendedValue | |
454 }; | |
455 return event; | |
456 }, | |
457 | |
458 /** | |
459 * Creates an indicator event for controlled properties using | |
460 * the ONC getManagedProperties dictionary format. | |
461 * @param {string} name The name for the Event. | |
462 * @param {Object} data ONC managed network property dictionary. | |
463 * @private | |
464 */ | |
465 createManagedEvent_: function(name, propData) { | |
466 var event = new Event(name); | |
467 event.value = {}; | |
468 | |
469 // Set the current value and recommended value. | |
470 var activeValue = propData['Active']; | |
471 var effective = propData['Effective']; | |
472 if (activeValue == undefined) | |
473 activeValue = propData[effective]; | |
474 event.value.value = activeValue; | |
475 | |
476 if (propData['UserEditable']) { | |
477 var userValue = propData['UserPolicy']; | |
478 if (userValue != activeValue) { | |
pneubeck (no reviews)
2014/08/06 17:37:35
As the comment in the next line says, we should ch
stevenjb
2014/08/06 19:17:03
Oops. Done.
| |
479 // UserEditable and unchanged value indicates this is recommended. | |
pneubeck (no reviews)
2014/08/06 17:37:35
nit:
... indicates that the recommended value is
stevenjb
2014/08/06 19:17:03
Moved to one (hopefully more clear) above the if b
| |
480 event.value.controlledBy = 'recommended'; | |
481 event.value.recommendedValue = userValue; | |
pneubeck (no reviews)
2014/08/06 17:37:35
can be set independent of activeValue.
just move i
stevenjb
2014/08/06 19:17:03
Ah. Done.
| |
482 } | |
483 } else if (propData['DeviceEditable']) { | |
484 var deviceValue = propData['DevicePolicy']; | |
485 if (deviceValue != activeValue) { | |
pneubeck (no reviews)
2014/08/06 17:37:35
ditto, wrong negation.
stevenjb
2014/08/06 19:17:03
Done.
| |
486 // DeviceEditable and unchanged value indicates this is recommended. | |
487 event.value.controlledBy = 'recommended'; | |
488 event.value.recommendedValue = deviceValue; | |
pneubeck (no reviews)
2014/08/06 17:37:35
ditto, should be out of the inner block.
stevenjb
2014/08/06 19:17:03
Done.
| |
489 } | |
490 } else if (effective == 'UserPolicy' || effective == 'DevicePolicy') { | |
491 // Otherwise this is a controlled property. | |
pneubeck (no reviews)
2014/08/06 17:37:35
nit: I wouldn't call it 'controlled' but
'Otherwi
stevenjb
2014/08/06 19:17:03
Acknowledged.
| |
492 event.value.controlledBy = 'policy'; | |
493 } | |
494 | |
495 return event; | |
496 }, | |
497 | |
498 /** | |
414 * Update details page controls. | 499 * Update details page controls. |
415 * @private | |
416 */ | 500 */ |
417 updateControls: function() { | 501 updateControls: function() { |
418 // Only show ipconfig section if network is connected OR if nothing on | 502 // Only show ipconfig section if network is connected OR if nothing on |
419 // this device is connected. This is so that you can fix the ip configs | 503 // this device is connected. This is so that you can fix the ip configs |
420 // if you can't connect to any network. | 504 // if you can't connect to any network. |
421 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, | 505 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, |
422 // we need to redo this logic to allow configuration of all networks. | 506 // we need to redo this logic to allow configuration of all networks. |
423 $('ipconfig-section').hidden = !this.connected && this.deviceConnected; | 507 $('ipconfig-section').hidden = !this.connected && this.deviceConnected; |
424 $('ipconfig-dns-section').hidden = | 508 $('ipconfig-dns-section').hidden = |
425 !this.connected && this.deviceConnected; | 509 !this.connected && this.deviceConnected; |
426 | 510 |
427 // Network type related. | 511 // Network type related. |
428 updateHidden('#details-internet-page .cellular-details', !this.cellular); | 512 updateHidden('#details-internet-page .cellular-details', |
429 updateHidden('#details-internet-page .wifi-details', !this.wireless); | 513 this.type != 'Cellular'); |
430 updateHidden('#details-internet-page .wimax-details', !this.wimax); | 514 updateHidden('#details-internet-page .wifi-details', |
431 updateHidden('#details-internet-page .vpn-details', !this.vpn); | 515 this.type != 'WiFi'); |
516 updateHidden('#details-internet-page .wimax-details', | |
517 this.type != 'Wimax'); | |
518 updateHidden('#details-internet-page .vpn-details', this.type != 'VPN'); | |
432 updateHidden('#details-internet-page .proxy-details', !this.showProxy); | 519 updateHidden('#details-internet-page .proxy-details', !this.showProxy); |
433 | 520 |
434 // Cellular | 521 // Cellular |
435 | 522 |
436 // Conditionally call updateHidden on .gsm-only, so that we don't unhide | 523 // Conditionally call updateHidden on .gsm-only, so that we don't unhide |
437 // a previously hidden element. | 524 // a previously hidden element. |
438 if (this.gsm) | 525 if (this.gsm) |
439 updateHidden('#details-internet-page .cdma-only', true); | 526 updateHidden('#details-internet-page .cdma-only', true); |
440 else | 527 else |
441 updateHidden('#details-internet-page .gsm-only', true); | 528 updateHidden('#details-internet-page .gsm-only', true); |
442 | 529 |
443 // Wifi | 530 // Wifi |
444 | 531 |
445 // Network information merged into the Wifi tab for wireless networks | 532 // Hide network tab for VPN. |
446 // unless the option is set for enabling a static IP configuration. | |
447 updateHidden('#details-internet-page .network-details', | 533 updateHidden('#details-internet-page .network-details', |
448 (this.wireless && !this.showStaticIPConfig) || this.vpn); | 534 this.type == 'VPN'); |
449 updateHidden('#details-internet-page .wifi-network-setting', | |
450 this.showStaticIPConfig); | |
451 | 535 |
452 // Password and shared. | 536 // Password and shared. |
453 updateHidden('#details-internet-page #password-details', | 537 updateHidden('#details-internet-page #password-details', |
454 !this.wireless || !this.hasSecurity); | 538 this.type != 'WiFi' || !this.hasSecurity); |
455 updateHidden('#details-internet-page #wifi-shared-network', | 539 updateHidden('#details-internet-page #wifi-shared-network', |
456 !this.shared); | 540 !this.shared); |
457 updateHidden('#details-internet-page #prefer-network', | 541 updateHidden('#details-internet-page #prefer-network', |
458 !this.showPreferred); | 542 !this.showPreferred); |
459 | 543 |
460 // WiMAX. | 544 // WiMAX. |
461 updateHidden('#details-internet-page #wimax-shared-network', | 545 updateHidden('#details-internet-page #wimax-shared-network', |
462 !this.shared); | 546 !this.shared); |
463 | 547 |
464 // Proxy | 548 // Proxy |
465 this.updateProxyBannerVisibility_(); | 549 this.updateProxyBannerVisibility_(); |
466 this.toggleSingleProxy_(); | 550 this.toggleSingleProxy_(); |
467 if ($('manual-proxy').checked) | 551 if ($('manual-proxy').checked) |
468 this.enableManualProxy_(); | 552 this.enableManualProxy_(); |
469 else | 553 else |
470 this.disableManualProxy_(); | 554 this.disableManualProxy_(); |
471 }, | 555 }, |
472 | 556 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 $('ftp-proxy').disabled = allDisabled; | 663 $('ftp-proxy').disabled = allDisabled; |
580 $('ftp-proxy-port').disabled = allDisabled; | 664 $('ftp-proxy-port').disabled = allDisabled; |
581 $('socks-host').disabled = allDisabled; | 665 $('socks-host').disabled = allDisabled; |
582 $('socks-port').disabled = allDisabled; | 666 $('socks-port').disabled = allDisabled; |
583 $('proxy-use-pac-url').disabled = true; | 667 $('proxy-use-pac-url').disabled = true; |
584 $('proxy-pac-url').disabled = true; | 668 $('proxy-pac-url').disabled = true; |
585 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; | 669 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; |
586 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; | 670 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; |
587 chrome.send('coreOptionsUserMetricsAction', | 671 chrome.send('coreOptionsUserMetricsAction', |
588 ['Options_NetworkManualProxy_Enable']); | 672 ['Options_NetworkManualProxy_Enable']); |
589 }, | 673 } |
590 }; | 674 }; |
591 | 675 |
592 /** | 676 /** |
593 * Enables or Disables all buttons that provide operations on the cellular | 677 * Enables or Disables all buttons that provide operations on the cellular |
594 * network. | 678 * network. |
595 */ | 679 */ |
596 DetailsInternetPage.changeCellularButtonsState = function(disable) { | 680 DetailsInternetPage.changeCellularButtonsState = function(disable) { |
597 var buttonsToDisableList = | 681 var buttonsToDisableList = |
598 new Array('details-internet-login', | 682 new Array('details-internet-login', |
599 'details-internet-disconnect', | 683 'details-internet-disconnect', |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 /** | 724 /** |
641 * Displays the InternetDetails dialog with only the proxy settings visible. | 725 * Displays the InternetDetails dialog with only the proxy settings visible. |
642 */ | 726 */ |
643 DetailsInternetPage.showProxySettings = function() { | 727 DetailsInternetPage.showProxySettings = function() { |
644 var detailsPage = DetailsInternetPage.getInstance(); | 728 var detailsPage = DetailsInternetPage.getInstance(); |
645 $('network-details-header').hidden = true; | 729 $('network-details-header').hidden = true; |
646 $('buyplan-details').hidden = true; | 730 $('buyplan-details').hidden = true; |
647 $('activate-details').hidden = true; | 731 $('activate-details').hidden = true; |
648 $('view-account-details').hidden = true; | 732 $('view-account-details').hidden = true; |
649 $('web-proxy-auto-discovery').hidden = true; | 733 $('web-proxy-auto-discovery').hidden = true; |
650 detailsPage.cellular = false; | |
651 detailsPage.wireless = false; | |
652 detailsPage.vpn = false; | |
653 detailsPage.showProxy = true; | 734 detailsPage.showProxy = true; |
654 updateHidden('#internet-tab', true); | 735 updateHidden('#internet-tab', true); |
655 updateHidden('#details-tab-strip', true); | 736 updateHidden('#details-tab-strip', true); |
656 updateHidden('#details-internet-page .action-area', true); | 737 updateHidden('#details-internet-page .action-area', true); |
657 detailsPage.updateControls(); | 738 detailsPage.updateControls(); |
658 detailsPage.visible = true; | 739 detailsPage.visible = true; |
659 chrome.send('coreOptionsUserMetricsAction', | 740 chrome.send('coreOptionsUserMetricsAction', |
660 ['Options_NetworkShowProxyTab']); | 741 ['Options_NetworkShowProxyTab']); |
661 }; | 742 }; |
662 | 743 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 } | 781 } |
701 }; | 782 }; |
702 | 783 |
703 DetailsInternetPage.updateCarrier = function() { | 784 DetailsInternetPage.updateCarrier = function() { |
704 DetailsInternetPage.showCarrierChangeSpinner(false); | 785 DetailsInternetPage.showCarrierChangeSpinner(false); |
705 }; | 786 }; |
706 | 787 |
707 DetailsInternetPage.loginFromDetails = function() { | 788 DetailsInternetPage.loginFromDetails = function() { |
708 var data = $('connection-state').data; | 789 var data = $('connection-state').data; |
709 var servicePath = data.servicePath; | 790 var servicePath = data.servicePath; |
710 chrome.send('networkCommand', [data.Type, servicePath, 'connect']); | 791 chrome.send('networkCommand', [data.type, servicePath, 'connect']); |
711 PageManager.closeOverlay(); | 792 PageManager.closeOverlay(); |
712 }; | 793 }; |
713 | 794 |
714 DetailsInternetPage.disconnectNetwork = function() { | 795 DetailsInternetPage.disconnectNetwork = function() { |
715 var data = $('connection-state').data; | 796 var data = $('connection-state').data; |
716 var servicePath = data.servicePath; | 797 var servicePath = data.servicePath; |
717 chrome.send('networkCommand', [data.Type, servicePath, 'disconnect']); | 798 chrome.send('networkCommand', [data.type, servicePath, 'disconnect']); |
718 PageManager.closeOverlay(); | 799 PageManager.closeOverlay(); |
719 }; | 800 }; |
720 | 801 |
721 DetailsInternetPage.configureNetwork = function() { | 802 DetailsInternetPage.configureNetwork = function() { |
722 var data = $('connection-state').data; | 803 var data = $('connection-state').data; |
723 var servicePath = data.servicePath; | 804 var servicePath = data.servicePath; |
724 chrome.send('networkCommand', [data.Type, servicePath, 'configure']); | 805 chrome.send('networkCommand', [data.type, servicePath, 'configure']); |
725 PageManager.closeOverlay(); | 806 PageManager.closeOverlay(); |
726 }; | 807 }; |
727 | 808 |
728 DetailsInternetPage.activateFromDetails = function() { | 809 DetailsInternetPage.activateFromDetails = function() { |
729 var data = $('connection-state').data; | 810 var data = $('connection-state').data; |
730 var servicePath = data.servicePath; | 811 var servicePath = data.servicePath; |
731 if (data.Type == 'Cellular') | 812 if (data.Type == 'Cellular') |
732 chrome.send('networkCommand', [data.Type, servicePath, 'activate']); | 813 chrome.send('networkCommand', [data.type, servicePath, 'activate']); |
733 PageManager.closeOverlay(); | 814 PageManager.closeOverlay(); |
734 }; | 815 }; |
735 | 816 |
736 DetailsInternetPage.setDetails = function() { | 817 DetailsInternetPage.setDetails = function() { |
737 var data = $('connection-state').data; | 818 var data = $('connection-state').data; |
738 var servicePath = data.servicePath; | 819 var servicePath = data.servicePath; |
739 if (data.Type == 'WiFi') { | 820 if (data.type == 'WiFi') { |
740 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', | 821 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', |
741 $('prefer-network-wifi')); | 822 $('prefer-network-wifi')); |
742 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 823 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
743 $('auto-connect-network-wifi')); | 824 $('auto-connect-network-wifi')); |
744 } else if (data.Type == 'Wimax') { | 825 } else if (data.type == 'Wimax') { |
745 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 826 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
746 $('auto-connect-network-wimax')); | 827 $('auto-connect-network-wimax')); |
747 } else if (data.Type == 'Cellular') { | 828 } else if (data.type == 'Cellular') { |
748 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 829 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
749 $('auto-connect-network-cellular')); | 830 $('auto-connect-network-cellular')); |
750 } else if (data.Type == 'VPN') { | 831 } else if (data.type == 'VPN') { |
751 chrome.send('setServerHostname', | 832 chrome.send('setServerHostname', |
752 [servicePath, | 833 [servicePath, |
753 $('inet-server-hostname').value]); | 834 $('inet-server-hostname').value]); |
754 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 835 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
755 $('auto-connect-network-vpn')); | 836 $('auto-connect-network-vpn')); |
756 } | 837 } |
757 | 838 |
758 var nameServerTypes = ['automatic', 'google', 'user']; | 839 var nameServerTypes = ['automatic', 'google', 'user']; |
759 var nameServerType = 'automatic'; | 840 var nameServerType = 'automatic'; |
760 for (var i = 0; i < nameServerTypes.length; ++i) { | 841 for (var i = 0; i < nameServerTypes.length; ++i) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { | 903 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { |
823 if (data.type == 'Ethernet') { | 904 if (data.type == 'Ethernet') { |
824 // Ethernet can never be connected or disconnected and can always be | 905 // Ethernet can never be connected or disconnected and can always be |
825 // configured (e.g. to set security). | 906 // configured (e.g. to set security). |
826 $('details-internet-login').hidden = true; | 907 $('details-internet-login').hidden = true; |
827 $('details-internet-disconnect').hidden = true; | 908 $('details-internet-disconnect').hidden = true; |
828 $('details-internet-configure').hidden = false; | 909 $('details-internet-configure').hidden = false; |
829 return; | 910 return; |
830 } | 911 } |
831 | 912 |
832 var connectState = data.ConnectionState; | 913 var connectState = getActiveValue(data, 'ConnectionState'); |
833 if (connectState == 'NotConnected') { | 914 if (connectState == 'NotConnected') { |
834 $('details-internet-login').hidden = false; | 915 $('details-internet-login').hidden = false; |
835 // Connecting to an unconfigured network might trigger certificate | 916 // Connecting to an unconfigured network might trigger certificate |
836 // installation UI. Until that gets handled here, always enable the | 917 // installation UI. Until that gets handled here, always enable the |
837 // Connect button. | 918 // Connect button. |
838 $('details-internet-login').disabled = false; | 919 $('details-internet-login').disabled = false; |
839 $('details-internet-disconnect').hidden = true; | 920 $('details-internet-disconnect').hidden = true; |
840 } else { | 921 } else { |
841 $('details-internet-login').hidden = true; | 922 $('details-internet-login').hidden = true; |
842 $('details-internet-disconnect').hidden = false; | 923 $('details-internet-disconnect').hidden = false; |
843 } | 924 } |
844 | 925 |
845 var connectable = data.Connectable; | 926 var connectable = getActiveValue(data, 'Connectable'); |
846 if (connectState != 'Connected' && | 927 if (connectState != 'Connected' && |
847 (!connectable || isSecureWiFiNetwork(data) || | 928 (!connectable || this.hasSecurity || |
848 (data.Type == 'Wimax' || data.Type == 'VPN'))) { | 929 (data.type == 'Wimax' || data.type == 'VPN'))) { |
849 $('details-internet-configure').hidden = false; | 930 $('details-internet-configure').hidden = false; |
850 } else { | 931 } else { |
851 $('details-internet-configure').hidden = true; | 932 $('details-internet-configure').hidden = true; |
852 } | 933 } |
853 }; | 934 }; |
854 | 935 |
855 DetailsInternetPage.updateConnectionData = function(update) { | 936 DetailsInternetPage.updateConnectionData = function(update) { |
856 var detailsPage = DetailsInternetPage.getInstance(); | 937 var detailsPage = DetailsInternetPage.getInstance(); |
857 if (!detailsPage.visible) | 938 if (!detailsPage.visible) |
858 return; | 939 return; |
859 | 940 |
860 var data = $('connection-state').data; | 941 var data = $('connection-state').data; |
861 if (!data) | 942 if (!data) |
862 return; | 943 return; |
863 | 944 |
864 if (update.servicePath != data.servicePath) | 945 if (update.servicePath != data.servicePath) |
865 return; | 946 return; |
866 | 947 |
867 // Update our cached data object. | 948 // Update our cached data object. |
868 updateDataObject(data, update); | 949 updateDataObject(data, update); |
869 | 950 |
951 var connectionState = getActiveValue(data, 'ConnectionState'); | |
952 var connectionStateString = networkOncStateString(connectionState); | |
870 detailsPage.deviceConnected = data.deviceConnected; | 953 detailsPage.deviceConnected = data.deviceConnected; |
871 detailsPage.connecting = data.ConnectionState == 'Connecting'; | 954 detailsPage.connected = connectionState == 'Connected'; |
872 detailsPage.connected = data.ConnectionState == 'Connected'; | |
873 var connectionStateString = networkOncStateString(data.ConnectionState); | |
874 $('connection-state').textContent = connectionStateString; | 955 $('connection-state').textContent = connectionStateString; |
875 | 956 |
876 this.updateConnectionButtonVisibilty(data); | 957 this.updateConnectionButtonVisibilty(data); |
877 | 958 |
878 if (data.Type == 'WiFi') { | 959 if (data.type == 'WiFi') { |
879 $('wifi-connection-state').textContent = connectionStateString; | 960 $('wifi-connection-state').textContent = connectionStateString; |
880 } else if (data.Type == 'Wimax') { | 961 } else if (data.type == 'Wimax') { |
881 $('wimax-connection-state').textContent = connectionStateString; | 962 $('wimax-connection-state').textContent = connectionStateString; |
882 } else if (data.Type == 'Cellular') { | 963 } else if (data.type == 'Cellular') { |
883 $('activation-state').textContent = data.activationState; | 964 $('activation-state').textContent = data.activationState; |
884 | 965 |
885 $('buyplan-details').hidden = !data.showBuyButton; | 966 $('buyplan-details').hidden = !data.showBuyButton; |
886 $('view-account-details').hidden = !data.showViewAccountButton; | 967 $('view-account-details').hidden = !data.showViewAccountButton; |
887 | 968 |
888 $('activate-details').hidden = !data.showActivateButton; | 969 $('activate-details').hidden = !data.showActivateButton; |
889 if (data.showActivateButton) | 970 if (data.showActivateButton) |
890 $('details-internet-login').hidden = true; | 971 $('details-internet-login').hidden = true; |
891 | 972 |
892 if (detailsPage.gsm) { | 973 if (detailsPage.gsm) { |
893 // TODO(stevenjb): Use managed properties for policy controlled values. | 974 // TODO(stevenjb): Use managed properties for policy controlled values. |
894 var lockEnabled = data.simCardLockEnabled.value; | 975 var lockEnabled = data.simCardLockEnabled.value; |
895 $('sim-card-lock-enabled').checked = lockEnabled; | 976 $('sim-card-lock-enabled').checked = lockEnabled; |
896 $('change-pin').hidden = !lockEnabled; | 977 $('change-pin').hidden = !lockEnabled; |
897 } | 978 } |
898 } | 979 } |
899 | 980 |
900 $('connection-state').data = data; | 981 $('connection-state').data = data; |
901 }; | 982 }; |
902 | 983 |
903 DetailsInternetPage.showDetailedInfo = function(data) { | 984 DetailsInternetPage.showDetailedInfo = function(data) { |
904 var detailsPage = DetailsInternetPage.getInstance(); | 985 var detailsPage = DetailsInternetPage.getInstance(); |
905 | 986 |
987 data.type = getActiveValue(data, 'Type'); // Get Active Type value. | |
988 | |
906 // Populate header | 989 // Populate header |
907 $('network-details-title').textContent = getNetworkName(data); | 990 $('network-details-title').textContent = getNetworkName(data); |
908 var connectionStateString = networkOncStateString(data.ConnectionState); | 991 var connectionState = getActiveValue(data, 'ConnectionState'); |
992 var connectionStateString = networkOncStateString(connectionState); | |
993 detailsPage.connected = connectionState == 'Connected'; | |
909 $('network-details-subtitle-status').textContent = connectionStateString; | 994 $('network-details-subtitle-status').textContent = connectionStateString; |
910 var typeKey = null; | 995 var typeKey = null; |
911 switch (data.Type) { | 996 switch (data.type) { |
912 case 'Ethernet': | 997 case 'Ethernet': |
913 typeKey = 'ethernetTitle'; | 998 typeKey = 'ethernetTitle'; |
914 break; | 999 break; |
915 case 'WiFi': | 1000 case 'WiFi': |
916 typeKey = 'wifiTitle'; | 1001 typeKey = 'wifiTitle'; |
917 break; | 1002 break; |
918 case 'Wimax': | 1003 case 'Wimax': |
919 typeKey = 'wimaxTitle'; | 1004 typeKey = 'wimaxTitle'; |
920 break; | 1005 break; |
921 case 'Cellular': | 1006 case 'Cellular': |
922 typeKey = 'cellularTitle'; | 1007 typeKey = 'cellularTitle'; |
923 break; | 1008 break; |
924 case 'VPN': | 1009 case 'VPN': |
925 typeKey = 'vpnTitle'; | 1010 typeKey = 'vpnTitle'; |
926 break; | 1011 break; |
927 } | 1012 } |
928 var typeLabel = $('network-details-subtitle-type'); | 1013 var typeLabel = $('network-details-subtitle-type'); |
929 var typeSeparator = $('network-details-subtitle-separator'); | 1014 var typeSeparator = $('network-details-subtitle-separator'); |
930 if (typeKey) { | 1015 if (typeKey) { |
931 typeLabel.textContent = loadTimeData.getString(typeKey); | 1016 typeLabel.textContent = loadTimeData.getString(typeKey); |
932 typeLabel.hidden = false; | 1017 typeLabel.hidden = false; |
933 typeSeparator.hidden = false; | 1018 typeSeparator.hidden = false; |
934 } else { | 1019 } else { |
935 typeLabel.hidden = true; | 1020 typeLabel.hidden = true; |
936 typeSeparator.hidden = true; | 1021 typeSeparator.hidden = true; |
937 } | 1022 } |
938 | 1023 |
939 // TODO(chocobo): Is this hack to cache the data here reasonable? | 1024 // TODO(stevenjb): Find a more appropriate place to cache data. |
940 // TODO(kevers): Find more appropriate place to cache data. | |
941 $('connection-state').data = data; | 1025 $('connection-state').data = data; |
942 | 1026 |
943 $('buyplan-details').hidden = true; | 1027 $('buyplan-details').hidden = true; |
944 $('activate-details').hidden = true; | 1028 $('activate-details').hidden = true; |
945 $('view-account-details').hidden = true; | 1029 $('view-account-details').hidden = true; |
946 | 1030 |
947 this.updateConnectionButtonVisibilty(data); | 1031 this.updateConnectionButtonVisibilty(data); |
948 | 1032 |
949 $('web-proxy-auto-discovery').hidden = true; | 1033 $('web-proxy-auto-discovery').hidden = true; |
950 | 1034 |
951 detailsPage.deviceConnected = data.deviceConnected; | 1035 detailsPage.deviceConnected = data.deviceConnected; |
952 detailsPage.connecting = data.ConnectionState == 'Connecting'; | 1036 detailsPage.connected = connectionState == 'Connected'; |
953 detailsPage.connected = data.ConnectionState == 'Connected'; | |
954 | 1037 |
955 // Only show proxy for remembered networks. | 1038 // Only show proxy for remembered networks. |
956 if (data.remembered) { | 1039 if (data.remembered) { |
957 detailsPage.showProxy = true; | 1040 detailsPage.showProxy = true; |
958 chrome.send('selectNetwork', [data.servicePath]); | 1041 chrome.send('selectNetwork', [data.servicePath]); |
959 } else { | 1042 } else { |
960 detailsPage.showProxy = false; | 1043 detailsPage.showProxy = false; |
961 } | 1044 } |
962 detailsPage.showStaticIPConfig = data.showStaticIPConfig; | |
963 $('connection-state').textContent = connectionStateString; | 1045 $('connection-state').textContent = connectionStateString; |
964 | 1046 |
965 var ipAutoConfig = data.ipAutoConfig ? 'automatic' : 'user'; | 1047 var ipAutoConfig = data.ipAutoConfig ? 'automatic' : 'user'; |
966 $('ip-automatic-configuration-checkbox').checked = data.ipAutoConfig; | 1048 $('ip-automatic-configuration-checkbox').checked = data.ipAutoConfig; |
967 var inetAddress = {autoConfig: ipAutoConfig}; | 1049 var inetAddress = {autoConfig: ipAutoConfig}; |
968 var inetNetmask = {autoConfig: ipAutoConfig}; | 1050 var inetNetmask = {autoConfig: ipAutoConfig}; |
969 var inetGateway = {autoConfig: ipAutoConfig}; | 1051 var inetGateway = {autoConfig: ipAutoConfig}; |
970 | 1052 |
971 if (data.ipconfig.value) { | 1053 if (data.ipconfig.value) { |
972 inetAddress.automatic = data.ipconfig.value.address; | 1054 inetAddress.automatic = data.ipconfig.value.address; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1043 nameServerModels.push({value: nameServersUser[i] || ''}); | 1125 nameServerModels.push({value: nameServersUser[i] || ''}); |
1044 | 1126 |
1045 $(data.nameServerType + '-dns-radio').checked = true; | 1127 $(data.nameServerType + '-dns-radio').checked = true; |
1046 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); | 1128 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); |
1047 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); | 1129 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); |
1048 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); | 1130 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); |
1049 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); | 1131 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); |
1050 | 1132 |
1051 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); | 1133 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); |
1052 | 1134 |
1053 if (data.MacAddress) { | 1135 var macAddress = getActiveValue(data, 'MacAddress'); |
1054 $('hardware-address').textContent = data.MacAddress; | 1136 if (macAddress) { |
1137 $('hardware-address').textContent = macAddress; | |
1055 $('hardware-address-row').style.display = 'table-row'; | 1138 $('hardware-address-row').style.display = 'table-row'; |
1056 } else { | 1139 } else { |
1057 // This is most likely a device without a hardware address. | 1140 // This is most likely a device without a hardware address. |
1058 $('hardware-address-row').style.display = 'none'; | 1141 $('hardware-address-row').style.display = 'none'; |
1059 } | 1142 } |
1060 | 1143 |
1144 var setOrHideParent = function(field, property) { | |
1145 if (property) { | |
1146 $(field).textContent = property; | |
1147 $(field).parentElement.hidden = false; | |
1148 } else { | |
1149 $(field).parentElement.hidden = true; | |
1150 } | |
1151 }; | |
1152 | |
1153 var networkName = getNetworkName(data); | |
1154 | |
1061 // Signal strength as percentage (for WiFi and Wimax). | 1155 // Signal strength as percentage (for WiFi and Wimax). |
1062 var signalStrength = | 1156 var signalStrength; |
1063 (data.WiFi && data.WiFi.SignalStrength) ? data.WiFi.SignalStrength : 0; | 1157 if (data.type == 'WiFi' || data.type == 'Wimax') { |
1158 signalStrength = | |
1159 getActiveDictionaryValue(data, data.type, 'SignalStrength'); | |
1160 } | |
1161 if (!signalStrength) | |
1162 signalStrength = 0; | |
1064 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1163 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
1065 strengthFormat = strengthFormat.replace('$1', signalStrength); | 1164 var strengthString = strengthFormat.replace('$1', signalStrength); |
1066 | 1165 |
1067 if (data.Type == 'WiFi') { | 1166 detailsPage.type = data.type; |
1167 if (data.type == 'WiFi') { | |
1168 assert(data.WiFi, 'WiFi network has no WiFi object' + networkName); | |
1068 OptionsPage.showTab($('wifi-network-nav-tab')); | 1169 OptionsPage.showTab($('wifi-network-nav-tab')); |
1069 detailsPage.wireless = true; | |
1070 detailsPage.vpn = false; | |
1071 detailsPage.ethernet = false; | |
1072 detailsPage.cellular = false; | |
1073 detailsPage.gsm = false; | 1170 detailsPage.gsm = false; |
1074 detailsPage.wimax = false; | |
1075 detailsPage.shared = data.shared; | 1171 detailsPage.shared = data.shared; |
1076 $('wifi-connection-state').textContent = connectionStateString; | 1172 $('wifi-connection-state').textContent = connectionStateString; |
1077 $('wifi-ssid').textContent = data.WiFi ? data.WiFi.SSID : data.Name; | 1173 var ssid = getActiveDictionaryValue(data, 'WiFi', 'SSID'); |
1078 if (data.WiFi && data.WiFi.BSSID) { | 1174 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
1079 $('wifi-bssid').textContent = data.WiFi.BSSID; | 1175 setOrHideParent('wifi-bssid', |
1080 $('wifi-bssid-entry').hidden = false; | 1176 getActiveDictionaryValue(data, 'WiFi', 'BSSID')); |
1081 } else { | 1177 var security = getActiveDictionaryValue(data, 'WiFi', 'Security'); |
1082 $('wifi-bssid-entry').hidden = true; | 1178 if (security == 'None') |
1083 } | 1179 security = undefined; |
1084 $('wifi-ip-address').textContent = inetAddress.value; | 1180 setOrHideParent('wifi-security', security); |
1085 $('wifi-netmask').textContent = inetNetmask.value; | |
1086 $('wifi-gateway').textContent = inetGateway.value; | |
1087 $('wifi-name-servers').textContent = inetNameServers; | |
1088 var hasSecurity = isSecureWiFiNetwork(data); | |
1089 if (hasSecurity) { | |
1090 $('wifi-security').textContent = data.WiFi.Security; | |
1091 $('wifi-security-entry').hidden = false; | |
1092 } else { | |
1093 $('wifi-security-entry').hidden = true; | |
1094 } | |
1095 // Frequency is in MHz. | 1181 // Frequency is in MHz. |
1096 var frequency = | 1182 var frequency = getActiveDictionaryValue(data, 'WiFi', 'Frequency'); |
1097 data.WiFi && data.WiFi.Frequency ? data.WiFi.Frequency : 0; | 1183 if (!frequency) |
1184 frequency = 0; | |
1098 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); | 1185 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); |
1099 frequencyFormat = frequencyFormat.replace('$1', frequency); | 1186 frequencyFormat = frequencyFormat.replace('$1', frequency); |
1100 $('wifi-frequency').textContent = frequencyFormat; | 1187 $('wifi-frequency').textContent = frequencyFormat; |
1101 $('wifi-signal-strength').textContent = strengthFormat; | 1188 $('wifi-signal-strength').textContent = strengthString; |
1102 if (data.MacAddress) { | 1189 setOrHideParent('wifi-hardware-address', |
1103 $('wifi-hardware-address').textContent = data.MacAddress; | 1190 getActiveValue(data, 'MacAddress')); |
1104 $('wifi-hardware-address-entry').hidden = false; | |
1105 } else { | |
1106 $('wifi-hardware-address-entry').hidden = true; | |
1107 } | |
1108 detailsPage.showPreferred = data.remembered; | 1191 detailsPage.showPreferred = data.remembered; |
1109 $('prefer-network-wifi').checked = data.preferred.value; | 1192 $('prefer-network-wifi').checked = data.preferred.value; |
1110 $('prefer-network-wifi').disabled = !data.remembered; | 1193 $('prefer-network-wifi').disabled = !data.remembered; |
1111 $('auto-connect-network-wifi').checked = data.autoConnect.value; | 1194 $('auto-connect-network-wifi').checked = |
1195 getActiveValue(data, 'AutoConnect'); | |
1112 $('auto-connect-network-wifi').disabled = !data.remembered; | 1196 $('auto-connect-network-wifi').disabled = !data.remembered; |
1113 detailsPage.hasSecurity = hasSecurity; | 1197 detailsPage.hasSecurity = security != undefined; |
1114 } else if (data.Type == 'Wimax') { | 1198 } else if (data.type == 'Wimax') { |
1199 assert(data.Wimax, 'Wimax network has no Wimax object' + networkName); | |
1115 OptionsPage.showTab($('wimax-network-nav-tab')); | 1200 OptionsPage.showTab($('wimax-network-nav-tab')); |
1116 detailsPage.wimax = true; | |
1117 detailsPage.wireless = false; | |
1118 detailsPage.vpn = false; | |
1119 detailsPage.ethernet = false; | |
1120 detailsPage.cellular = false; | |
1121 detailsPage.gsm = false; | 1201 detailsPage.gsm = false; |
1122 detailsPage.shared = data.shared; | 1202 detailsPage.shared = data.shared; |
1123 detailsPage.showPreferred = data.remembered; | 1203 detailsPage.showPreferred = data.remembered; |
1124 $('wimax-connection-state').textContent = connectionStateString; | 1204 $('wimax-connection-state').textContent = connectionStateString; |
1125 $('auto-connect-network-wimax').checked = data.autoConnect.value; | 1205 $('auto-connect-network-wimax').checked = |
1206 getActiveValue(data, 'AutoConnect'); | |
1126 $('auto-connect-network-wimax').disabled = !data.remembered; | 1207 $('auto-connect-network-wimax').disabled = !data.remembered; |
1127 if (data.identity) { | 1208 var identity; |
1128 $('wimax-eap-identity').textContent = data.identity; | 1209 if (data.Wimax.EAP) |
1129 $('wimax-eap-identity-entry').hidden = false; | 1210 identity = getActiveValue(data.Wimax.EAP, 'Identity'); |
1130 } else { | 1211 setOrHideParent('wimax-eap-identity', identity); |
1131 $('wimax-eap-identity-entry').hidden = true; | 1212 $('wimax-signal-strength').textContent = strengthString; |
1132 } | 1213 } else if (data.type == 'Cellular') { |
1133 $('wimax-signal-strength').textContent = strengthFormat; | 1214 assert(data.Cellular, |
1134 } else if (data.Type == 'Cellular') { | 1215 'Cellular network has no Cellular object' + networkName); |
1135 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1216 OptionsPage.showTab($('cellular-conn-nav-tab')); |
1136 detailsPage.ethernet = false; | |
1137 detailsPage.wireless = false; | |
1138 detailsPage.wimax = false; | |
1139 detailsPage.vpn = false; | |
1140 detailsPage.cellular = true; | |
1141 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1217 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
1142 var carrierSelector = $('select-carrier'); | 1218 var carrierSelector = $('select-carrier'); |
1143 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1219 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
1144 carrierSelector.options.length = 0; | 1220 carrierSelector.options.length = 0; |
1145 for (var i = 0; i < data.carriers.length; ++i) { | 1221 for (var i = 0; i < data.carriers.length; ++i) { |
1146 var option = document.createElement('option'); | 1222 var option = document.createElement('option'); |
1147 option.textContent = data.carriers[i]; | 1223 option.textContent = data.carriers[i]; |
1148 carrierSelector.add(option); | 1224 carrierSelector.add(option); |
1149 } | 1225 } |
1150 carrierSelector.selectedIndex = data.currentCarrierIndex; | 1226 carrierSelector.selectedIndex = data.currentCarrierIndex; |
1151 } else { | 1227 } else { |
1152 $('service-name').textContent = getNetworkName(data); | 1228 $('service-name').textContent = networkName; |
1153 } | 1229 } |
1154 | 1230 |
1155 $('network-technology').textContent = data.Cellular.NetworkTechnology; | 1231 $('network-technology').textContent = |
1232 getActiveDictionaryValue(data, 'Cellular', 'NetworkTechnology'); | |
1156 $('activation-state').textContent = data.activationState; | 1233 $('activation-state').textContent = data.activationState; |
1157 $('roaming-state').textContent = data.roamingState; | 1234 $('roaming-state').textContent = data.roamingState; |
1158 $('restricted-pool').textContent = data.restrictedPool; | 1235 $('restricted-pool').textContent = data.restrictedPool; |
1159 $('error-state').textContent = data.errorState; | 1236 $('error-state').textContent = data.errorMessage; |
1160 $('manufacturer').textContent = data.Cellular.Manufacturer; | 1237 $('manufacturer').textContent = |
1161 $('model-id').textContent = data.Cellular.ModelID; | 1238 getActiveDictionaryValue(data, 'Cellular', 'Manufacturer'); |
1162 $('firmware-revision').textContent = data.Cellular.FirmwareRevision; | 1239 $('model-id').textContent = |
1163 $('hardware-revision').textContent = data.Cellular.HardwareRevision; | 1240 getActiveDictionaryValue(data, 'Cellular', 'ModelID'); |
1164 $('mdn').textContent = data.Cellular.MDN; | 1241 $('firmware-revision').textContent = |
1242 getActiveDictionaryValue(data, 'Cellular', 'FirmwareRevision'); | |
1243 $('hardware-revision').textContent = | |
1244 getActiveDictionaryValue(data, 'Cellular', 'HardwareRevision'); | |
1245 $('mdn').textContent = getActiveDictionaryValue(data, 'Cellular', 'MDN'); | |
1165 | 1246 |
1166 // Show ServingOperator properties only if available. | 1247 // Show ServingOperator properties only if available. |
1167 if (data.Cellular.ServingOperator) { | 1248 if (data.Cellular.ServingOperator) { |
1168 $('operator-name').textContent = data.Cellular.ServingOperator.Name; | 1249 $('operator-name').textContent = |
1169 $('operator-code').textContent = data.Cellular.ServingOperator.Code; | 1250 getActiveValue(data.Cellular.ServingOperator, 'Name'); |
1251 $('operator-code').textContent = | |
1252 getActiveValue(data.Cellular.ServingOperator, 'Code'); | |
1170 } else { | 1253 } else { |
1171 $('operator-name').parentElement.hidden = true; | 1254 $('operator-name').parentElement.hidden = true; |
1172 $('operator-code').parentElement.hidden = true; | 1255 $('operator-code').parentElement.hidden = true; |
1173 } | 1256 } |
1174 // Make sure that GSM/CDMA specific properties that shouldn't be hidden | 1257 // Make sure that GSM/CDMA specific properties that shouldn't be hidden |
1175 // are visible. | 1258 // are visible. |
1176 updateHidden('#details-internet-page .gsm-only', false); | 1259 updateHidden('#details-internet-page .gsm-only', false); |
1177 updateHidden('#details-internet-page .cdma-only', false); | 1260 updateHidden('#details-internet-page .cdma-only', false); |
1178 | 1261 |
1179 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. | 1262 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. |
1180 (function() { | 1263 setOrHideParent('esn', getActiveDictionaryValue(data, 'Cellular', 'ESN')); |
1181 var setContentOrHide = function(field, value) { | 1264 setOrHideParent( |
1182 if (value) | 1265 'imei', getActiveDictionaryValue(data, 'Cellular', 'IMEI')); |
1183 $(field).textContent = value; | 1266 setOrHideParent( |
1184 else | 1267 'meid', getActiveDictionaryValue(data, 'Cellular', 'MEID')); |
1185 $(field).parentElement.hidden = true; | 1268 setOrHideParent('min', getActiveDictionaryValue(data, 'Cellular', 'MIN')); |
1186 }; | 1269 setOrHideParent( |
1187 setContentOrHide('esn', data.Cellular.ESN); | 1270 'prl-version', |
1188 setContentOrHide('imei', data.Cellular.IMEI); | 1271 getActiveDictionaryValue(data, 'Cellular', 'PRLVersion')); |
1189 setContentOrHide('meid', data.Cellular.MEID); | 1272 |
1190 setContentOrHide('min', data.Cellular.MIN); | 1273 var family = getActiveDictionaryValue(data, 'Cellular', 'GSM'); |
1191 setContentOrHide('prl-version', data.Cellular.PRLVersion); | 1274 detailsPage.gsm = family == 'GSM'; |
1192 })(); | |
1193 detailsPage.gsm = data.Cellular.Family == 'GSM'; | |
1194 if (detailsPage.gsm) { | 1275 if (detailsPage.gsm) { |
1195 $('iccid').textContent = data.Cellular.ICCID; | 1276 $('iccid').textContent = |
1196 $('imsi').textContent = data.Cellular.IMSI; | 1277 getActiveDictionaryValue(data, 'Cellular', 'ICCID'); |
1278 $('imsi').textContent = | |
1279 getActiveDictionaryValue(data, 'Cellular', 'IMSI'); | |
1197 | 1280 |
1198 var apnSelector = $('select-apn'); | 1281 var apnSelector = $('select-apn'); |
1199 // Clear APN lists, keep only last element that "other". | 1282 // Clear APN lists, keep only last element that "other". |
1200 while (apnSelector.length != 1) | 1283 while (apnSelector.length != 1) |
1201 apnSelector.remove(0); | 1284 apnSelector.remove(0); |
1202 var otherOption = apnSelector[0]; | 1285 var otherOption = apnSelector[0]; |
1203 data.selectedApn = -1; | 1286 data.selectedApn = -1; |
1204 data.userApnIndex = -1; | 1287 data.userApnIndex = -1; |
1205 var apnList = data.providerApnList.value; | 1288 var apnList = data.providerApnList.value; |
1206 for (var i = 0; i < apnList.length; i++) { | 1289 for (var i = 0; i < apnList.length; i++) { |
(...skipping 28 matching lines...) Expand all Loading... | |
1235 data.userApnIndex = data.selectedApn; | 1318 data.userApnIndex = data.selectedApn; |
1236 } | 1319 } |
1237 apnSelector.selectedIndex = data.selectedApn; | 1320 apnSelector.selectedIndex = data.selectedApn; |
1238 updateHidden('.apn-list-view', false); | 1321 updateHidden('.apn-list-view', false); |
1239 updateHidden('.apn-details-view', true); | 1322 updateHidden('.apn-details-view', true); |
1240 // TODO(stevenjb): Used managed properties for policy controlled value. | 1323 // TODO(stevenjb): Used managed properties for policy controlled value. |
1241 var lockEnabled = data.simCardLockEnabled.value; | 1324 var lockEnabled = data.simCardLockEnabled.value; |
1242 $('sim-card-lock-enabled').checked = lockEnabled; | 1325 $('sim-card-lock-enabled').checked = lockEnabled; |
1243 $('change-pin').hidden = !lockEnabled; | 1326 $('change-pin').hidden = !lockEnabled; |
1244 } | 1327 } |
1245 $('auto-connect-network-cellular').checked = data.autoConnect.value; | 1328 $('auto-connect-network-cellular').checked = |
1329 getActiveValue(data, 'AutoConnect'); | |
1246 $('auto-connect-network-cellular').disabled = false; | 1330 $('auto-connect-network-cellular').disabled = false; |
1247 | 1331 |
1248 $('buyplan-details').hidden = !data.showBuyButton; | 1332 $('buyplan-details').hidden = !data.showBuyButton; |
1249 $('view-account-details').hidden = !data.showViewAccountButton; | 1333 $('view-account-details').hidden = !data.showViewAccountButton; |
1250 $('activate-details').hidden = !data.showActivateButton; | 1334 $('activate-details').hidden = !data.showActivateButton; |
1251 if (data.showActivateButton) { | 1335 if (data.showActivateButton) { |
1252 $('details-internet-login').hidden = true; | 1336 $('details-internet-login').hidden = true; |
1253 } | 1337 } |
1254 } else if (data.Type == 'VPN') { | 1338 } else if (data.type == 'VPN') { |
1255 OptionsPage.showTab($('vpn-nav-tab')); | 1339 OptionsPage.showTab($('vpn-nav-tab')); |
1256 detailsPage.wireless = false; | |
1257 detailsPage.wimax = false; | |
1258 detailsPage.vpn = true; | |
1259 detailsPage.ethernet = false; | |
1260 detailsPage.cellular = false; | |
1261 detailsPage.gsm = false; | 1340 detailsPage.gsm = false; |
1262 $('inet-service-name').textContent = getNetworkName(data); | 1341 $('inet-service-name').textContent = networkName; |
1263 $('inet-provider-type').textContent = data.providerType; | 1342 $('inet-provider-type').textContent = data.providerType; |
1264 $('inet-username').textContent = data.username; | 1343 $('inet-username').textContent = data.username; |
1265 var inetServerHostname = $('inet-server-hostname'); | 1344 var inetServerHostname = $('inet-server-hostname'); |
1266 inetServerHostname.value = data.serverHostname.value; | 1345 inetServerHostname.value = data.serverHostname.value; |
1267 inetServerHostname.resetHandler = function() { | 1346 inetServerHostname.resetHandler = function() { |
1268 PageManager.hideBubble(); | 1347 PageManager.hideBubble(); |
1269 inetServerHostname.value = data.serverHostname.recommendedValue; | 1348 inetServerHostname.value = data.serverHostname.recommendedValue; |
1270 }; | 1349 }; |
1271 $('auto-connect-network-vpn').checked = data.autoConnect.value; | 1350 $('auto-connect-network-vpn').checked = |
1351 getActiveValue(data, 'AutoConnect'); | |
1272 $('auto-connect-network-vpn').disabled = false; | 1352 $('auto-connect-network-vpn').disabled = false; |
1273 } else { | 1353 } else { |
1274 OptionsPage.showTab($('internet-nav-tab')); | 1354 OptionsPage.showTab($('internet-nav-tab')); |
1275 detailsPage.ethernet = true; | |
1276 detailsPage.wireless = false; | |
1277 detailsPage.wimax = false; | |
1278 detailsPage.vpn = false; | |
1279 detailsPage.cellular = false; | |
1280 detailsPage.gsm = false; | |
1281 } | 1355 } |
1282 | 1356 |
1283 // Update controlled option indicators. | 1357 // Update controlled option indicators. |
1284 indicators = cr.doc.querySelectorAll( | 1358 var indicators = cr.doc.querySelectorAll( |
1285 '#details-internet-page .controlled-setting-indicator'); | 1359 '#details-internet-page .controlled-setting-indicator'); |
1286 for (var i = 0; i < indicators.length; i++) { | 1360 for (var i = 0; i < indicators.length; i++) { |
1287 var propName = indicators[i].getAttribute('data'); | 1361 var attributeName = |
1362 indicators[i].hasAttribute('managed') ? 'managed' : 'data'; | |
1363 var propName = indicators[i].getAttribute(attributeName); | |
1288 if (!propName || !data[propName]) | 1364 if (!propName || !data[propName]) |
1289 continue; | 1365 continue; |
1290 var propData = data[propName]; | 1366 var event; |
1291 // Create a synthetic pref change event decorated as | 1367 if (attributeName == 'managed') |
1292 // CoreOptionsHandler::CreateValueForPref() does. | 1368 event = detailsPage.createManagedEvent_(propName, data[propName]); |
1293 var event = new Event(name); | 1369 else |
1294 event.value = { | 1370 event = detailsPage.createControlledEvent_(propName, data[propName]); |
1295 value: propData.value, | |
1296 controlledBy: propData.controlledBy, | |
1297 recommendedValue: propData.recommendedValue | |
1298 }; | |
1299 indicators[i].handlePrefChange(event); | 1371 indicators[i].handlePrefChange(event); |
1300 var forElement = $(indicators[i].getAttribute('for')); | 1372 var forElement = $(indicators[i].getAttribute('for')); |
1301 if (forElement) { | 1373 if (forElement) { |
1302 if (propData.controlledBy == 'policy') | 1374 if (event.value.controlledBy == 'policy') |
1303 forElement.disabled = true; | 1375 forElement.disabled = true; |
1304 if (forElement.resetHandler) | 1376 if (forElement.resetHandler) |
1305 indicators[i].resetHandler = forElement.resetHandler; | 1377 indicators[i].resetHandler = forElement.resetHandler; |
1306 } | 1378 } |
1307 } | 1379 } |
1308 | 1380 |
1309 detailsPage.updateControls(); | 1381 detailsPage.updateControls(); |
1310 | 1382 |
1311 // Don't show page name in address bar and in history to prevent people | 1383 // Don't show page name in address bar and in history to prevent people |
1312 // navigate here by hand and solve issue with page session restore. | 1384 // navigate here by hand and solve issue with page session restore. |
1313 PageManager.showPageByName('detailsInternetPage', false); | 1385 PageManager.showPageByName('detailsInternetPage', false); |
1314 }; | 1386 }; |
1315 | 1387 |
1316 return { | 1388 return { |
1317 DetailsInternetPage: DetailsInternetPage | 1389 DetailsInternetPage: DetailsInternetPage |
1318 }; | 1390 }; |
1319 }); | 1391 }); |
OLD | NEW |