| 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, |
| 121 'detailsInternetPage', | 122 'detailsInternetPage', |
| 122 null, | 123 null, |
| 123 'details-internet-page'); | 124 'details-internet-page'); |
| 124 } | 125 } |
| 125 | 126 |
| 126 cr.addSingletonGetter(DetailsInternetPage); | 127 cr.addSingletonGetter(DetailsInternetPage); |
| 127 | 128 |
| 128 DetailsInternetPage.prototype = { | 129 DetailsInternetPage.prototype = { |
| 129 __proto__: OptionsPage.prototype, | 130 __proto__: Page.prototype, |
| 130 | 131 |
| 131 /** | 132 /** |
| 132 * Initializes DetailsInternetPage page. | 133 * Initializes DetailsInternetPage page. |
| 133 * Calls base class implementation to starts preference initialization. | |
| 134 */ | 134 */ |
| 135 initializePage: function() { | 135 initializePage: function() { |
| 136 OptionsPage.prototype.initializePage.call(this); | 136 Page.prototype.initializePage.call(this); |
| 137 var params = parseQueryParams(window.location); | 137 var params = parseQueryParams(window.location); |
| 138 this.initializePageContents_(params); | 138 this.initializePageContents_(params); |
| 139 this.showNetworkDetails_(params); | 139 this.showNetworkDetails_(params); |
| 140 }, | 140 }, |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * Auto-activates the network details dialog if network information | 143 * Auto-activates the network details dialog if network information |
| 144 * is included in the URL. | 144 * is included in the URL. |
| 145 */ | 145 */ |
| 146 showNetworkDetails_: function(params) { | 146 showNetworkDetails_: function(params) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 177 DetailsInternetPage.configureNetwork(); | 177 DetailsInternetPage.configureNetwork(); |
| 178 }); | 178 }); |
| 179 | 179 |
| 180 $('activate-details').addEventListener('click', function(event) { | 180 $('activate-details').addEventListener('click', function(event) { |
| 181 DetailsInternetPage.activateFromDetails(); | 181 DetailsInternetPage.activateFromDetails(); |
| 182 }); | 182 }); |
| 183 | 183 |
| 184 $('buyplan-details').addEventListener('click', function(event) { | 184 $('buyplan-details').addEventListener('click', function(event) { |
| 185 var data = $('connection-state').data; | 185 var data = $('connection-state').data; |
| 186 chrome.send('buyDataPlan', [data.servicePath]); | 186 chrome.send('buyDataPlan', [data.servicePath]); |
| 187 OptionsPage.closeOverlay(); | 187 PageManager.closeOverlay(); |
| 188 }); | 188 }); |
| 189 | 189 |
| 190 $('view-account-details').addEventListener('click', function(event) { | 190 $('view-account-details').addEventListener('click', function(event) { |
| 191 var data = $('connection-state').data; | 191 var data = $('connection-state').data; |
| 192 chrome.send('showMorePlanInfo', [data.servicePath]); | 192 chrome.send('showMorePlanInfo', [data.servicePath]); |
| 193 OptionsPage.closeOverlay(); | 193 PageManager.closeOverlay(); |
| 194 }); | 194 }); |
| 195 | 195 |
| 196 $('cellular-apn-use-default').addEventListener('click', function(event) { | 196 $('cellular-apn-use-default').addEventListener('click', function(event) { |
| 197 var data = $('connection-state').data; | 197 var data = $('connection-state').data; |
| 198 var apnSelector = $('select-apn'); | 198 var apnSelector = $('select-apn'); |
| 199 | 199 |
| 200 if (data.userApnIndex != -1) { | 200 if (data.userApnIndex != -1) { |
| 201 apnSelector.remove(data.userApnIndex); | 201 apnSelector.remove(data.userApnIndex); |
| 202 data.userApnIndex = -1; | 202 data.userApnIndex = -1; |
| 203 } | 203 } |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 }; | 706 }; |
| 707 | 707 |
| 708 DetailsInternetPage.updateCarrier = function() { | 708 DetailsInternetPage.updateCarrier = function() { |
| 709 DetailsInternetPage.showCarrierChangeSpinner(false); | 709 DetailsInternetPage.showCarrierChangeSpinner(false); |
| 710 }; | 710 }; |
| 711 | 711 |
| 712 DetailsInternetPage.loginFromDetails = function() { | 712 DetailsInternetPage.loginFromDetails = function() { |
| 713 var data = $('connection-state').data; | 713 var data = $('connection-state').data; |
| 714 var servicePath = data.servicePath; | 714 var servicePath = data.servicePath; |
| 715 chrome.send('networkCommand', [data.Type, servicePath, 'connect']); | 715 chrome.send('networkCommand', [data.Type, servicePath, 'connect']); |
| 716 OptionsPage.closeOverlay(); | 716 PageManager.closeOverlay(); |
| 717 }; | 717 }; |
| 718 | 718 |
| 719 DetailsInternetPage.disconnectNetwork = function() { | 719 DetailsInternetPage.disconnectNetwork = function() { |
| 720 var data = $('connection-state').data; | 720 var data = $('connection-state').data; |
| 721 var servicePath = data.servicePath; | 721 var servicePath = data.servicePath; |
| 722 chrome.send('networkCommand', [data.Type, servicePath, 'disconnect']); | 722 chrome.send('networkCommand', [data.Type, servicePath, 'disconnect']); |
| 723 OptionsPage.closeOverlay(); | 723 PageManager.closeOverlay(); |
| 724 }; | 724 }; |
| 725 | 725 |
| 726 DetailsInternetPage.configureNetwork = function() { | 726 DetailsInternetPage.configureNetwork = function() { |
| 727 var data = $('connection-state').data; | 727 var data = $('connection-state').data; |
| 728 var servicePath = data.servicePath; | 728 var servicePath = data.servicePath; |
| 729 chrome.send('networkCommand', [data.Type, servicePath, 'configure']); | 729 chrome.send('networkCommand', [data.Type, servicePath, 'configure']); |
| 730 OptionsPage.closeOverlay(); | 730 PageManager.closeOverlay(); |
| 731 }; | 731 }; |
| 732 | 732 |
| 733 DetailsInternetPage.activateFromDetails = function() { | 733 DetailsInternetPage.activateFromDetails = function() { |
| 734 var data = $('connection-state').data; | 734 var data = $('connection-state').data; |
| 735 var servicePath = data.servicePath; | 735 var servicePath = data.servicePath; |
| 736 if (data.Type == 'Cellular') | 736 if (data.Type == 'Cellular') |
| 737 chrome.send('networkCommand', [data.Type, servicePath, 'activate']); | 737 chrome.send('networkCommand', [data.Type, servicePath, 'activate']); |
| 738 OptionsPage.closeOverlay(); | 738 PageManager.closeOverlay(); |
| 739 }; | 739 }; |
| 740 | 740 |
| 741 DetailsInternetPage.setDetails = function() { | 741 DetailsInternetPage.setDetails = function() { |
| 742 var data = $('connection-state').data; | 742 var data = $('connection-state').data; |
| 743 var servicePath = data.servicePath; | 743 var servicePath = data.servicePath; |
| 744 if (data.Type == 'WiFi') { | 744 if (data.Type == 'WiFi') { |
| 745 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', | 745 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', |
| 746 $('prefer-network-wifi')); | 746 $('prefer-network-wifi')); |
| 747 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 747 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
| 748 $('auto-connect-network-wifi')); | 748 $('auto-connect-network-wifi')); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 userNameServers = userNameServers.join(','); | 782 userNameServers = userNameServers.join(','); |
| 783 | 783 |
| 784 chrome.send('setIPConfig', | 784 chrome.send('setIPConfig', |
| 785 [servicePath, | 785 [servicePath, |
| 786 Boolean($('ip-automatic-configuration-checkbox').checked), | 786 Boolean($('ip-automatic-configuration-checkbox').checked), |
| 787 $('ip-address').model.value || '', | 787 $('ip-address').model.value || '', |
| 788 $('ip-netmask').model.value || '', | 788 $('ip-netmask').model.value || '', |
| 789 $('ip-gateway').model.value || '', | 789 $('ip-gateway').model.value || '', |
| 790 nameServerType, | 790 nameServerType, |
| 791 userNameServers]); | 791 userNameServers]); |
| 792 OptionsPage.closeOverlay(); | 792 PageManager.closeOverlay(); |
| 793 }; | 793 }; |
| 794 | 794 |
| 795 DetailsInternetPage.updateNameServerDisplay = function(type) { | 795 DetailsInternetPage.updateNameServerDisplay = function(type) { |
| 796 var editable = type == 'user'; | 796 var editable = type == 'user'; |
| 797 var fields = [$('ipconfig-dns1'), $('ipconfig-dns2'), | 797 var fields = [$('ipconfig-dns1'), $('ipconfig-dns2'), |
| 798 $('ipconfig-dns3'), $('ipconfig-dns4')]; | 798 $('ipconfig-dns3'), $('ipconfig-dns4')]; |
| 799 for (var i = 0; i < fields.length; ++i) { | 799 for (var i = 0; i < fields.length; ++i) { |
| 800 fields[i].editable = editable; | 800 fields[i].editable = editable; |
| 801 } | 801 } |
| 802 if (editable) | 802 if (editable) |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 detailsPage.vpn = true; | 1252 detailsPage.vpn = true; |
| 1253 detailsPage.ethernet = false; | 1253 detailsPage.ethernet = false; |
| 1254 detailsPage.cellular = false; | 1254 detailsPage.cellular = false; |
| 1255 detailsPage.gsm = false; | 1255 detailsPage.gsm = false; |
| 1256 $('inet-service-name').textContent = getNetworkName(data); | 1256 $('inet-service-name').textContent = getNetworkName(data); |
| 1257 $('inet-provider-type').textContent = data.providerType; | 1257 $('inet-provider-type').textContent = data.providerType; |
| 1258 $('inet-username').textContent = data.username; | 1258 $('inet-username').textContent = data.username; |
| 1259 var inetServerHostname = $('inet-server-hostname'); | 1259 var inetServerHostname = $('inet-server-hostname'); |
| 1260 inetServerHostname.value = data.serverHostname.value; | 1260 inetServerHostname.value = data.serverHostname.value; |
| 1261 inetServerHostname.resetHandler = function() { | 1261 inetServerHostname.resetHandler = function() { |
| 1262 OptionsPage.hideBubble(); | 1262 PageManager.hideBubble(); |
| 1263 inetServerHostname.value = data.serverHostname.recommendedValue; | 1263 inetServerHostname.value = data.serverHostname.recommendedValue; |
| 1264 }; | 1264 }; |
| 1265 $('auto-connect-network-vpn').checked = data.autoConnect.value; | 1265 $('auto-connect-network-vpn').checked = data.autoConnect.value; |
| 1266 $('auto-connect-network-vpn').disabled = false; | 1266 $('auto-connect-network-vpn').disabled = false; |
| 1267 } else { | 1267 } else { |
| 1268 OptionsPage.showTab($('internet-nav-tab')); | 1268 OptionsPage.showTab($('internet-nav-tab')); |
| 1269 detailsPage.ethernet = true; | 1269 detailsPage.ethernet = true; |
| 1270 detailsPage.wireless = false; | 1270 detailsPage.wireless = false; |
| 1271 detailsPage.wimax = false; | 1271 detailsPage.wimax = false; |
| 1272 detailsPage.vpn = false; | 1272 detailsPage.vpn = false; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1297 forElement.disabled = true; | 1297 forElement.disabled = true; |
| 1298 if (forElement.resetHandler) | 1298 if (forElement.resetHandler) |
| 1299 indicators[i].resetHandler = forElement.resetHandler; | 1299 indicators[i].resetHandler = forElement.resetHandler; |
| 1300 } | 1300 } |
| 1301 } | 1301 } |
| 1302 | 1302 |
| 1303 detailsPage.updateControls(); | 1303 detailsPage.updateControls(); |
| 1304 | 1304 |
| 1305 // Don't show page name in address bar and in history to prevent people | 1305 // Don't show page name in address bar and in history to prevent people |
| 1306 // navigate here by hand and solve issue with page session restore. | 1306 // navigate here by hand and solve issue with page session restore. |
| 1307 OptionsPage.showPageByName('detailsInternetPage', false); | 1307 PageManager.showPageByName('detailsInternetPage', false); |
| 1308 }; | 1308 }; |
| 1309 | 1309 |
| 1310 return { | 1310 return { |
| 1311 DetailsInternetPage: DetailsInternetPage | 1311 DetailsInternetPage: DetailsInternetPage |
| 1312 }; | 1312 }; |
| 1313 }); | 1313 }); |
| OLD | NEW |