| 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 // 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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 if (hostValue.indexOf(':') !== -1) { | 1182 if (hostValue.indexOf(':') !== -1) { |
| 1183 if (hostValue.match(/:/g).length == 1) { | 1183 if (hostValue.match(/:/g).length == 1) { |
| 1184 hostValue = hostValue.split(':'); | 1184 hostValue = hostValue.split(':'); |
| 1185 $(proxyHost).value = hostValue[0]; | 1185 $(proxyHost).value = hostValue[0]; |
| 1186 $(proxyPort).value = hostValue[1]; | 1186 $(proxyPort).value = hostValue[1]; |
| 1187 } | 1187 } |
| 1188 } | 1188 } |
| 1189 }; | 1189 }; |
| 1190 | 1190 |
| 1191 DetailsInternetPage.loginFromDetails = function() { | 1191 DetailsInternetPage.loginFromDetails = function() { |
| 1192 DetailsInternetPage.configureOrConnect(); |
| 1193 PageManager.closeOverlay(); |
| 1194 }; |
| 1195 |
| 1196 /** |
| 1197 * This function identifies unconfigured networks and networks that are |
| 1198 * likely to fail (e.g. due to a bad passphrase on a previous connect |
| 1199 * attempt). For such networks a configure dialog will be opened. Otherwise |
| 1200 * a connection will be attempted. |
| 1201 */ |
| 1202 DetailsInternetPage.configureOrConnect = function() { |
| 1192 var detailsPage = DetailsInternetPage.getInstance(); | 1203 var detailsPage = DetailsInternetPage.getInstance(); |
| 1193 if (detailsPage.type_ == 'WiFi') | 1204 if (detailsPage.type_ == 'WiFi') |
| 1194 sendChromeMetricsAction('Options_NetworkConnectToWifi'); | 1205 sendChromeMetricsAction('Options_NetworkConnectToWifi'); |
| 1195 else if (detailsPage.type_ == 'VPN') | 1206 else if (detailsPage.type_ == 'VPN') |
| 1196 sendChromeMetricsAction('Options_NetworkConnectToVPN'); | 1207 sendChromeMetricsAction('Options_NetworkConnectToVPN'); |
| 1197 // TODO(stevenjb): chrome.networkingPrivate.startConnect | 1208 |
| 1198 chrome.send('startConnect', [detailsPage.onc_.guid()]); | 1209 var onc = detailsPage.onc_; |
| 1199 PageManager.closeOverlay(); | 1210 var guid = onc.guid(); |
| 1211 var type = onc.getActiveValue('Type'); |
| 1212 |
| 1213 // VPNs do not correctly set 'Connectable', so we always show the |
| 1214 // configuration UI. |
| 1215 if (type == 'VPN') { |
| 1216 chrome.send('configureNetwork', [guid]); |
| 1217 return; |
| 1218 } |
| 1219 |
| 1220 // If 'Connectable' is false for WiFi or WiMAX, Shill requires |
| 1221 // additional configuration to connect, so show the configuration UI. |
| 1222 if ((type == 'WiFi' || type == 'WiMAX') && |
| 1223 !onc.getActiveValue('Connectable')) { |
| 1224 chrome.send('configureNetwork', [guid]); |
| 1225 return; |
| 1226 } |
| 1227 |
| 1228 // Secure WiFi networks with ErrorState set most likely require |
| 1229 // configuration (e.g. a correct passphrase) before connecting. |
| 1230 if (type == 'WiFi' && onc.getWiFiSecurity() != 'None') { |
| 1231 var errorState = onc.getActiveValue('ErrorState'); |
| 1232 if (errorState && errorState != 'Unknown') { |
| 1233 chrome.send('configureNetwork', [guid]); |
| 1234 return; |
| 1235 } |
| 1236 } |
| 1237 |
| 1238 // Cellular networks need to be activated before they can be connected to. |
| 1239 if (type == 'Cellular') { |
| 1240 var activationState = onc.getActiveValue('Cellular.ActivationState'); |
| 1241 if (activationState != 'Activated' && activationState != 'Unknown') { |
| 1242 DetailsInternetPage.activateCellular(guid); |
| 1243 return; |
| 1244 } |
| 1245 } |
| 1246 |
| 1247 chrome.networkingPrivate.startConnect(guid); |
| 1200 }; | 1248 }; |
| 1201 | 1249 |
| 1202 DetailsInternetPage.disconnectNetwork = function() { | 1250 DetailsInternetPage.disconnectNetwork = function() { |
| 1203 var detailsPage = DetailsInternetPage.getInstance(); | 1251 var detailsPage = DetailsInternetPage.getInstance(); |
| 1204 if (detailsPage.type_ == 'WiFi') | 1252 if (detailsPage.type_ == 'WiFi') |
| 1205 sendChromeMetricsAction('Options_NetworkDisconnectWifi'); | 1253 sendChromeMetricsAction('Options_NetworkDisconnectWifi'); |
| 1206 else if (detailsPage.type_ == 'VPN') | 1254 else if (detailsPage.type_ == 'VPN') |
| 1207 sendChromeMetricsAction('Options_NetworkDisconnectVPN'); | 1255 sendChromeMetricsAction('Options_NetworkDisconnectVPN'); |
| 1208 chrome.networkingPrivate.startDisconnect(detailsPage.onc_.guid()); | 1256 chrome.networkingPrivate.startDisconnect(detailsPage.onc_.guid()); |
| 1209 PageManager.closeOverlay(); | 1257 PageManager.closeOverlay(); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 | 1833 |
| 1786 // Don't show page name in address bar and in history to prevent people | 1834 // Don't show page name in address bar and in history to prevent people |
| 1787 // navigate here by hand and solve issue with page session restore. | 1835 // navigate here by hand and solve issue with page session restore. |
| 1788 PageManager.showPageByName('detailsInternetPage', false); | 1836 PageManager.showPageByName('detailsInternetPage', false); |
| 1789 }; | 1837 }; |
| 1790 | 1838 |
| 1791 return { | 1839 return { |
| 1792 DetailsInternetPage: DetailsInternetPage | 1840 DetailsInternetPage: DetailsInternetPage |
| 1793 }; | 1841 }; |
| 1794 }); | 1842 }); |
| OLD | NEW |