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

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

Issue 1006553002: Add third-party VPN support to network details dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_2_460428_add_ash_ui
Patch Set: Updated to read the extension ID from the new ONC property. Created 5 years, 9 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
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 chrome.networkingPrivate calls. 10 // * chrome.send calls will be replaced with chrome.networkingPrivate calls.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 }, 208 },
209 209
210 /** 210 /**
211 * Auto-activates the network details dialog if network information 211 * Auto-activates the network details dialog if network information
212 * is included in the URL. 212 * is included in the URL.
213 */ 213 */
214 showNetworkDetails_: function() { 214 showNetworkDetails_: function() {
215 var guid = parseQueryParams(window.location).guid; 215 var guid = parseQueryParams(window.location).guid;
216 if (!guid || !guid.length) 216 if (!guid || !guid.length)
217 return; 217 return;
218 chrome.send('updateVPNProviders');
218 chrome.networkingPrivate.getManagedProperties( 219 chrome.networkingPrivate.getManagedProperties(
219 guid, DetailsInternetPage.initializeDetailsPage); 220 guid, DetailsInternetPage.initializeDetailsPage);
220 }, 221 },
221 222
222 /** 223 /**
223 * Initializes the contents of the page. 224 * Initializes the contents of the page.
224 */ 225 */
225 initializePageContents_: function() { 226 initializePageContents_: function() {
226 $('details-internet-dismiss').addEventListener('click', function(event) { 227 $('details-internet-dismiss').addEventListener('click', function(event) {
227 DetailsInternetPage.setDetails(); 228 DetailsInternetPage.setDetails();
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 }, 750 },
750 751
751 /** 752 /**
752 * Helper method called from initializeDetailsPage and updateConnectionData. 753 * Helper method called from initializeDetailsPage and updateConnectionData.
753 * Updates the fields in the header section of the details frame. 754 * Updates the fields in the header section of the details frame.
754 * @private 755 * @private
755 */ 756 */
756 populateHeader_: function() { 757 populateHeader_: function() {
757 var onc = this.onc_; 758 var onc = this.onc_;
758 759
759 $('network-details-title').textContent = onc.getTranslatedValue('Name'); 760 $('network-details-title').textContent =
761 this.networkTitle_ || onc.getTranslatedValue('Name');
762
760 var connectionState = onc.getActiveValue('ConnectionState'); 763 var connectionState = onc.getActiveValue('ConnectionState');
761 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 764 var connectionStateString = onc.getTranslatedValue('ConnectionState');
762 $('network-details-subtitle-status').textContent = connectionStateString; 765 $('network-details-subtitle-status').textContent = connectionStateString;
763 766
764 var typeKey; 767 var typeKey;
765 var type = this.type_; 768 var type = this.type_;
766 if (type == 'Ethernet') 769 if (type == 'Ethernet')
767 typeKey = 'ethernetTitle'; 770 typeKey = 'ethernetTitle';
768 else if (type == 'WiFi') 771 else if (type == 'WiFi')
769 typeKey = 'wifiTitle'; 772 typeKey = 'wifiTitle';
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 var priority = preferredCheckbox.checked ? kPreferredPriority : 0; 1181 var priority = preferredCheckbox.checked ? kPreferredPriority : 0;
1179 oncData.setProperty('Priority', priority); 1182 oncData.setProperty('Priority', priority);
1180 sendChromeMetricsAction('Options_NetworkSetPrefer'); 1183 sendChromeMetricsAction('Options_NetworkSetPrefer');
1181 } 1184 }
1182 autoConnectCheckboxId = 'auto-connect-network-wifi'; 1185 autoConnectCheckboxId = 'auto-connect-network-wifi';
1183 } else if (type == 'WiMAX') { 1186 } else if (type == 'WiMAX') {
1184 autoConnectCheckboxId = 'auto-connect-network-wimax'; 1187 autoConnectCheckboxId = 'auto-connect-network-wimax';
1185 } else if (type == 'Cellular') { 1188 } else if (type == 'Cellular') {
1186 autoConnectCheckboxId = 'auto-connect-network-cellular'; 1189 autoConnectCheckboxId = 'auto-connect-network-cellular';
1187 } else if (type == 'VPN') { 1190 } else if (type == 'VPN') {
1188 oncData.setProperty('VPN.Host', $('inet-server-hostname').value); 1191 var providerType = detailsPage.onc_.getActiveValue('VPN.Type');
1192 if (providerType != 'ThirdPartyVPN') {
1193 oncData.setProperty('VPN.Type', providerType);
1194 oncData.setProperty('VPN.Host', $('inet-server-hostname').value);
1195 }
1189 autoConnectCheckboxId = 'auto-connect-network-vpn'; 1196 autoConnectCheckboxId = 'auto-connect-network-vpn';
1190 } 1197 }
1191 if (autoConnectCheckboxId != '') { 1198 if (autoConnectCheckboxId != '') {
1192 var autoConnectCheckbox = 1199 var autoConnectCheckbox =
1193 assertInstanceof($(autoConnectCheckboxId), HTMLInputElement); 1200 assertInstanceof($(autoConnectCheckboxId), HTMLInputElement);
1194 if (!autoConnectCheckbox.hidden && !autoConnectCheckbox.disabled) { 1201 if (!autoConnectCheckbox.hidden && !autoConnectCheckbox.disabled) {
1195 var autoConnectKey = type + '.AutoConnect'; 1202 var autoConnectKey = type + '.AutoConnect';
1196 oncData.setProperty(autoConnectKey, !!autoConnectCheckbox.checked); 1203 oncData.setProperty(autoConnectKey, !!autoConnectCheckbox.checked);
1197 sendChromeMetricsAction('Options_NetworkAutoConnect'); 1204 sendChromeMetricsAction('Options_NetworkAutoConnect');
1198 } 1205 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 DetailsInternetPage.initializeDetailsPage = function(oncData) { 1305 DetailsInternetPage.initializeDetailsPage = function(oncData) {
1299 var onc = new OncData(oncData); 1306 var onc = new OncData(oncData);
1300 1307
1301 var detailsPage = DetailsInternetPage.getInstance(); 1308 var detailsPage = DetailsInternetPage.getInstance();
1302 detailsPage.onc_ = onc; 1309 detailsPage.onc_ = onc;
1303 var type = onc.getActiveValue('Type'); 1310 var type = onc.getActiveValue('Type');
1304 detailsPage.type_ = type; 1311 detailsPage.type_ = type;
1305 1312
1306 sendShowDetailsMetrics(type, onc.getActiveValue('ConnectionState')); 1313 sendShowDetailsMetrics(type, onc.getActiveValue('ConnectionState'));
1307 1314
1315 if (type == 'VPN') {
1316 // Cache the dialog title, which will contain the provider name in the
1317 // case of a third-party VPN provider. This caching is important as the
1318 // provider may go away while the details dialog is being shown, causing
1319 // subsequent updates to be unable to determine the correct title.
1320 detailsPage.networkTitle_ = options.VPNProviders.formatNetworkName(onc);
1321 } else {
1322 detailsPage.networkTitle_ = undefined;
pneubeck (no reviews) 2015/03/18 20:41:30 I think it's more idiomatic to do delete detailsP
bartfab (slow) 2015/03/18 21:10:48 Done.
1323 }
1324
1308 detailsPage.populateHeader_(); 1325 detailsPage.populateHeader_();
1309 detailsPage.updateConnectionButtonVisibilty_(); 1326 detailsPage.updateConnectionButtonVisibilty_();
1310 detailsPage.updateDetails_(); 1327 detailsPage.updateDetails_();
1311 1328
1312 // Inform chrome which network to pass events for in InternetOptionsHandler. 1329 // Inform chrome which network to pass events for in InternetOptionsHandler.
1313 chrome.send('setNetworkGuid', [detailsPage.onc_.guid()]); 1330 chrome.send('setNetworkGuid', [detailsPage.onc_.guid()]);
1314 1331
1315 // TODO(stevenjb): Some of the setup below should be moved to 1332 // TODO(stevenjb): Some of the setup below should be moved to
1316 // updateDetails_() so that updates are reflected in the UI. 1333 // updateDetails_() so that updates are reflected in the UI.
1317 1334
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 if (isGsm) { 1646 if (isGsm) {
1630 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); 1647 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID');
1631 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); 1648 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI');
1632 detailsPage.initializeApnList_(); 1649 detailsPage.initializeApnList_();
1633 } 1650 }
1634 $('auto-connect-network-cellular').checked = 1651 $('auto-connect-network-cellular').checked =
1635 onc.getActiveValue('Cellular.AutoConnect'); 1652 onc.getActiveValue('Cellular.AutoConnect');
1636 $('auto-connect-network-cellular').disabled = false; 1653 $('auto-connect-network-cellular').disabled = false;
1637 } else if (type == 'VPN') { 1654 } else if (type == 'VPN') {
1638 OptionsPage.showTab($('vpn-nav-tab')); 1655 OptionsPage.showTab($('vpn-nav-tab'));
1656 var providerType = onc.getActiveValue('VPN.Type');
1657 var thirdPartyVPN = providerType == 'ThirdPartyVPN';
pneubeck (no reviews) 2015/03/18 20:41:30 nit: rename to isThirdPartyVPN
bartfab (slow) 2015/03/18 21:10:48 Done.
1658 $('vpn-tab').classList.toggle('third-party-vpn-provider', thirdPartyVPN);
1659
1639 $('inet-service-name').textContent = networkName; 1660 $('inet-service-name').textContent = networkName;
1640 $('inet-provider-type').textContent = 1661 $('inet-provider-type').textContent =
1641 onc.getTranslatedValue('VPN.Type'); 1662 onc.getTranslatedValue('VPN.Type');
1642 var providerType = onc.getActiveValue('VPN.Type');
1643 var usernameKey;
1644 if (providerType == 'OpenVPN')
1645 usernameKey = 'VPN.OpenVPN.Username';
1646 else if (providerType == 'L2TP-IPsec')
1647 usernameKey = 'VPN.L2TP.Username';
1648 1663
1649 if (usernameKey) { 1664 if (thirdPartyVPN) {
1650 $('inet-username').parentElement.hidden = false; 1665 $('inet-provider-name').textContent = '';
1651 $('inet-username').textContent = onc.getActiveValue(usernameKey); 1666 var extensionID = onc.getActiveValue('VPN.ThirdPartyVPN.ExtensionID');
1667 var providers = options.VPNProviders.getProviders();
1668 for (var i = 0; i < providers.length; ++i) {
pneubeck (no reviews) 2015/03/18 20:41:30 if this is the only use of getProviders(), then yo
bartfab (slow) 2015/03/18 21:10:48 CL 1017443002 will add another use which needs to
1669 if (extensionID == providers[i].extensionID) {
1670 $('inet-provider-name').textContent = providers[i].name;
1671 break;
1672 }
1673 }
1652 } else { 1674 } else {
1653 $('inet-username').parentElement.hidden = true; 1675 var usernameKey;
1676 if (providerType == 'OpenVPN')
1677 usernameKey = 'VPN.OpenVPN.Username';
1678 else if (providerType == 'L2TP-IPsec')
1679 usernameKey = 'VPN.L2TP.Username';
1680
1681 if (usernameKey) {
1682 $('inet-username').parentElement.hidden = false;
1683 $('inet-username').textContent = onc.getActiveValue(usernameKey);
1684 } else {
1685 $('inet-username').parentElement.hidden = true;
1686 }
1687 var inetServerHostname = $('inet-server-hostname');
1688 inetServerHostname.value = onc.getActiveValue('VPN.Host');
1689 inetServerHostname.resetHandler = function() {
1690 PageManager.hideBubble();
1691 var recommended = onc.getRecommendedValue('VPN.Host');
1692 if (recommended != undefined)
1693 inetServerHostname.value = recommended;
1694 };
1695 $('auto-connect-network-vpn').checked =
1696 onc.getActiveValue('VPN.AutoConnect');
1697 $('auto-connect-network-vpn').disabled = false;
1654 } 1698 }
1655 var inetServerHostname = $('inet-server-hostname');
1656 inetServerHostname.value = onc.getActiveValue('VPN.Host');
1657 inetServerHostname.resetHandler = function() {
1658 PageManager.hideBubble();
1659 var recommended = onc.getRecommendedValue('VPN.Host');
1660 if (recommended != undefined)
1661 inetServerHostname.value = recommended;
1662 };
1663 $('auto-connect-network-vpn').checked =
1664 onc.getActiveValue('VPN.AutoConnect');
1665 $('auto-connect-network-vpn').disabled = false;
1666 } else { 1699 } else {
1667 OptionsPage.showTab($('internet-nav-tab')); 1700 OptionsPage.showTab($('internet-nav-tab'));
1668 } 1701 }
1669 1702
1670 // Update controlled option indicators. 1703 // Update controlled option indicators.
1671 var indicators = cr.doc.querySelectorAll( 1704 var indicators = cr.doc.querySelectorAll(
1672 '#details-internet-page .controlled-setting-indicator'); 1705 '#details-internet-page .controlled-setting-indicator');
1673 for (var i = 0; i < indicators.length; i++) { 1706 for (var i = 0; i < indicators.length; i++) {
1674 var managed = indicators[i].hasAttribute('managed'); 1707 var managed = indicators[i].hasAttribute('managed');
1675 // TODO(stevenjb): Eliminate support for 'data' once 39 is stable. 1708 // TODO(stevenjb): Eliminate support for 'data' once 39 is stable.
(...skipping 28 matching lines...) Expand all
1704 1737
1705 // Don't show page name in address bar and in history to prevent people 1738 // Don't show page name in address bar and in history to prevent people
1706 // navigate here by hand and solve issue with page session restore. 1739 // navigate here by hand and solve issue with page session restore.
1707 PageManager.showPageByName('detailsInternetPage', false); 1740 PageManager.showPageByName('detailsInternetPage', false);
1708 }; 1741 };
1709 1742
1710 return { 1743 return {
1711 DetailsInternetPage: DetailsInternetPage 1744 DetailsInternetPage: DetailsInternetPage
1712 }; 1745 };
1713 }); 1746 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698