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 an API object that simulates the | 10 // * chrome.send calls will be replaced with an API object that simulates the |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 // Override the "automatic" values with the real saved DHCP values, | 1207 // Override the "automatic" values with the real saved DHCP values, |
1208 // if they are set. | 1208 // if they are set. |
1209 var savedNameServersString; | 1209 var savedNameServersString; |
1210 var savedIpAddress = onc.getActiveValue('SavedIPConfig.IPAddress'); | 1210 var savedIpAddress = onc.getActiveValue('SavedIPConfig.IPAddress'); |
1211 if (savedIpAddress != undefined) { | 1211 if (savedIpAddress != undefined) { |
1212 inetAddress.automatic = savedIpAddress; | 1212 inetAddress.automatic = savedIpAddress; |
1213 inetAddress.value = savedIpAddress; | 1213 inetAddress.value = savedIpAddress; |
1214 } | 1214 } |
1215 var savedPrefix = onc.getActiveValue('SavedIPConfig.RoutingPrefix'); | 1215 var savedPrefix = onc.getActiveValue('SavedIPConfig.RoutingPrefix'); |
1216 if (savedPrefix != undefined) { | 1216 if (savedPrefix != undefined) { |
1217 var savedNetmask = prefixLengthToNetmask(savedPrefix); | 1217 assert(typeof savedPrefix == 'number'); |
| 1218 var savedNetmask = prefixLengthToNetmask( |
| 1219 /** @type {number} */(savedPrefix)); |
1218 inetNetmask.automatic = savedNetmask; | 1220 inetNetmask.automatic = savedNetmask; |
1219 inetNetmask.value = savedNetmask; | 1221 inetNetmask.value = savedNetmask; |
1220 } | 1222 } |
1221 var savedGateway = onc.getActiveValue('SavedIPConfig.Gateway'); | 1223 var savedGateway = onc.getActiveValue('SavedIPConfig.Gateway'); |
1222 if (savedGateway != undefined) { | 1224 if (savedGateway != undefined) { |
1223 inetGateway.automatic = savedGateway; | 1225 inetGateway.automatic = savedGateway; |
1224 inetGateway.value = savedGateway; | 1226 inetGateway.value = savedGateway; |
1225 } | 1227 } |
1226 var savedNameServers = onc.getActiveValue('SavedIPConfig.NameServers'); | 1228 var savedNameServers = onc.getActiveValue('SavedIPConfig.NameServers'); |
1227 if (savedNameServers) { | 1229 if (savedNameServers) { |
1228 savedNameServers = savedNameServers.sort(); | 1230 savedNameServers = savedNameServers.sort(); |
1229 savedNameServersString = savedNameServers.join(','); | 1231 savedNameServersString = savedNameServers.join(','); |
1230 } | 1232 } |
1231 | 1233 |
1232 var ipAutoConfig = 'automatic'; | 1234 var ipAutoConfig = 'automatic'; |
1233 | 1235 |
1234 var staticNameServersString; | 1236 var staticNameServersString; |
1235 var staticIpAddress = onc.getActiveValue('StaticIPConfig.IPAddress'); | 1237 var staticIpAddress = onc.getActiveValue('StaticIPConfig.IPAddress'); |
1236 if (staticIpAddress != undefined) { | 1238 if (staticIpAddress != undefined) { |
1237 ipAutoConfig = 'user'; | 1239 ipAutoConfig = 'user'; |
1238 inetAddress.user = staticIpAddress; | 1240 inetAddress.user = staticIpAddress; |
1239 inetAddress.value = staticIpAddress; | 1241 inetAddress.value = staticIpAddress; |
1240 } | 1242 } |
1241 var staticPrefix = onc.getActiveValue('StaticIPConfig.RoutingPrefix'); | 1243 var staticPrefix = onc.getActiveValue('StaticIPConfig.RoutingPrefix'); |
1242 if (staticPrefix != undefined) { | 1244 if (staticPrefix != undefined) { |
1243 var staticNetmask = prefixLengthToNetmask(staticPrefix); | 1245 assert(typeof staticPrefix == 'number'); |
| 1246 var staticNetmask = prefixLengthToNetmask( |
| 1247 /** @type {number} */(staticPrefix)); |
1244 inetNetmask.user = staticNetmask; | 1248 inetNetmask.user = staticNetmask; |
1245 inetNetmask.value = staticNetmask; | 1249 inetNetmask.value = staticNetmask; |
1246 } | 1250 } |
1247 var staticGateway = onc.getActiveValue('StaticIPConfig.Gateway'); | 1251 var staticGateway = onc.getActiveValue('StaticIPConfig.Gateway'); |
1248 if (staticGateway != undefined) { | 1252 if (staticGateway != undefined) { |
1249 inetGateway.user = staticGateway; | 1253 inetGateway.user = staticGateway; |
1250 inetGateway.value = staticGateway; | 1254 inetGateway.value = staticGateway; |
1251 } | 1255 } |
1252 var staticNameServers = onc.getActiveValue('StaticIPConfig.NameServers'); | 1256 var staticNameServers = onc.getActiveValue('StaticIPConfig.NameServers'); |
1253 if (staticNameServers) { | 1257 if (staticNameServers) { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 | 1518 |
1515 // Don't show page name in address bar and in history to prevent people | 1519 // Don't show page name in address bar and in history to prevent people |
1516 // navigate here by hand and solve issue with page session restore. | 1520 // navigate here by hand and solve issue with page session restore. |
1517 PageManager.showPageByName('detailsInternetPage', false); | 1521 PageManager.showPageByName('detailsInternetPage', false); |
1518 }; | 1522 }; |
1519 | 1523 |
1520 return { | 1524 return { |
1521 DetailsInternetPage: DetailsInternetPage | 1525 DetailsInternetPage: DetailsInternetPage |
1522 }; | 1526 }; |
1523 }); | 1527 }); |
OLD | NEW |