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