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