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 cr.define('options.internet', function() { | 5 cr.define('options.internet', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 8 |
9 /** | 9 /** |
| 10 * Network settings constants. These enums must match their C++ |
| 11 * counterparts. |
| 12 */ |
| 13 function Constants() {} |
| 14 |
| 15 // Network types: |
| 16 Constants.TYPE_UNKNOWN = 0; |
| 17 Constants.TYPE_ETHERNET = 1; |
| 18 Constants.TYPE_WIFI = 2; |
| 19 Constants.TYPE_WIMAX = 3; |
| 20 Constants.TYPE_BLUETOOTH = 4; |
| 21 Constants.TYPE_CELLULAR = 5; |
| 22 Constants.TYPE_VPN = 6; |
| 23 |
| 24 /* |
10 * Minimum delay in milliseconds before updating controls. Used to | 25 * Minimum delay in milliseconds before updating controls. Used to |
11 * consolidate update requests resulting from preference update | 26 * consolidate update requests resulting from preference update |
12 * notifications. | 27 * notifications. |
13 * @type {Number} | 28 * @type {Number} |
14 * @const | 29 * @const |
15 */ | 30 */ |
16 var minimumUpdateContentsDelay_ = 50; | 31 var minimumUpdateContentsDelay_ = 50; |
17 | 32 |
18 /** | 33 /** |
19 * Time of the last request to update controls in milliseconds. | 34 * Time of the last request to update controls in milliseconds. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 * Auto-activates the network details dialog if network information | 134 * Auto-activates the network details dialog if network information |
120 * is included in the URL. | 135 * is included in the URL. |
121 */ | 136 */ |
122 showNetworkDetails_: function() { | 137 showNetworkDetails_: function() { |
123 var params = parseQueryParams(window.location); | 138 var params = parseQueryParams(window.location); |
124 var servicePath = params.servicePath; | 139 var servicePath = params.servicePath; |
125 var networkType = params.networkType; | 140 var networkType = params.networkType; |
126 if (!servicePath || !servicePath.length || | 141 if (!servicePath || !servicePath.length || |
127 !networkType || !networkType.length) | 142 !networkType || !networkType.length) |
128 return; | 143 return; |
129 // TODO(kevers): Use more descriptive name for callback. | 144 chrome.send('networkCommand', |
130 chrome.send('buttonClickCallback', | |
131 [networkType, servicePath, 'options']); | 145 [networkType, servicePath, 'options']); |
132 }, | 146 }, |
133 | 147 |
134 /** | 148 /** |
135 * Initializes the contents of the page. | 149 * Initializes the contents of the page. |
136 */ | 150 */ |
137 initializePageContents_: function() { | 151 initializePageContents_: function() { |
138 $('details-internet-dismiss').addEventListener('click', function(event) { | 152 $('details-internet-dismiss').addEventListener('click', function(event) { |
139 DetailsInternetPage.setDetails(); | 153 DetailsInternetPage.setDetails(); |
140 }); | 154 }); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 527 |
514 DetailsInternetPage.updateSecurityTab = function(requirePin) { | 528 DetailsInternetPage.updateSecurityTab = function(requirePin) { |
515 $('sim-card-lock-enabled').checked = requirePin; | 529 $('sim-card-lock-enabled').checked = requirePin; |
516 $('change-pin').hidden = !requirePin; | 530 $('change-pin').hidden = !requirePin; |
517 }; | 531 }; |
518 | 532 |
519 | 533 |
520 DetailsInternetPage.loginFromDetails = function() { | 534 DetailsInternetPage.loginFromDetails = function() { |
521 var data = $('connection-state').data; | 535 var data = $('connection-state').data; |
522 var servicePath = data.servicePath; | 536 var servicePath = data.servicePath; |
523 // TODO(kevers): Use more descriptive name for callback. | 537 chrome.send('networkCommand', [String(data.type), |
524 chrome.send('buttonClickCallback', [String(data.type), | |
525 servicePath, | 538 servicePath, |
526 'connect']); | 539 'connect']); |
527 OptionsPage.closeOverlay(); | 540 OptionsPage.closeOverlay(); |
528 }; | 541 }; |
529 | 542 |
530 DetailsInternetPage.disconnectNetwork = function() { | 543 DetailsInternetPage.disconnectNetwork = function() { |
531 var data = $('connection-state').data; | 544 var data = $('connection-state').data; |
532 var servicePath = data.servicePath; | 545 var servicePath = data.servicePath; |
533 // TODO(kevers): Use more descriptive name for callback. | 546 chrome.send('networkCommand', [String(data.type), |
534 chrome.send('buttonClickCallback', [String(data.type), | |
535 servicePath, | 547 servicePath, |
536 'disconnect']); | 548 'disconnect']); |
537 OptionsPage.closeOverlay(); | 549 OptionsPage.closeOverlay(); |
538 }; | 550 }; |
539 | 551 |
540 DetailsInternetPage.activateFromDetails = function() { | 552 DetailsInternetPage.activateFromDetails = function() { |
541 var data = $('connection-state').data; | 553 var data = $('connection-state').data; |
542 var servicePath = data.servicePath; | 554 var servicePath = data.servicePath; |
543 if (data.type == options.internet.Constants.TYPE_CELLULAR) { | 555 if (data.type == Constants.TYPE_CELLULAR) { |
544 // TODO(kevers): Use more descriptive name for callback. | 556 chrome.send('networkCommand', [String(data.type), |
545 chrome.send('buttonClickCallback', [String(data.type), | |
546 String(servicePath), | 557 String(servicePath), |
547 'activate']); | 558 'activate']); |
548 } | 559 } |
549 OptionsPage.closeOverlay(); | 560 OptionsPage.closeOverlay(); |
550 }; | 561 }; |
551 | 562 |
552 DetailsInternetPage.setDetails = function() { | 563 DetailsInternetPage.setDetails = function() { |
553 var data = $('connection-state').data; | 564 var data = $('connection-state').data; |
554 var servicePath = data.servicePath; | 565 var servicePath = data.servicePath; |
555 if (data.type == options.internet.Constants.TYPE_WIFI) { | 566 if (data.type == Constants.TYPE_WIFI) { |
556 chrome.send('setPreferNetwork', | 567 chrome.send('setPreferNetwork', |
557 [String(servicePath), | 568 [String(servicePath), |
558 $('prefer-network-wifi').checked ? 'true' : 'false']); | 569 $('prefer-network-wifi').checked ? 'true' : 'false']); |
559 chrome.send('setAutoConnect', | 570 chrome.send('setAutoConnect', |
560 [String(servicePath), | 571 [String(servicePath), |
561 $('auto-connect-network-wifi').checked ? 'true' : 'false']); | 572 $('auto-connect-network-wifi').checked ? 'true' : 'false']); |
562 } else if (data.type == options.internet.Constants.TYPE_CELLULAR) { | 573 } else if (data.type == Constants.TYPE_CELLULAR) { |
563 chrome.send('setAutoConnect', | 574 chrome.send('setAutoConnect', |
564 [String(servicePath), | 575 [String(servicePath), |
565 $('auto-connect-network-cellular').checked ? 'true' : | 576 $('auto-connect-network-cellular').checked ? 'true' : |
566 'false']); | 577 'false']); |
567 } | 578 } |
568 var ipConfigList = $('ip-config-list'); | 579 var ipConfigList = $('ip-config-list'); |
569 chrome.send('setIPConfig', [String(servicePath), | 580 chrome.send('setIPConfig', [String(servicePath), |
570 $('ip-type-dhcp').checked ? 'true' : 'false', | 581 $('ip-type-dhcp').checked ? 'true' : 'false', |
571 ipConfigList.dataModel.item(0).value, | 582 ipConfigList.dataModel.item(0).value, |
572 ipConfigList.dataModel.item(1).value, | 583 ipConfigList.dataModel.item(1).value, |
573 ipConfigList.dataModel.item(2).value, | 584 ipConfigList.dataModel.item(2).value, |
574 ipConfigList.dataModel.item(3).value]); | 585 ipConfigList.dataModel.item(3).value]); |
575 OptionsPage.closeOverlay(); | 586 OptionsPage.closeOverlay(); |
576 }; | 587 }; |
577 | 588 |
578 DetailsInternetPage.showDetailedInfo = function(data) { | 589 DetailsInternetPage.showDetailedInfo = function(data) { |
579 var detailsPage = DetailsInternetPage.getInstance(); | 590 var detailsPage = DetailsInternetPage.getInstance(); |
580 | 591 |
581 // Populate header | 592 // Populate header |
582 $('network-details-title').textContent = data.networkName; | 593 $('network-details-title').textContent = data.networkName; |
583 var statusKey = data.connected ? 'networkConnected' : | 594 var statusKey = data.connected ? 'networkConnected' : |
584 'networkNotConnected'; | 595 'networkNotConnected'; |
585 $('network-details-subtitle-status').textContent = | 596 $('network-details-subtitle-status').textContent = |
586 localStrings.getString(statusKey); | 597 localStrings.getString(statusKey); |
587 var typeKey = null; | 598 var typeKey = null; |
588 var Constants = options.internet.Constants; | |
589 switch (data.type) { | 599 switch (data.type) { |
590 case Constants.TYPE_ETHERNET: | 600 case Constants.TYPE_ETHERNET: |
591 typeKey = 'ethernetTitle'; | 601 typeKey = 'ethernetTitle'; |
592 break; | 602 break; |
593 case Constants.TYPE_WIFI: | 603 case Constants.TYPE_WIFI: |
594 typeKey = 'wifiTitle'; | 604 typeKey = 'wifiTitle'; |
595 break; | 605 break; |
596 case Constants.TYPE_CELLULAR: | 606 case Constants.TYPE_CELLULAR: |
597 typeKey = 'cellularTitle'; | 607 typeKey = 'cellularTitle'; |
598 break; | 608 break; |
(...skipping 13 matching lines...) Expand all Loading... |
612 } | 622 } |
613 | 623 |
614 // TODO(chocobo): Is this hack to cache the data here reasonable? | 624 // TODO(chocobo): Is this hack to cache the data here reasonable? |
615 // TODO(kevers): Find more appropriate place to cache data. | 625 // TODO(kevers): Find more appropriate place to cache data. |
616 $('connection-state').data = data; | 626 $('connection-state').data = data; |
617 | 627 |
618 $('buyplan-details').hidden = true; | 628 $('buyplan-details').hidden = true; |
619 $('activate-details').hidden = true; | 629 $('activate-details').hidden = true; |
620 $('view-account-details').hidden = true; | 630 $('view-account-details').hidden = true; |
621 $('details-internet-login').hidden = data.connected; | 631 $('details-internet-login').hidden = data.connected; |
622 if (data.type == options.internet.Constants.TYPE_ETHERNET) | 632 if (data.type == Constants.TYPE_ETHERNET) |
623 $('details-internet-disconnect').hidden = true; | 633 $('details-internet-disconnect').hidden = true; |
624 else | 634 else |
625 $('details-internet-disconnect').hidden = !data.connected; | 635 $('details-internet-disconnect').hidden = !data.connected; |
626 | 636 |
627 detailsPage.deviceConnected = data.deviceConnected; | 637 detailsPage.deviceConnected = data.deviceConnected; |
628 detailsPage.connecting = data.connecting; | 638 detailsPage.connecting = data.connecting; |
629 detailsPage.connected = data.connected; | 639 detailsPage.connected = data.connected; |
630 detailsPage.showProxy = data.showProxy; | 640 detailsPage.showProxy = data.showProxy; |
631 $('connection-state').textContent = data.connectionState; | 641 $('connection-state').textContent = data.connectionState; |
632 | 642 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 ipConfigList.selectionModel.selectedIndex = 0; | 716 ipConfigList.selectionModel.selectedIndex = 0; |
707 }); | 717 }); |
708 | 718 |
709 if (data.hardwareAddress) { | 719 if (data.hardwareAddress) { |
710 $('hardware-address').textContent = data.hardwareAddress; | 720 $('hardware-address').textContent = data.hardwareAddress; |
711 $('hardware-address-row').style.display = 'table-row'; | 721 $('hardware-address-row').style.display = 'table-row'; |
712 } else { | 722 } else { |
713 // This is most likely a device without a hardware address. | 723 // This is most likely a device without a hardware address. |
714 $('hardware-address-row').style.display = 'none'; | 724 $('hardware-address-row').style.display = 'none'; |
715 } | 725 } |
716 if (data.type == options.internet.Constants.TYPE_WIFI) { | 726 if (data.type == Constants.TYPE_WIFI) { |
717 OptionsPage.showTab($('wifi-network-nav-tab')); | 727 OptionsPage.showTab($('wifi-network-nav-tab')); |
718 detailsPage.wireless = true; | 728 detailsPage.wireless = true; |
719 detailsPage.vpn = false; | 729 detailsPage.vpn = false; |
720 detailsPage.ethernet = false; | 730 detailsPage.ethernet = false; |
721 detailsPage.cellular = false; | 731 detailsPage.cellular = false; |
722 detailsPage.gsm = false; | 732 detailsPage.gsm = false; |
723 detailsPage.shared = data.shared; | 733 detailsPage.shared = data.shared; |
724 $('wifi-connection-state').textContent = data.connectionState; | 734 $('wifi-connection-state').textContent = data.connectionState; |
725 $('wifi-ssid').textContent = data.ssid; | 735 $('wifi-ssid').textContent = data.ssid; |
726 if (data.bssid && data.bssid.length > 0) { | 736 if (data.bssid && data.bssid.length > 0) { |
(...skipping 25 matching lines...) Expand all Loading... |
752 $('wifi-hardware-address-entry').hidden = false; | 762 $('wifi-hardware-address-entry').hidden = false; |
753 } else { | 763 } else { |
754 $('wifi-hardware-address-entry').hidden = true; | 764 $('wifi-hardware-address-entry').hidden = true; |
755 } | 765 } |
756 detailsPage.showPreferred = data.showPreferred; | 766 detailsPage.showPreferred = data.showPreferred; |
757 $('prefer-network-wifi').checked = data.preferred.value; | 767 $('prefer-network-wifi').checked = data.preferred.value; |
758 $('prefer-network-wifi').disabled = !data.remembered; | 768 $('prefer-network-wifi').disabled = !data.remembered; |
759 $('auto-connect-network-wifi').checked = data.autoConnect.value; | 769 $('auto-connect-network-wifi').checked = data.autoConnect.value; |
760 $('auto-connect-network-wifi').disabled = !data.remembered; | 770 $('auto-connect-network-wifi').disabled = !data.remembered; |
761 detailsPage.password = data.encrypted; | 771 detailsPage.password = data.encrypted; |
762 } else if (data.type == options.internet.Constants.TYPE_CELLULAR) { | 772 } else if (data.type == Constants.TYPE_CELLULAR) { |
763 if (!data.gsm) | 773 if (!data.gsm) |
764 OptionsPage.showTab($('cellular-plan-nav-tab')); | 774 OptionsPage.showTab($('cellular-plan-nav-tab')); |
765 else | 775 else |
766 OptionsPage.showTab($('cellular-conn-nav-tab')); | 776 OptionsPage.showTab($('cellular-conn-nav-tab')); |
767 detailsPage.ethernet = false; | 777 detailsPage.ethernet = false; |
768 detailsPage.wireless = false; | 778 detailsPage.wireless = false; |
769 detailsPage.vpn = false; | 779 detailsPage.vpn = false; |
770 detailsPage.cellular = true; | 780 detailsPage.cellular = true; |
771 $('service-name').textContent = data.serviceName; | 781 $('service-name').textContent = data.serviceName; |
772 $('network-technology').textContent = data.networkTechnology; | 782 $('network-technology').textContent = data.networkTechnology; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 | 856 |
847 detailsPage.hascellplan = false; | 857 detailsPage.hascellplan = false; |
848 if (data.connected) { | 858 if (data.connected) { |
849 detailsPage.nocellplan = false; | 859 detailsPage.nocellplan = false; |
850 detailsPage.cellplanloading = true; | 860 detailsPage.cellplanloading = true; |
851 chrome.send('refreshCellularPlan', [data.servicePath]); | 861 chrome.send('refreshCellularPlan', [data.servicePath]); |
852 } else { | 862 } else { |
853 detailsPage.nocellplan = true; | 863 detailsPage.nocellplan = true; |
854 detailsPage.cellplanloading = false; | 864 detailsPage.cellplanloading = false; |
855 } | 865 } |
856 } else if (data.type == options.internet.Constants.TYPE_VPN) { | 866 } else if (data.type == Constants.TYPE_VPN) { |
857 OptionsPage.showTab($('vpn-nav-tab')); | 867 OptionsPage.showTab($('vpn-nav-tab')); |
858 detailsPage.wireless = false; | 868 detailsPage.wireless = false; |
859 detailsPage.vpn = true; | 869 detailsPage.vpn = true; |
860 detailsPage.ethernet = false; | 870 detailsPage.ethernet = false; |
861 detailsPage.cellular = false; | 871 detailsPage.cellular = false; |
862 detailsPage.gsm = false; | 872 detailsPage.gsm = false; |
863 $('inet-service-name').textContent = data.service_name; | 873 $('inet-service-name').textContent = data.service_name; |
864 $('inet-server-hostname').textContent = data.server_hostname; | 874 $('inet-server-hostname').textContent = data.server_hostname; |
865 $('inet-provider-type').textContent = data.provider_type; | 875 $('inet-provider-type').textContent = data.provider_type; |
866 $('inet-username').textContent = data.username; | 876 $('inet-username').textContent = data.username; |
(...skipping 30 matching lines...) Expand all Loading... |
897 | 907 |
898 // Don't show page name in address bar and in history to prevent people | 908 // Don't show page name in address bar and in history to prevent people |
899 // navigate here by hand and solve issue with page session restore. | 909 // navigate here by hand and solve issue with page session restore. |
900 OptionsPage.showPageByName('detailsInternetPage', false); | 910 OptionsPage.showPageByName('detailsInternetPage', false); |
901 }; | 911 }; |
902 | 912 |
903 return { | 913 return { |
904 DetailsInternetPage: DetailsInternetPage | 914 DetailsInternetPage: DetailsInternetPage |
905 }; | 915 }; |
906 }); | 916 }); |
OLD | NEW |