Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: chrome/browser/resources/options/chromeos/internet_detail.js

Issue 568413003: Fix typedef for InternetDetailedInfo in internet_detail.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // require: onc_data.js 5 // require: onc_data.js
6 6
7 // NOTE(stevenjb): This code is in the process of being converted to be 7 // NOTE(stevenjb): This code is in the process of being converted to be
8 // compatible with the networkingPrivate extension API: 8 // compatible with the networkingPrivate extension API:
9 // * The network property dictionaries are being converted to use ONC values. 9 // * The network property dictionaries are being converted to use ONC values.
10 // * chrome.send calls will be replaced with an API object that simulates the 10 // * chrome.send calls will be replaced with an API object that simulates the
11 // networkingPrivate API. See network_config.js. 11 // networkingPrivate API. See network_config.js.
12 // See crbug.com/279351 for more info. 12 // See crbug.com/279351 for more info.
13 13
14 /** @typedef {{activationState: (string|undefined), 14 /**
15 * carriers: Array, 15 * InternetDetailedInfo argument passed to showDetailedInfo.
16 * currentCarrierIndex; (number|undefined),
17 * ipAutoConfig: boolean,
18 * ipconfig: Object,
19 * nameServerType: string,
20 * restrictedPool: (string|undefined),
21 * roamingState: (string|undefined),
22 * savedIP: Object,
23 * showActivateButton: (boolean|undefined)
24 * showViewAccountButton: (boolean|undefined),
25 * staticIP: Object}}
26 * Only the keys which had caused problems are declared in this typedef.
27 * There are many more of them.
28 * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc 16 * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
17 * @typedef {{
18 * carriers: boolean,
Vitaly Pavlenko 2014/09/15 19:18:08 As it's being put in a dictionary only on some exe
stevenjb 2014/09/15 19:52:35 It actually should be (Array.<string>|undefined),
19 * currentCarrierIndex: boolean,
20 * deviceConnected: boolean,
21 * errorMessage: string,
22 * servicePath: boolean,
23 * showCarrierSelect: boolean,
24 * showViewAccountButton: boolean
Vitaly Pavlenko 2014/09/15 19:18:08 ^ same here: (boolean|undefined)
stevenjb 2014/09/15 19:52:35 Fixed this and other errors.
25 * }}
29 */ 26 */
30 var InternetDetailedInfo; 27 var InternetDetailedInfo;
31 28
32 cr.define('options.internet', function() { 29 cr.define('options.internet', function() {
33 var OncData = cr.onc.OncData; 30 var OncData = cr.onc.OncData;
34 var Page = cr.ui.pageManager.Page; 31 var Page = cr.ui.pageManager.Page;
35 var PageManager = cr.ui.pageManager.PageManager; 32 var PageManager = cr.ui.pageManager.PageManager;
36 /** @const */ var IPAddressField = options.internet.IPAddressField; 33 /** @const */ var IPAddressField = options.internet.IPAddressField;
37 34
38 /** @const */ var GoogleNameServersString = '8.8.4.4,8.8.8.8'; 35 /** @const */ var GoogleNameServersString = '8.8.4.4,8.8.8.8';
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 * @param {string} message The message to send to chrome. 91 * @param {string} message The message to send to chrome.
95 * @param {HTMLInputElement} checkbox The checkbox storing the value to send. 92 * @param {HTMLInputElement} checkbox The checkbox storing the value to send.
96 */ 93 */
97 function sendCheckedIfEnabled(path, message, checkbox) { 94 function sendCheckedIfEnabled(path, message, checkbox) {
98 if (!checkbox.hidden && !checkbox.disabled) 95 if (!checkbox.hidden && !checkbox.disabled)
99 chrome.send(message, [path, checkbox.checked ? 'true' : 'false']); 96 chrome.send(message, [path, checkbox.checked ? 'true' : 'false']);
100 } 97 }
101 98
102 /** 99 /**
103 * Returns the netmask as a string for a given prefix length. 100 * Returns the netmask as a string for a given prefix length.
104 * @param {string} prefixLength The ONC routing prefix length. 101 * @param {number} prefixLength The ONC routing prefix length.
105 * @return {string} The corresponding netmask. 102 * @return {string} The corresponding netmask.
106 */ 103 */
107 function prefixLengthToNetmask(prefixLength) { 104 function prefixLengthToNetmask(prefixLength) {
108 // Return the empty string for invalid inputs. 105 // Return the empty string for invalid inputs.
109 if (prefixLength < 0 || prefixLength > 32) 106 if (prefixLength < 0 || prefixLength > 32)
110 return ''; 107 return '';
111 var netmask = ''; 108 var netmask = '';
112 for (var i = 0; i < 4; ++i) { 109 for (var i = 0; i < 4; ++i) {
113 var remainder = 8; 110 var remainder = 8;
114 if (prefixLength >= 8) { 111 if (prefixLength >= 8) {
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 $('socks-host').disabled = allDisabled; 566 $('socks-host').disabled = allDisabled;
570 $('socks-port').disabled = allDisabled; 567 $('socks-port').disabled = allDisabled;
571 $('proxy-use-pac-url').disabled = true; 568 $('proxy-use-pac-url').disabled = true;
572 $('proxy-pac-url').disabled = true; 569 $('proxy-pac-url').disabled = true;
573 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; 570 $('auto-proxy-parms').hidden = !$('auto-proxy').checked;
574 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; 571 $('manual-proxy-parms').hidden = !$('manual-proxy').checked;
575 chrome.send('coreOptionsUserMetricsAction', 572 chrome.send('coreOptionsUserMetricsAction',
576 ['Options_NetworkManualProxy_Enable']); 573 ['Options_NetworkManualProxy_Enable']);
577 }, 574 },
578 575
576 /**
577 * Helper method called from showDetailedInfo and updateConnectionData.
578 * Updates visibilty/enabled of the login/disconnect/configure buttons.
579 * @private
580 */
579 updateConnectionButtonVisibilty_: function() { 581 updateConnectionButtonVisibilty_: function() {
580 var onc = this.onc_; 582 var onc = this.onc_;
581 if (this.type_ == 'Ethernet') { 583 if (this.type_ == 'Ethernet') {
582 // Ethernet can never be connected or disconnected and can always be 584 // Ethernet can never be connected or disconnected and can always be
583 // configured (e.g. to set security). 585 // configured (e.g. to set security).
584 $('details-internet-login').hidden = true; 586 $('details-internet-login').hidden = true;
585 $('details-internet-disconnect').hidden = true; 587 $('details-internet-disconnect').hidden = true;
586 $('details-internet-configure').hidden = false; 588 $('details-internet-configure').hidden = false;
587 return; 589 return;
588 } 590 }
(...skipping 14 matching lines...) Expand all
603 var connectable = onc.getActiveValue('Connectable'); 605 var connectable = onc.getActiveValue('Connectable');
604 if (connectState != 'Connected' && 606 if (connectState != 'Connected' &&
605 (!connectable || onc.getWiFiSecurity() != 'None' || 607 (!connectable || onc.getWiFiSecurity() != 'None' ||
606 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) { 608 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) {
607 $('details-internet-configure').hidden = false; 609 $('details-internet-configure').hidden = false;
608 } else { 610 } else {
609 $('details-internet-configure').hidden = true; 611 $('details-internet-configure').hidden = true;
610 } 612 }
611 }, 613 },
612 614
615 /**
616 * Helper method called from showDetailedInfo and updateConnectionData.
617 * Updates the connection state property and account / sim card links.
618 * @param {InternetDetailedInfo} data
619 * @private
620 */
613 updateDetails_: function(data) { 621 updateDetails_: function(data) {
614 var onc = this.onc_; 622 var onc = this.onc_;
615 623
616 if ('deviceConnected' in data) 624 if ('deviceConnected' in data)
617 this.deviceConnected_ = data.deviceConnected; 625 this.deviceConnected_ = data.deviceConnected;
618 626
619 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 627 var connectionStateString = onc.getTranslatedValue('ConnectionState');
620 $('connection-state').textContent = connectionStateString; 628 $('connection-state').textContent = connectionStateString;
621 629
622 var type = this.type_; 630 var type = this.type_;
(...skipping 18 matching lines...) Expand all
641 activationState == 'PartiallyActivated'; 649 activationState == 'PartiallyActivated';
642 } 650 }
643 651
644 $('view-account-details').hidden = !showViewAccount; 652 $('view-account-details').hidden = !showViewAccount;
645 $('activate-details').hidden = !showActivate; 653 $('activate-details').hidden = !showActivate;
646 // If activation is not complete, hide the login button. 654 // If activation is not complete, hide the login button.
647 if (showActivate) 655 if (showActivate)
648 $('details-internet-login').hidden = true; 656 $('details-internet-login').hidden = true;
649 }, 657 },
650 658
659 /**
660 * Helper method called from showDetailedInfo and updateConnectionData.
661 * Updates the fields in the header section of the details frame.
662 * @private
663 */
651 populateHeader_: function() { 664 populateHeader_: function() {
652 var onc = this.onc_; 665 var onc = this.onc_;
653 666
654 $('network-details-title').textContent = onc.getTranslatedValue('Name'); 667 $('network-details-title').textContent = onc.getTranslatedValue('Name');
655 var connectionState = onc.getActiveValue('ConnectionState'); 668 var connectionState = onc.getActiveValue('ConnectionState');
656 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 669 var connectionStateString = onc.getTranslatedValue('ConnectionState');
657 $('network-details-subtitle-status').textContent = connectionStateString; 670 $('network-details-subtitle-status').textContent = connectionStateString;
658 671
659 var typeKey; 672 var typeKey;
660 var type = this.type_; 673 var type = this.type_;
(...skipping 14 matching lines...) Expand all
675 if (typeKey) { 688 if (typeKey) {
676 typeLabel.textContent = loadTimeData.getString(typeKey); 689 typeLabel.textContent = loadTimeData.getString(typeKey);
677 typeLabel.hidden = false; 690 typeLabel.hidden = false;
678 typeSeparator.hidden = false; 691 typeSeparator.hidden = false;
679 } else { 692 } else {
680 typeLabel.hidden = true; 693 typeLabel.hidden = true;
681 typeSeparator.hidden = true; 694 typeSeparator.hidden = true;
682 } 695 }
683 }, 696 },
684 697
685 initializeApnList_: function(onc) { 698 /**
699 * Helper method called from showDetailedInfo to intialize the Apn list.
700 * @private
701 */
702 initializeApnList_: function() {
703 var onc = this.onc_;
704
686 var apnSelector = $('select-apn'); 705 var apnSelector = $('select-apn');
687 // Clear APN lists, keep only last element that "other". 706 // Clear APN lists, keep only last element that "other".
688 while (apnSelector.length != 1) { 707 while (apnSelector.length != 1) {
689 apnSelector.remove(0); 708 apnSelector.remove(0);
690 } 709 }
691 var otherOption = apnSelector[0]; 710 var otherOption = apnSelector[0];
692 var activeApn = onc.getActiveValue('Cellular.APN.AccessPointName'); 711 var activeApn = onc.getActiveValue('Cellular.APN.AccessPointName');
693 var activeUsername = onc.getActiveValue('Cellular.APN.Username'); 712 var activeUsername = onc.getActiveValue('Cellular.APN.Username');
694 var activePassword = onc.getActiveValue('Cellular.APN.Password'); 713 var activePassword = onc.getActiveValue('Cellular.APN.Password');
695 var lastGoodApn = 714 var lastGoodApn =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 apnSelector.add(activeOption, otherOption); 748 apnSelector.add(activeOption, otherOption);
730 this.selectedApnIndex_ = apnSelector.length - 2; 749 this.selectedApnIndex_ = apnSelector.length - 2;
731 this.userApnIndex_ = this.selectedApnIndex_; 750 this.userApnIndex_ = this.selectedApnIndex_;
732 } 751 }
733 assert(this.selectedApnIndex_ >= 0); 752 assert(this.selectedApnIndex_ >= 0);
734 apnSelector.selectedIndex = this.selectedApnIndex_; 753 apnSelector.selectedIndex = this.selectedApnIndex_;
735 updateHidden('.apn-list-view', false); 754 updateHidden('.apn-list-view', false);
736 updateHidden('.apn-details-view', true); 755 updateHidden('.apn-details-view', true);
737 }, 756 },
738 757
758 /**
759 * Event Listener for the cellular-apn-use-default button.
760 * @private
761 */
739 setDefaultApn_: function() { 762 setDefaultApn_: function() {
740 var onc = this.onc_; 763 var onc = this.onc_;
741 var apnSelector = $('select-apn'); 764 var apnSelector = $('select-apn');
742 765
743 if (this.userApnIndex_ != -1) { 766 if (this.userApnIndex_ != -1) {
744 apnSelector.remove(this.userApnIndex_); 767 apnSelector.remove(this.userApnIndex_);
745 this.userApnIndex_ = -1; 768 this.userApnIndex_ = -1;
746 } 769 }
747 770
748 var iApn = -1; 771 var iApn = -1;
(...skipping 12 matching lines...) Expand all
761 activeApn['Username'], 784 activeApn['Username'],
762 activeApn['Password']]); 785 activeApn['Password']]);
763 } 786 }
764 apnSelector.selectedIndex = iApn; 787 apnSelector.selectedIndex = iApn;
765 this.selectedApnIndex_ = iApn; 788 this.selectedApnIndex_ = iApn;
766 789
767 updateHidden('.apn-list-view', false); 790 updateHidden('.apn-list-view', false);
768 updateHidden('.apn-details-view', true); 791 updateHidden('.apn-details-view', true);
769 }, 792 },
770 793
794 /**
795 * Event Listener for the cellular-apn-set button.
796 * @private
797 */
771 setApn_: function(apnValue) { 798 setApn_: function(apnValue) {
772 if (apnValue == '') 799 if (apnValue == '')
773 return; 800 return;
774 801
775 var onc = this.onc_; 802 var onc = this.onc_;
776 var apnSelector = $('select-apn'); 803 var apnSelector = $('select-apn');
777 804
778 var activeApn = {}; 805 var activeApn = {};
779 activeApn['AccessPointName'] = stringFromValue(apnValue); 806 activeApn['AccessPointName'] = stringFromValue(apnValue);
780 activeApn['Username'] = stringFromValue($('cellular-apn-username').value); 807 activeApn['Username'] = stringFromValue($('cellular-apn-username').value);
(...skipping 15 matching lines...) Expand all
796 option.value = -1; 823 option.value = -1;
797 option.selected = true; 824 option.selected = true;
798 apnSelector.add(option, apnSelector[apnSelector.length - 1]); 825 apnSelector.add(option, apnSelector[apnSelector.length - 1]);
799 this.userApnIndex_ = apnSelector.length - 2; 826 this.userApnIndex_ = apnSelector.length - 2;
800 this.selectedApnIndex_ = this.userApnIndex_; 827 this.selectedApnIndex_ = this.userApnIndex_;
801 828
802 updateHidden('.apn-list-view', false); 829 updateHidden('.apn-list-view', false);
803 updateHidden('.apn-details-view', true); 830 updateHidden('.apn-details-view', true);
804 }, 831 },
805 832
833 /**
834 * Event Listener for the cellular-apn-cancel button.
835 * @private
836 */
806 cancelApn_: function() { 837 cancelApn_: function() {
807 $('select-apn').selectedIndex = this.selectedApnIndex_; 838 $('select-apn').selectedIndex = this.selectedApnIndex_;
808 updateHidden('.apn-list-view', false); 839 updateHidden('.apn-list-view', false);
809 updateHidden('.apn-details-view', true); 840 updateHidden('.apn-details-view', true);
810 }, 841 },
811 842
843 /**
844 * Event Listener for the select-apn button.
845 * @private
846 */
812 selectApn_: function() { 847 selectApn_: function() {
813 var onc = this.onc_; 848 var onc = this.onc_;
814 var apnSelector = $('select-apn'); 849 var apnSelector = $('select-apn');
815 var apnDict; 850 var apnDict;
816 if (apnSelector[apnSelector.selectedIndex].value != -1) { 851 if (apnSelector[apnSelector.selectedIndex].value != -1) {
817 var apnList = onc.getActiveValue('Cellular.APNList'); 852 var apnList = onc.getActiveValue('Cellular.APNList');
818 var apnIndex = apnSelector.selectedIndex; 853 var apnIndex = apnSelector.selectedIndex;
819 assert(apnIndex < apnList.length); 854 assert(apnIndex < apnList.length);
820 apnDict = apnList[apnIndex]; 855 apnDict = apnList[apnIndex];
821 chrome.send('setApn', [this.servicePath_, 856 chrome.send('setApn', [this.servicePath_,
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. 1405 // Show IMEI/ESN/MEID/MIN/PRL only if they are available.
1371 setOrHideParent('esn', onc.getActiveValue('Cellular.ESN')); 1406 setOrHideParent('esn', onc.getActiveValue('Cellular.ESN'));
1372 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI')); 1407 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI'));
1373 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID')); 1408 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID'));
1374 setOrHideParent('min', onc.getActiveValue('Cellular.MIN')); 1409 setOrHideParent('min', onc.getActiveValue('Cellular.MIN'));
1375 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion')); 1410 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion'));
1376 1411
1377 if (onc.getActiveValue('Cellular.Family') == 'GSM') { 1412 if (onc.getActiveValue('Cellular.Family') == 'GSM') {
1378 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); 1413 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID');
1379 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); 1414 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI');
1380 detailsPage.initializeApnList_(onc); 1415 detailsPage.initializeApnList_();
1381 } 1416 }
1382 $('auto-connect-network-cellular').checked = 1417 $('auto-connect-network-cellular').checked =
1383 onc.getActiveValue('AutoConnect'); 1418 onc.getActiveValue('AutoConnect');
1384 $('auto-connect-network-cellular').disabled = false; 1419 $('auto-connect-network-cellular').disabled = false;
1385 } else if (type == 'VPN') { 1420 } else if (type == 'VPN') {
1386 OptionsPage.showTab($('vpn-nav-tab')); 1421 OptionsPage.showTab($('vpn-nav-tab'));
1387 $('inet-service-name').textContent = networkName; 1422 $('inet-service-name').textContent = networkName;
1388 $('inet-provider-type').textContent = 1423 $('inet-provider-type').textContent =
1389 onc.getTranslatedValue('VPN.Type'); 1424 onc.getTranslatedValue('VPN.Type');
1390 var providerType = onc.getActiveValue('VPN.Type'); 1425 var providerType = onc.getActiveValue('VPN.Type');
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 1474
1440 // Don't show page name in address bar and in history to prevent people 1475 // Don't show page name in address bar and in history to prevent people
1441 // navigate here by hand and solve issue with page session restore. 1476 // navigate here by hand and solve issue with page session restore.
1442 PageManager.showPageByName('detailsInternetPage', false); 1477 PageManager.showPageByName('detailsInternetPage', false);
1443 }; 1478 };
1444 1479
1445 return { 1480 return {
1446 DetailsInternetPage: DetailsInternetPage 1481 DetailsInternetPage: DetailsInternetPage
1447 }; 1482 };
1448 }); 1483 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698