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