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