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

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

Issue 701243002: Fix JS errors for Cellular (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « chrome/browser/resources/options/chromeos/internet_detail.html ('k') | 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
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 var apnList = onc.getActiveValue('Cellular.APNList'); 773 var apnList = onc.getActiveValue('Cellular.APNList');
774 for (var i = 0; i < apnList.length; i++) { 774 for (var i = 0; i < apnList.length; i++) {
775 var apnDict = apnList[i]; 775 var apnDict = apnList[i];
776 var option = document.createElement('option'); 776 var option = document.createElement('option');
777 var localizedName = apnDict['LocalizedName']; 777 var localizedName = apnDict['LocalizedName'];
778 var name = localizedName ? localizedName : apnDict['Name']; 778 var name = localizedName ? localizedName : apnDict['Name'];
779 var accessPointName = apnDict['AccessPointName']; 779 var accessPointName = apnDict['AccessPointName'];
780 option.textContent = 780 option.textContent =
781 name ? (name + ' (' + accessPointName + ')') : accessPointName; 781 name ? (name + ' (' + accessPointName + ')') : accessPointName;
782 option.value = i; 782 option.value = i;
783 // If this matches the active Apn, or LastGoodApn, set it as the 783 // Insert new option before "other" option.
784 // selected Apn. 784 apnSelector.add(option, otherOption);
785 if (this.selectedApnIndex_ != -1)
786 continue;
787 // If this matches the active Apn, or LastGoodApn (or there is no last
788 // good APN), set it as the selected Apn.
785 if ((activeApn == accessPointName && 789 if ((activeApn == accessPointName &&
786 activeUsername == apnDict['Username'] && 790 activeUsername == apnDict['Username'] &&
787 activePassword == apnDict['Password']) || 791 activePassword == apnDict['Password']) ||
792 (!activeApn && !lastGoodApn) ||
788 (!activeApn && 793 (!activeApn &&
789 lastGoodApn == accessPointName && 794 lastGoodApn == accessPointName &&
790 lastGoodUsername == apnDict['Username'] && 795 lastGoodUsername == apnDict['Username'] &&
791 lastGoodPassword == apnDict['Password'])) { 796 lastGoodPassword == apnDict['Password'])) {
792 this.selectedApnIndex_ = i; 797 this.selectedApnIndex_ = i;
793 } 798 }
794 // Insert new option before "other" option.
795 apnSelector.add(option, otherOption);
796 } 799 }
797 if (this.selectedApnIndex_ == -1 && activeApn) { 800 if (this.selectedApnIndex_ == -1 && activeApn) {
798 var activeOption = document.createElement('option'); 801 var activeOption = document.createElement('option');
799 activeOption.textContent = activeApn; 802 activeOption.textContent = activeApn;
800 activeOption.value = -1; 803 activeOption.value = -1;
801 apnSelector.add(activeOption, otherOption); 804 apnSelector.add(activeOption, otherOption);
802 this.selectedApnIndex_ = apnSelector.length - 2; 805 this.selectedApnIndex_ = apnSelector.length - 2;
803 this.userApnIndex_ = this.selectedApnIndex_; 806 this.userApnIndex_ = this.selectedApnIndex_;
804 } 807 }
805 assert(this.selectedApnIndex_ >= 0); 808 assert(this.selectedApnIndex_ >= 0);
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 $('auto-connect-network-vpn').disabled = false; 1556 $('auto-connect-network-vpn').disabled = false;
1554 } else { 1557 } else {
1555 OptionsPage.showTab($('internet-nav-tab')); 1558 OptionsPage.showTab($('internet-nav-tab'));
1556 } 1559 }
1557 1560
1558 // Update controlled option indicators. 1561 // Update controlled option indicators.
1559 var indicators = cr.doc.querySelectorAll( 1562 var indicators = cr.doc.querySelectorAll(
1560 '#details-internet-page .controlled-setting-indicator'); 1563 '#details-internet-page .controlled-setting-indicator');
1561 for (var i = 0; i < indicators.length; i++) { 1564 for (var i = 0; i < indicators.length; i++) {
1562 var managed = indicators[i].hasAttribute('managed'); 1565 var managed = indicators[i].hasAttribute('managed');
1566 // TODO(stevenjb): Eliminate support for 'data' once 39 is stable.
1563 var attributeName = managed ? 'managed' : 'data'; 1567 var attributeName = managed ? 'managed' : 'data';
1564 var propName = indicators[i].getAttribute(attributeName); 1568 var propName = indicators[i].getAttribute(attributeName);
1565 if (!propName) 1569 if (!propName)
1566 continue; 1570 continue;
1567 var propValue = managed ? 1571 var propValue = managed ?
1568 onc.getManagedProperty(propName) : 1572 onc.getManagedProperty(propName) :
1569 onc.getActiveValue(propName); 1573 onc.getActiveValue(propName);
1570 if (propValue == undefined) 1574 // If the property is unset or unmanaged (i.e. not an Object) skip it.
1575 if (propValue == undefined || (typeof propValue != 'object'))
1571 continue; 1576 continue;
1572 propValue = assertInstanceof(propValue, Object);
1573 var event; 1577 var event;
1574 if (managed) 1578 if (managed)
1575 event = detailsPage.createManagedEvent_(propName, propValue); 1579 event = detailsPage.createManagedEvent_(propName, propValue);
1576 else 1580 else
1577 event = detailsPage.createControlledEvent_(propName, 1581 event = detailsPage.createControlledEvent_(propName,
1578 /** @type {{value: *, controlledBy: *, recommendedValue: *}} */( 1582 /** @type {{value: *, controlledBy: *, recommendedValue: *}} */(
1579 propValue)); 1583 propValue));
1580 indicators[i].handlePrefChange(event); 1584 indicators[i].handlePrefChange(event);
1581 var forElement = $(indicators[i].getAttribute('for')); 1585 var forElement = $(indicators[i].getAttribute('for'));
1582 if (forElement) { 1586 if (forElement) {
1583 if (event.value.controlledBy == 'policy') 1587 if (event.value.controlledBy == 'policy')
1584 forElement.disabled = true; 1588 forElement.disabled = true;
1585 if (forElement.resetHandler) 1589 if (forElement.resetHandler)
1586 indicators[i].resetHandler = forElement.resetHandler; 1590 indicators[i].resetHandler = forElement.resetHandler;
1587 } 1591 }
1588 } 1592 }
1589 1593
1590 detailsPage.updateControls(); 1594 detailsPage.updateControls();
1591 1595
1592 // Don't show page name in address bar and in history to prevent people 1596 // Don't show page name in address bar and in history to prevent people
1593 // navigate here by hand and solve issue with page session restore. 1597 // navigate here by hand and solve issue with page session restore.
1594 PageManager.showPageByName('detailsInternetPage', false); 1598 PageManager.showPageByName('detailsInternetPage', false);
1595 }; 1599 };
1596 1600
1597 return { 1601 return {
1598 DetailsInternetPage: DetailsInternetPage 1602 DetailsInternetPage: DetailsInternetPage
1599 }; 1603 };
1600 }); 1604 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/chromeos/internet_detail.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698