| 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 OptionsPage = options.OptionsPage; | 13 var Page = cr.ui.pageManager.Page; |
| 14 var PageManager = cr.ui.pageManager.PageManager; |
| 14 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 15 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 15 /** @const */ var IPAddressField = options.internet.IPAddressField; | 16 /** @const */ var IPAddressField = options.internet.IPAddressField; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 /* | 19 /* |
| 19 * Helper function to set hidden attribute for elements matching a selector. | 20 * Helper function to set hidden attribute for elements matching a selector. |
| 20 * @param {string} selector CSS selector for extracting a list of elements. | 21 * @param {string} selector CSS selector for extracting a list of elements. |
| 21 * @param {bool} hidden New hidden value. | 22 * @param {bool} hidden New hidden value. |
| 22 */ | 23 */ |
| 23 function updateHidden(selector, hidden) { | 24 function updateHidden(selector, hidden) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 111 } |
| 111 | 112 |
| 112 ///////////////////////////////////////////////////////////////////////////// | 113 ///////////////////////////////////////////////////////////////////////////// |
| 113 // DetailsInternetPage class: | 114 // DetailsInternetPage class: |
| 114 | 115 |
| 115 /** | 116 /** |
| 116 * Encapsulated handling of ChromeOS internet details overlay page. | 117 * Encapsulated handling of ChromeOS internet details overlay page. |
| 117 * @constructor | 118 * @constructor |
| 118 */ | 119 */ |
| 119 function DetailsInternetPage() { | 120 function DetailsInternetPage() { |
| 120 OptionsPage.call(this, | 121 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); |
| 121 'detailsInternetPage', | |
| 122 null, | |
| 123 'details-internet-page'); | |
| 124 } | 122 } |
| 125 | 123 |
| 126 cr.addSingletonGetter(DetailsInternetPage); | 124 cr.addSingletonGetter(DetailsInternetPage); |
| 127 | 125 |
| 128 DetailsInternetPage.prototype = { | 126 DetailsInternetPage.prototype = { |
| 129 __proto__: OptionsPage.prototype, | 127 __proto__: Page.prototype, |
| 130 | 128 |
| 131 /** @override */ | 129 /** @override */ |
| 132 initializePage: function() { | 130 initializePage: function() { |
| 133 OptionsPage.prototype.initializePage.call(this); | 131 Page.prototype.initializePage.call(this); |
| 134 var params = parseQueryParams(window.location); | 132 var params = parseQueryParams(window.location); |
| 135 this.initializePageContents_(params); | 133 this.initializePageContents_(params); |
| 136 this.showNetworkDetails_(params); | 134 this.showNetworkDetails_(params); |
| 137 }, | 135 }, |
| 138 | 136 |
| 139 /** | 137 /** |
| 140 * Auto-activates the network details dialog if network information | 138 * Auto-activates the network details dialog if network information |
| 141 * is included in the URL. | 139 * is included in the URL. |
| 142 */ | 140 */ |
| 143 showNetworkDetails_: function(params) { | 141 showNetworkDetails_: function(params) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 174 DetailsInternetPage.configureNetwork(); | 172 DetailsInternetPage.configureNetwork(); |
| 175 }); | 173 }); |
| 176 | 174 |
| 177 $('activate-details').addEventListener('click', function(event) { | 175 $('activate-details').addEventListener('click', function(event) { |
| 178 DetailsInternetPage.activateFromDetails(); | 176 DetailsInternetPage.activateFromDetails(); |
| 179 }); | 177 }); |
| 180 | 178 |
| 181 $('buyplan-details').addEventListener('click', function(event) { | 179 $('buyplan-details').addEventListener('click', function(event) { |
| 182 var data = $('connection-state').data; | 180 var data = $('connection-state').data; |
| 183 chrome.send('buyDataPlan', [data.servicePath]); | 181 chrome.send('buyDataPlan', [data.servicePath]); |
| 184 OptionsPage.closeOverlay(); | 182 PageManager.closeOverlay(); |
| 185 }); | 183 }); |
| 186 | 184 |
| 187 $('view-account-details').addEventListener('click', function(event) { | 185 $('view-account-details').addEventListener('click', function(event) { |
| 188 var data = $('connection-state').data; | 186 var data = $('connection-state').data; |
| 189 chrome.send('showMorePlanInfo', [data.servicePath]); | 187 chrome.send('showMorePlanInfo', [data.servicePath]); |
| 190 OptionsPage.closeOverlay(); | 188 PageManager.closeOverlay(); |
| 191 }); | 189 }); |
| 192 | 190 |
| 193 $('cellular-apn-use-default').addEventListener('click', function(event) { | 191 $('cellular-apn-use-default').addEventListener('click', function(event) { |
| 194 var data = $('connection-state').data; | 192 var data = $('connection-state').data; |
| 195 var apnSelector = $('select-apn'); | 193 var apnSelector = $('select-apn'); |
| 196 | 194 |
| 197 if (data.userApnIndex != -1) { | 195 if (data.userApnIndex != -1) { |
| 198 apnSelector.remove(data.userApnIndex); | 196 apnSelector.remove(data.userApnIndex); |
| 199 data.userApnIndex = -1; | 197 data.userApnIndex = -1; |
| 200 } | 198 } |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 }; | 701 }; |
| 704 | 702 |
| 705 DetailsInternetPage.updateCarrier = function() { | 703 DetailsInternetPage.updateCarrier = function() { |
| 706 DetailsInternetPage.showCarrierChangeSpinner(false); | 704 DetailsInternetPage.showCarrierChangeSpinner(false); |
| 707 }; | 705 }; |
| 708 | 706 |
| 709 DetailsInternetPage.loginFromDetails = function() { | 707 DetailsInternetPage.loginFromDetails = function() { |
| 710 var data = $('connection-state').data; | 708 var data = $('connection-state').data; |
| 711 var servicePath = data.servicePath; | 709 var servicePath = data.servicePath; |
| 712 chrome.send('networkCommand', [data.Type, servicePath, 'connect']); | 710 chrome.send('networkCommand', [data.Type, servicePath, 'connect']); |
| 713 OptionsPage.closeOverlay(); | 711 PageManager.closeOverlay(); |
| 714 }; | 712 }; |
| 715 | 713 |
| 716 DetailsInternetPage.disconnectNetwork = function() { | 714 DetailsInternetPage.disconnectNetwork = function() { |
| 717 var data = $('connection-state').data; | 715 var data = $('connection-state').data; |
| 718 var servicePath = data.servicePath; | 716 var servicePath = data.servicePath; |
| 719 chrome.send('networkCommand', [data.Type, servicePath, 'disconnect']); | 717 chrome.send('networkCommand', [data.Type, servicePath, 'disconnect']); |
| 720 OptionsPage.closeOverlay(); | 718 PageManager.closeOverlay(); |
| 721 }; | 719 }; |
| 722 | 720 |
| 723 DetailsInternetPage.configureNetwork = function() { | 721 DetailsInternetPage.configureNetwork = function() { |
| 724 var data = $('connection-state').data; | 722 var data = $('connection-state').data; |
| 725 var servicePath = data.servicePath; | 723 var servicePath = data.servicePath; |
| 726 chrome.send('networkCommand', [data.Type, servicePath, 'configure']); | 724 chrome.send('networkCommand', [data.Type, servicePath, 'configure']); |
| 727 OptionsPage.closeOverlay(); | 725 PageManager.closeOverlay(); |
| 728 }; | 726 }; |
| 729 | 727 |
| 730 DetailsInternetPage.activateFromDetails = function() { | 728 DetailsInternetPage.activateFromDetails = function() { |
| 731 var data = $('connection-state').data; | 729 var data = $('connection-state').data; |
| 732 var servicePath = data.servicePath; | 730 var servicePath = data.servicePath; |
| 733 if (data.Type == 'Cellular') | 731 if (data.Type == 'Cellular') |
| 734 chrome.send('networkCommand', [data.Type, servicePath, 'activate']); | 732 chrome.send('networkCommand', [data.Type, servicePath, 'activate']); |
| 735 OptionsPage.closeOverlay(); | 733 PageManager.closeOverlay(); |
| 736 }; | 734 }; |
| 737 | 735 |
| 738 DetailsInternetPage.setDetails = function() { | 736 DetailsInternetPage.setDetails = function() { |
| 739 var data = $('connection-state').data; | 737 var data = $('connection-state').data; |
| 740 var servicePath = data.servicePath; | 738 var servicePath = data.servicePath; |
| 741 if (data.Type == 'WiFi') { | 739 if (data.Type == 'WiFi') { |
| 742 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', | 740 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', |
| 743 $('prefer-network-wifi')); | 741 $('prefer-network-wifi')); |
| 744 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 742 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
| 745 $('auto-connect-network-wifi')); | 743 $('auto-connect-network-wifi')); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 userNameServers = userNameServers.join(','); | 777 userNameServers = userNameServers.join(','); |
| 780 | 778 |
| 781 chrome.send('setIPConfig', | 779 chrome.send('setIPConfig', |
| 782 [servicePath, | 780 [servicePath, |
| 783 Boolean($('ip-automatic-configuration-checkbox').checked), | 781 Boolean($('ip-automatic-configuration-checkbox').checked), |
| 784 $('ip-address').model.value || '', | 782 $('ip-address').model.value || '', |
| 785 $('ip-netmask').model.value || '', | 783 $('ip-netmask').model.value || '', |
| 786 $('ip-gateway').model.value || '', | 784 $('ip-gateway').model.value || '', |
| 787 nameServerType, | 785 nameServerType, |
| 788 userNameServers]); | 786 userNameServers]); |
| 789 OptionsPage.closeOverlay(); | 787 PageManager.closeOverlay(); |
| 790 }; | 788 }; |
| 791 | 789 |
| 792 DetailsInternetPage.updateNameServerDisplay = function(type) { | 790 DetailsInternetPage.updateNameServerDisplay = function(type) { |
| 793 var editable = type == 'user'; | 791 var editable = type == 'user'; |
| 794 var fields = [$('ipconfig-dns1'), $('ipconfig-dns2'), | 792 var fields = [$('ipconfig-dns1'), $('ipconfig-dns2'), |
| 795 $('ipconfig-dns3'), $('ipconfig-dns4')]; | 793 $('ipconfig-dns3'), $('ipconfig-dns4')]; |
| 796 for (var i = 0; i < fields.length; ++i) { | 794 for (var i = 0; i < fields.length; ++i) { |
| 797 fields[i].editable = editable; | 795 fields[i].editable = editable; |
| 798 } | 796 } |
| 799 if (editable) | 797 if (editable) |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 detailsPage.vpn = true; | 1247 detailsPage.vpn = true; |
| 1250 detailsPage.ethernet = false; | 1248 detailsPage.ethernet = false; |
| 1251 detailsPage.cellular = false; | 1249 detailsPage.cellular = false; |
| 1252 detailsPage.gsm = false; | 1250 detailsPage.gsm = false; |
| 1253 $('inet-service-name').textContent = getNetworkName(data); | 1251 $('inet-service-name').textContent = getNetworkName(data); |
| 1254 $('inet-provider-type').textContent = data.providerType; | 1252 $('inet-provider-type').textContent = data.providerType; |
| 1255 $('inet-username').textContent = data.username; | 1253 $('inet-username').textContent = data.username; |
| 1256 var inetServerHostname = $('inet-server-hostname'); | 1254 var inetServerHostname = $('inet-server-hostname'); |
| 1257 inetServerHostname.value = data.serverHostname.value; | 1255 inetServerHostname.value = data.serverHostname.value; |
| 1258 inetServerHostname.resetHandler = function() { | 1256 inetServerHostname.resetHandler = function() { |
| 1259 OptionsPage.hideBubble(); | 1257 PageManager.hideBubble(); |
| 1260 inetServerHostname.value = data.serverHostname.recommendedValue; | 1258 inetServerHostname.value = data.serverHostname.recommendedValue; |
| 1261 }; | 1259 }; |
| 1262 $('auto-connect-network-vpn').checked = data.autoConnect.value; | 1260 $('auto-connect-network-vpn').checked = data.autoConnect.value; |
| 1263 $('auto-connect-network-vpn').disabled = false; | 1261 $('auto-connect-network-vpn').disabled = false; |
| 1264 } else { | 1262 } else { |
| 1265 OptionsPage.showTab($('internet-nav-tab')); | 1263 OptionsPage.showTab($('internet-nav-tab')); |
| 1266 detailsPage.ethernet = true; | 1264 detailsPage.ethernet = true; |
| 1267 detailsPage.wireless = false; | 1265 detailsPage.wireless = false; |
| 1268 detailsPage.wimax = false; | 1266 detailsPage.wimax = false; |
| 1269 detailsPage.vpn = false; | 1267 detailsPage.vpn = false; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1294 forElement.disabled = true; | 1292 forElement.disabled = true; |
| 1295 if (forElement.resetHandler) | 1293 if (forElement.resetHandler) |
| 1296 indicators[i].resetHandler = forElement.resetHandler; | 1294 indicators[i].resetHandler = forElement.resetHandler; |
| 1297 } | 1295 } |
| 1298 } | 1296 } |
| 1299 | 1297 |
| 1300 detailsPage.updateControls(); | 1298 detailsPage.updateControls(); |
| 1301 | 1299 |
| 1302 // Don't show page name in address bar and in history to prevent people | 1300 // Don't show page name in address bar and in history to prevent people |
| 1303 // navigate here by hand and solve issue with page session restore. | 1301 // navigate here by hand and solve issue with page session restore. |
| 1304 OptionsPage.showPageByName('detailsInternetPage', false); | 1302 PageManager.showPageByName('detailsInternetPage', false); |
| 1305 }; | 1303 }; |
| 1306 | 1304 |
| 1307 return { | 1305 return { |
| 1308 DetailsInternetPage: DetailsInternetPage | 1306 DetailsInternetPage: DetailsInternetPage |
| 1309 }; | 1307 }; |
| 1310 }); | 1308 }); |
| OLD | NEW |