Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 * @param {string} selector CSS selector for extracting a list of elements. | 24 * @param {string} selector CSS selector for extracting a list of elements. |
| 25 * @param {bool} hidden New hidden value. | 25 * @param {bool} hidden New hidden value. |
| 26 */ | 26 */ |
| 27 function updateHidden(selector, hidden) { | 27 function updateHidden(selector, hidden) { |
| 28 var elements = cr.doc.querySelectorAll(selector); | 28 var elements = cr.doc.querySelectorAll(selector); |
| 29 for (var i = 0, el; el = elements[i]; i++) { | 29 for (var i = 0, el; el = elements[i]; i++) { |
| 30 el.hidden = hidden; | 30 el.hidden = hidden; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 /* | |
| 35 * Helper function to update the properties of the data object from the | |
| 36 * properties in the update object. | |
| 37 * @param {object} data object to update. | |
| 38 * @param {object} object containing the updated properties. | |
| 39 */ | |
| 40 function updateDataObject(data, update) { | |
| 41 for (var prop in update) { | |
| 42 if (prop in data) | |
| 43 data[prop] = update[prop]; | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 /** | 34 /** |
| 48 * Monitor pref change of given element. | 35 * Monitor pref change of given element. |
| 49 * @param {Element} el Target element. | 36 * @param {Element} el Target element. |
| 50 */ | 37 */ |
| 51 function observePrefsUI(el) { | 38 function observePrefsUI(el) { |
| 52 Preferences.getInstance().addEventListener(el.pref, handlePrefUpdate); | 39 Preferences.getInstance().addEventListener(el.pref, handlePrefUpdate); |
| 53 } | 40 } |
| 54 | 41 |
| 55 /** | 42 /** |
| 56 * UI pref change handler. | 43 * UI pref change handler. |
| 57 * @param {Event} e The update event. | 44 * @param {Event} e The update event. |
| 58 */ | 45 */ |
| 59 function handlePrefUpdate(e) { | 46 function handlePrefUpdate(e) { |
| 60 DetailsInternetPage.getInstance().updateControls(); | 47 DetailsInternetPage.getInstance().updateControls_(); |
|
armansito
2014/09/06 00:38:56
nit: It feels a bit awkward that this top-level fu
stevenjb
2014/09/08 19:43:12
Yeah, I think you're right. I will make updateCont
| |
| 61 } | 48 } |
| 62 | 49 |
| 63 /** | 50 /** |
| 64 * Simple helper method for converting a field to a string. It is used to | 51 * Simple helper method for converting a field to a string. It is used to |
| 65 * easily assign an empty string from fields that may be unknown or undefined. | 52 * easily assign an empty string from fields that may be unknown or undefined. |
| 66 * @param {object} value that should be converted to a string. | 53 * @param {object} value that should be converted to a string. |
| 67 * @return {string} the result. | 54 * @return {string} the result. |
| 68 */ | 55 */ |
| 69 function stringFromValue(value) { | 56 function stringFromValue(value) { |
| 70 return value ? String(value) : ''; | 57 return value ? String(value) : ''; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 } | 96 } |
| 110 | 97 |
| 111 ///////////////////////////////////////////////////////////////////////////// | 98 ///////////////////////////////////////////////////////////////////////////// |
| 112 // DetailsInternetPage class: | 99 // DetailsInternetPage class: |
| 113 | 100 |
| 114 /** | 101 /** |
| 115 * Encapsulated handling of ChromeOS internet details overlay page. | 102 * Encapsulated handling of ChromeOS internet details overlay page. |
| 116 * @constructor | 103 * @constructor |
| 117 */ | 104 */ |
| 118 function DetailsInternetPage() { | 105 function DetailsInternetPage() { |
| 106 this.userApnIndex_ = -1; | |
| 107 this.selectedApnIndex_ = -1; | |
| 108 this.userApn_ = {}; | |
| 119 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); | 109 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); |
| 120 } | 110 } |
| 121 | 111 |
| 122 cr.addSingletonGetter(DetailsInternetPage); | 112 cr.addSingletonGetter(DetailsInternetPage); |
| 123 | 113 |
| 124 DetailsInternetPage.prototype = { | 114 DetailsInternetPage.prototype = { |
| 125 __proto__: Page.prototype, | 115 __proto__: Page.prototype, |
| 126 | 116 |
| 127 /** @override */ | 117 /** @override */ |
| 128 initializePage: function() { | 118 initializePage: function() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 function(event) { | 157 function(event) { |
| 168 DetailsInternetPage.setDetails(); | 158 DetailsInternetPage.setDetails(); |
| 169 DetailsInternetPage.configureNetwork(); | 159 DetailsInternetPage.configureNetwork(); |
| 170 }); | 160 }); |
| 171 | 161 |
| 172 $('activate-details').addEventListener('click', function(event) { | 162 $('activate-details').addEventListener('click', function(event) { |
| 173 DetailsInternetPage.activateFromDetails(); | 163 DetailsInternetPage.activateFromDetails(); |
| 174 }); | 164 }); |
| 175 | 165 |
| 176 $('buyplan-details').addEventListener('click', function(event) { | 166 $('buyplan-details').addEventListener('click', function(event) { |
| 177 var data = $('connection-state').data; | 167 chrome.send('buyDataPlan', |
| 178 chrome.send('buyDataPlan', [data.servicePath]); | 168 [DetailsInternetPage.getInstance().servicePath_]); |
| 179 PageManager.closeOverlay(); | 169 PageManager.closeOverlay(); |
| 180 }); | 170 }); |
| 181 | 171 |
| 182 $('view-account-details').addEventListener('click', function(event) { | 172 $('view-account-details').addEventListener('click', function(event) { |
| 183 var data = $('connection-state').data; | 173 chrome.send('showMorePlanInfo', |
| 184 chrome.send('showMorePlanInfo', [data.servicePath]); | 174 [DetailsInternetPage.getInstance().servicePath_]); |
| 185 PageManager.closeOverlay(); | 175 PageManager.closeOverlay(); |
| 186 }); | 176 }); |
| 187 | 177 |
| 188 $('cellular-apn-use-default').addEventListener('click', function(event) { | 178 $('cellular-apn-use-default').addEventListener('click', function(event) { |
| 189 var data = $('connection-state').data; | 179 DetailsInternetPage.getInstance().setDefaultApn_(); |
| 190 var onc = $('connection-state').onc; | |
| 191 var apnSelector = $('select-apn'); | |
| 192 | |
| 193 if (data.userApnIndex != -1) { | |
| 194 apnSelector.remove(data.userApnIndex); | |
| 195 data.userApnIndex = -1; | |
| 196 } | |
| 197 | |
| 198 var activeApn; | |
| 199 var iApn = -1; | |
| 200 var apnList = onc.getActiveValue('Cellular.APNList'); | |
| 201 if (apnList != undefined && apnList.length > 0) { | |
| 202 iApn = 0; | |
| 203 var defaultApn = apnList[iApn]; | |
| 204 activeApn['AccessPointName'] = | |
| 205 stringFromValue(defaultApn['AccessPointName']); | |
| 206 activeApn['Username'] = stringFromValue(defaultApn['Username']); | |
| 207 activeApn['Password'] = stringFromValue(defaultApn['Password']); | |
| 208 chrome.send('setApn', [data.servicePath, | |
| 209 activeApn['AccessPointName'], | |
| 210 activeApn['Username'], | |
| 211 activeApn['Password']]); | |
| 212 } | |
| 213 onc.setManagedProperty('Cellular.APN', activeApn); | |
| 214 apnSelector.selectedIndex = iApn; | |
| 215 data.selectedApn = iApn; | |
| 216 | |
| 217 updateHidden('.apn-list-view', false); | |
| 218 updateHidden('.apn-details-view', true); | |
| 219 }); | 180 }); |
| 220 | 181 |
| 221 $('cellular-apn-set').addEventListener('click', function(event) { | 182 $('cellular-apn-set').addEventListener('click', function(event) { |
| 222 if ($('cellular-apn').value == '') | 183 DetailsInternetPage.getInstance().setApn_($('cellular-apn').value); |
| 223 return; | |
| 224 | |
| 225 var data = $('connection-state').data; | |
| 226 var onc = $('connection-state').onc; | |
| 227 var apnSelector = $('select-apn'); | |
| 228 | |
| 229 var activeApn = {}; | |
| 230 activeApn['AccessPointName'] = | |
| 231 stringFromValue($('cellular-apn').value); | |
| 232 activeApn['Username'] = | |
| 233 stringFromValue($('cellular-apn-username').value); | |
| 234 activeApn['Password'] = | |
| 235 stringFromValue($('cellular-apn-password').value); | |
| 236 onc.setManagedProperty('Cellular.APN', activeApn); | |
| 237 data.userApn = activeApn; | |
| 238 chrome.send('setApn', [data.servicePath, | |
| 239 activeApn['AccessPointName'], | |
| 240 activeApn['Username'], | |
| 241 activeApn['Password']]); | |
| 242 | |
| 243 if (data.userApnIndex != -1) { | |
| 244 apnSelector.remove(data.userApnIndex); | |
| 245 data.userApnIndex = -1; | |
| 246 } | |
| 247 | |
| 248 var option = document.createElement('option'); | |
| 249 option.textContent = activeApn['AccessPointName']; | |
| 250 option.value = -1; | |
| 251 option.selected = true; | |
| 252 apnSelector.add(option, apnSelector[apnSelector.length - 1]); | |
| 253 data.userApnIndex = apnSelector.length - 2; | |
| 254 data.selectedApn = data.userApnIndex; | |
| 255 | |
| 256 updateHidden('.apn-list-view', false); | |
| 257 updateHidden('.apn-details-view', true); | |
| 258 }); | 184 }); |
| 259 | 185 |
| 260 $('cellular-apn-cancel').addEventListener('click', function(event) { | 186 $('cellular-apn-cancel').addEventListener('click', function(event) { |
| 261 $('select-apn').selectedIndex = $('connection-state').data.selectedApn; | 187 DetailsInternetPage.getInstance().cancelApn_(); |
| 262 updateHidden('.apn-list-view', false); | |
| 263 updateHidden('.apn-details-view', true); | |
| 264 }); | 188 }); |
| 265 | 189 |
| 266 $('select-apn').addEventListener('change', function(event) { | 190 $('select-apn').addEventListener('change', function(event) { |
| 267 var data = $('connection-state').data; | 191 DetailsInternetPage.getInstance().selectApn_(); |
| 268 var onc = $('connection-state').onc; | |
| 269 var apnSelector = $('select-apn'); | |
| 270 var apnDict; | |
| 271 if (apnSelector[apnSelector.selectedIndex].value != -1) { | |
| 272 var apnList = onc.getActiveValue('Cellular.APNList'); | |
| 273 var apnIndex = apnSelector.selectedIndex; | |
| 274 assert(apnIndex < apnList.length); | |
| 275 apnDict = apnList[apnIndex]; | |
| 276 chrome.send('setApn', [data.servicePath, | |
| 277 stringFromValue(apnDict['AccessPointName']), | |
| 278 stringFromValue(apnDict['Username']), | |
| 279 stringFromValue(apnDict['Password'])]); | |
| 280 data.selectedApn = apnIndex; | |
| 281 } else if (apnSelector.selectedIndex == data.userApnIndex) { | |
| 282 apnDict = data.userApn; | |
| 283 chrome.send('setApn', [data.servicePath, | |
| 284 stringFromValue(apnDict['AccessPointName']), | |
| 285 stringFromValue(apnDict['Username']), | |
| 286 stringFromValue(apnDict['Password'])]); | |
| 287 data.selectedApn = apnSelector.selectedIndex; | |
| 288 } else { | |
| 289 apnDict = onc.getActiveValue('Cellular.APN'); | |
| 290 $('cellular-apn').value = stringFromValue(apnDict['AccessPointName']); | |
| 291 $('cellular-apn-username').value = | |
| 292 stringFromValue(apnDict['Username']); | |
| 293 $('cellular-apn-password').value = | |
| 294 stringFromValue(apnDict['Password']); | |
| 295 | |
| 296 updateHidden('.apn-list-view', true); | |
| 297 updateHidden('.apn-details-view', false); | |
| 298 } | |
| 299 }); | 192 }); |
| 300 | 193 |
| 301 $('sim-card-lock-enabled').addEventListener('click', function(event) { | 194 $('sim-card-lock-enabled').addEventListener('click', function(event) { |
| 302 var newValue = $('sim-card-lock-enabled').checked; | 195 var newValue = $('sim-card-lock-enabled').checked; |
| 303 // Leave value as is because user needs to enter PIN code first. | 196 // Leave value as is because user needs to enter PIN code first. |
| 304 // When PIN will be entered and value changed, | 197 // When PIN will be entered and value changed, |
| 305 // we'll update UI to reflect that change. | 198 // we'll update UI to reflect that change. |
| 306 $('sim-card-lock-enabled').checked = !newValue; | 199 $('sim-card-lock-enabled').checked = !newValue; |
| 307 chrome.send('setSimCardLock', [newValue]); | 200 chrome.send('setSimCardLock', [newValue]); |
| 308 }); | 201 }); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 } else if (effective == 'UserPolicy' || effective == 'DevicePolicy') { | 363 } else if (effective == 'UserPolicy' || effective == 'DevicePolicy') { |
| 471 event.value.controlledBy = 'policy'; | 364 event.value.controlledBy = 'policy'; |
| 472 } | 365 } |
| 473 | 366 |
| 474 return event; | 367 return event; |
| 475 }, | 368 }, |
| 476 | 369 |
| 477 /** | 370 /** |
| 478 * Update details page controls. | 371 * Update details page controls. |
| 479 */ | 372 */ |
| 480 updateControls: function() { | 373 updateControls_: function() { |
| 481 // Only show ipconfig section if network is connected OR if nothing on | 374 // Only show ipconfig section if network is connected OR if nothing on |
| 482 // this device is connected. This is so that you can fix the ip configs | 375 // this device is connected. This is so that you can fix the ip configs |
| 483 // if you can't connect to any network. | 376 // if you can't connect to any network. |
| 484 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, | 377 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, |
| 485 // we need to redo this logic to allow configuration of all networks. | 378 // we need to redo this logic to allow configuration of all networks. |
| 486 $('ipconfig-section').hidden = !this.connected && this.deviceConnected; | 379 $('ipconfig-section').hidden = !this.connected && this.deviceConnected; |
| 487 $('ipconfig-dns-section').hidden = | 380 $('ipconfig-dns-section').hidden = |
| 488 !this.connected && this.deviceConnected; | 381 !this.connected && this.deviceConnected; |
| 489 | 382 |
| 490 // Network type related. | 383 // Network type related. |
| 491 updateHidden('#details-internet-page .cellular-details', | 384 updateHidden('#details-internet-page .cellular-details', |
| 492 this.type != 'Cellular'); | 385 this.type_ != 'Cellular'); |
| 493 updateHidden('#details-internet-page .wifi-details', | 386 updateHidden('#details-internet-page .wifi-details', |
| 494 this.type != 'WiFi'); | 387 this.type_ != 'WiFi'); |
| 495 updateHidden('#details-internet-page .wimax-details', | 388 updateHidden('#details-internet-page .wimax-details', |
| 496 this.type != 'Wimax'); | 389 this.type_ != 'Wimax'); |
| 497 updateHidden('#details-internet-page .vpn-details', this.type != 'VPN'); | 390 updateHidden('#details-internet-page .vpn-details', this.type_ != 'VPN'); |
| 498 updateHidden('#details-internet-page .proxy-details', !this.showProxy); | 391 updateHidden('#details-internet-page .proxy-details', !this.showProxy); |
| 499 | 392 |
| 500 // Cellular | 393 // Cellular |
| 501 | 394 |
| 502 // Conditionally call updateHidden on .gsm-only, so that we don't unhide | 395 // Conditionally call updateHidden on .gsm-only, so that we don't unhide |
| 503 // a previously hidden element. | 396 // a previously hidden element. |
| 504 if (this.gsm) | 397 if (this.gsm) |
| 505 updateHidden('#details-internet-page .cdma-only', true); | 398 updateHidden('#details-internet-page .cdma-only', true); |
| 506 else | 399 else |
| 507 updateHidden('#details-internet-page .gsm-only', true); | 400 updateHidden('#details-internet-page .gsm-only', true); |
| 508 | 401 |
| 509 // Wifi | 402 // Wifi |
| 510 | 403 |
| 511 // Hide network tab for VPN. | 404 // Hide network tab for VPN. |
| 512 updateHidden('#details-internet-page .network-details', | 405 updateHidden('#details-internet-page .network-details', |
| 513 this.type == 'VPN'); | 406 this.type_ == 'VPN'); |
| 514 | 407 |
| 515 // Password and shared. | 408 // Password and shared. |
| 516 updateHidden('#details-internet-page #password-details', | 409 updateHidden('#details-internet-page #password-details', |
| 517 this.type != 'WiFi' || !this.hasSecurity); | 410 this.type_ != 'WiFi' || !this.hasSecurity); |
| 518 updateHidden('#details-internet-page #wifi-shared-network', | 411 updateHidden('#details-internet-page #wifi-shared-network', |
| 519 !this.shared); | 412 !this.shared); |
| 520 updateHidden('#details-internet-page #prefer-network', | 413 updateHidden('#details-internet-page #prefer-network', |
| 521 !this.showPreferred); | 414 !this.showPreferred); |
| 522 | 415 |
| 523 // WiMAX. | 416 // WiMAX. |
| 524 updateHidden('#details-internet-page #wimax-shared-network', | 417 updateHidden('#details-internet-page #wimax-shared-network', |
| 525 !this.shared); | 418 !this.shared); |
| 526 | 419 |
| 527 // Proxy | 420 // Proxy |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 642 $('ftp-proxy').disabled = allDisabled; | 535 $('ftp-proxy').disabled = allDisabled; |
| 643 $('ftp-proxy-port').disabled = allDisabled; | 536 $('ftp-proxy-port').disabled = allDisabled; |
| 644 $('socks-host').disabled = allDisabled; | 537 $('socks-host').disabled = allDisabled; |
| 645 $('socks-port').disabled = allDisabled; | 538 $('socks-port').disabled = allDisabled; |
| 646 $('proxy-use-pac-url').disabled = true; | 539 $('proxy-use-pac-url').disabled = true; |
| 647 $('proxy-pac-url').disabled = true; | 540 $('proxy-pac-url').disabled = true; |
| 648 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; | 541 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; |
| 649 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; | 542 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; |
| 650 chrome.send('coreOptionsUserMetricsAction', | 543 chrome.send('coreOptionsUserMetricsAction', |
| 651 ['Options_NetworkManualProxy_Enable']); | 544 ['Options_NetworkManualProxy_Enable']); |
| 545 }, | |
| 546 | |
| 547 updateConnectionButtonVisibilty_: function() { | |
| 548 var onc = this.onc_; | |
| 549 if (this.type_ == 'Ethernet') { | |
| 550 // Ethernet can never be connected or disconnected and can always be | |
| 551 // configured (e.g. to set security). | |
| 552 $('details-internet-login').hidden = true; | |
| 553 $('details-internet-disconnect').hidden = true; | |
| 554 $('details-internet-configure').hidden = false; | |
| 555 return; | |
| 556 } | |
| 557 | |
| 558 var connectState = onc.getActiveValue('ConnectionState'); | |
| 559 if (connectState == 'NotConnected') { | |
| 560 $('details-internet-login').hidden = false; | |
| 561 // Connecting to an unconfigured network might trigger certificate | |
| 562 // installation UI. Until that gets handled here, always enable the | |
| 563 // Connect button. | |
| 564 $('details-internet-login').disabled = false; | |
| 565 $('details-internet-disconnect').hidden = true; | |
| 566 } else { | |
| 567 $('details-internet-login').hidden = true; | |
| 568 $('details-internet-disconnect').hidden = false; | |
| 569 } | |
| 570 | |
| 571 var connectable = onc.getActiveValue('Connectable'); | |
| 572 if (connectState != 'Connected' && | |
| 573 (!connectable || this.hasSecurity || | |
| 574 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) { | |
| 575 $('details-internet-configure').hidden = false; | |
| 576 } else { | |
| 577 $('details-internet-configure').hidden = true; | |
| 578 } | |
| 579 }, | |
| 580 | |
| 581 populateHeader_: function() { | |
| 582 var onc = this.onc_; | |
| 583 | |
| 584 $('network-details-title').textContent = onc.getTranslatedValue('Name'); | |
| 585 var connectionState = onc.getActiveValue('ConnectionState'); | |
| 586 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | |
| 587 this.connected = connectionState == 'Connected'; | |
| 588 $('network-details-subtitle-status').textContent = connectionStateString; | |
| 589 var typeKey; | |
| 590 var type = this.type_; | |
| 591 if (type == 'Ethernet') | |
| 592 typeKey = 'ethernetTitle'; | |
| 593 else if (type == 'WiFi') | |
| 594 typeKey = 'wifiTitle'; | |
| 595 else if (type == 'Wimax') | |
| 596 typeKey = 'wimaxTitle'; | |
| 597 else if (type == 'Cellular') | |
| 598 typeKey = 'cellularTitle'; | |
| 599 else if (type == 'VPN') | |
| 600 typeKey = 'vpnTitle'; | |
| 601 else | |
| 602 typeKey = null; | |
| 603 var typeLabel = $('network-details-subtitle-type'); | |
| 604 var typeSeparator = $('network-details-subtitle-separator'); | |
| 605 if (typeKey) { | |
| 606 typeLabel.textContent = loadTimeData.getString(typeKey); | |
| 607 typeLabel.hidden = false; | |
| 608 typeSeparator.hidden = false; | |
| 609 } else { | |
| 610 typeLabel.hidden = true; | |
| 611 typeSeparator.hidden = true; | |
| 612 } | |
| 613 }, | |
| 614 | |
| 615 initializeApnList_: function(onc) { | |
| 616 var apnSelector = $('select-apn'); | |
| 617 // Clear APN lists, keep only last element that "other". | |
| 618 while (apnSelector.length != 1) { | |
| 619 apnSelector.remove(0); | |
| 620 } | |
| 621 var otherOption = apnSelector[0]; | |
| 622 var activeApn = onc.getActiveValue('Cellular.APN.AccessPointName'); | |
| 623 var activeUsername = onc.getActiveValue('Cellular.APN.Username'); | |
| 624 var activePassword = onc.getActiveValue('Cellular.APN.Password'); | |
| 625 var lastGoodApn = | |
| 626 onc.getActiveValue('Cellular.LastGoodAPN.AccessPointName'); | |
| 627 var lastGoodUsername = | |
| 628 onc.getActiveValue('Cellular.LastGoodAPN.Username'); | |
| 629 var lastGoodPassword = | |
| 630 onc.getActiveValue('Cellular.LastGoodAPN.Password'); | |
| 631 var apnList = onc.getActiveValue('Cellular.APNList'); | |
| 632 for (var i = 0; i < apnList.length; i++) { | |
| 633 var apnDict = apnList[i]; | |
| 634 var option = document.createElement('option'); | |
| 635 var localizedName = apnDict['LocalizedName']; | |
| 636 var name = localizedName ? localizedName : apnDict['Name']; | |
| 637 var accessPointName = apnDict['AccessPointName']; | |
| 638 option.textContent = | |
| 639 name ? (name + ' (' + accessPointName + ')') : accessPointName; | |
| 640 option.value = i; | |
| 641 // If this matches the active Apn, or LastGoodApn, set it as the | |
| 642 // selected Apn. | |
| 643 if ((activeApn == accessPointName && | |
| 644 activeUsername == apnDict['Username'] && | |
| 645 activePassword == apnDict['Password']) || | |
| 646 (!activeApn && | |
| 647 lastGoodApn == accessPointName && | |
| 648 lastGoodUsername == apnDict['Username'] && | |
| 649 lastGoodPassword == apnDict['Password'])) { | |
| 650 this.selectedApnIndex_ = i; | |
| 651 } | |
| 652 // Insert new option before "other" option. | |
| 653 apnSelector.add(option, otherOption); | |
| 654 } | |
| 655 if (this.selectedApnIndex_ == -1 && activeApn) { | |
| 656 var activeOption = document.createElement('option'); | |
| 657 activeOption.textContent = activeApn; | |
| 658 activeOption.value = -1; | |
| 659 apnSelector.add(activeOption, otherOption); | |
| 660 this.selectedApnIndex_ = apnSelector.length - 2; | |
| 661 this.userApnIndex_ = this.selectedApnIndex_; | |
| 662 } | |
| 663 assert(this.selectedApnIndex_ >= 0); | |
| 664 apnSelector.selectedIndex = this.selectedApnIndex_; | |
| 665 updateHidden('.apn-list-view', false); | |
| 666 updateHidden('.apn-details-view', true); | |
| 667 }, | |
| 668 | |
| 669 setDefaultApn_: function() { | |
| 670 var onc = this.onc_; | |
| 671 var apnSelector = $('select-apn'); | |
| 672 | |
| 673 if (this.userApnIndex_ != -1) { | |
| 674 apnSelector.remove(this.userApnIndex_); | |
| 675 this.userApnIndex_ = -1; | |
| 676 } | |
| 677 | |
| 678 var activeApn; | |
| 679 var iApn = -1; | |
| 680 var apnList = onc.getActiveValue('Cellular.APNList'); | |
| 681 if (apnList != undefined && apnList.length > 0) { | |
| 682 iApn = 0; | |
| 683 var defaultApn = apnList[iApn]; | |
| 684 activeApn['AccessPointName'] = | |
| 685 stringFromValue(defaultApn['AccessPointName']); | |
| 686 activeApn['Username'] = stringFromValue(defaultApn['Username']); | |
| 687 activeApn['Password'] = stringFromValue(defaultApn['Password']); | |
| 688 chrome.send('setApn', [this.servicePath_, | |
| 689 activeApn['AccessPointName'], | |
| 690 activeApn['Username'], | |
| 691 activeApn['Password']]); | |
| 692 } | |
| 693 onc.setManagedProperty('Cellular.APN', activeApn); | |
|
pneubeck (no reviews)
2014/09/08 21:51:05
maybe the original idea here was, that this proper
stevenjb
2014/09/08 23:25:16
I thought of that, but I don't see any advantage t
| |
| 694 apnSelector.selectedIndex = iApn; | |
| 695 this.selectedApnIndex_ = iApn; | |
| 696 | |
| 697 updateHidden('.apn-list-view', false); | |
| 698 updateHidden('.apn-details-view', true); | |
| 699 }, | |
| 700 | |
| 701 setApn_: function(apnValue) { | |
| 702 if (apnValue == '') | |
| 703 return; | |
| 704 | |
| 705 var onc = this.onc_; | |
| 706 var apnSelector = $('select-apn'); | |
| 707 | |
| 708 var activeApn = {}; | |
| 709 activeApn['AccessPointName'] = stringFromValue(apnValue); | |
| 710 activeApn['Username'] = stringFromValue($('cellular-apn-username').value); | |
| 711 activeApn['Password'] = stringFromValue($('cellular-apn-password').value); | |
| 712 onc.setManagedProperty('Cellular.APN', activeApn); | |
| 713 this.userApn_ = activeApn; | |
| 714 chrome.send('setApn', [this.servicePath_, | |
| 715 activeApn['AccessPointName'], | |
| 716 activeApn['Username'], | |
| 717 activeApn['Password']]); | |
| 718 | |
| 719 if (this.userApnIndex_ != -1) { | |
| 720 apnSelector.remove(this.userApnIndex_); | |
| 721 this.userApnIndex_ = -1; | |
| 722 } | |
| 723 | |
| 724 var option = document.createElement('option'); | |
| 725 option.textContent = activeApn['AccessPointName']; | |
| 726 option.value = -1; | |
| 727 option.selected = true; | |
| 728 apnSelector.add(option, apnSelector[apnSelector.length - 1]); | |
| 729 this.userApnIndex_ = apnSelector.length - 2; | |
| 730 this.selectedApnIndex_ = this.userApnIndex_; | |
| 731 | |
| 732 updateHidden('.apn-list-view', false); | |
| 733 updateHidden('.apn-details-view', true); | |
| 734 }, | |
| 735 | |
| 736 cancelApn_: function() { | |
| 737 $('select-apn').selectedIndex = this.selectedApnIndex_; | |
| 738 updateHidden('.apn-list-view', false); | |
| 739 updateHidden('.apn-details-view', true); | |
| 740 }, | |
| 741 | |
| 742 selectApn_: function() { | |
| 743 var onc = this.onc_; | |
| 744 var apnSelector = $('select-apn'); | |
| 745 var apnDict; | |
| 746 if (apnSelector[apnSelector.selectedIndex].value != -1) { | |
| 747 var apnList = onc.getActiveValue('Cellular.APNList'); | |
| 748 var apnIndex = apnSelector.selectedIndex; | |
| 749 assert(apnIndex < apnList.length); | |
| 750 apnDict = apnList[apnIndex]; | |
| 751 chrome.send('setApn', [this.servicePath_, | |
| 752 stringFromValue(apnDict['AccessPointName']), | |
| 753 stringFromValue(apnDict['Username']), | |
| 754 stringFromValue(apnDict['Password'])]); | |
| 755 this.selectedApnIndex_ = apnIndex; | |
| 756 } else if (apnSelector.selectedIndex == this.userApnIndex_) { | |
| 757 apnDict = this.userApn_; | |
| 758 chrome.send('setApn', [this.servicePath_, | |
| 759 stringFromValue(apnDict['AccessPointName']), | |
| 760 stringFromValue(apnDict['Username']), | |
| 761 stringFromValue(apnDict['Password'])]); | |
| 762 this.selectedApnIndex_ = apnSelector.selectedIndex; | |
| 763 } else { | |
| 764 apnDict = onc.getActiveValue('Cellular.APN'); | |
| 765 $('cellular-apn').value = stringFromValue(apnDict['AccessPointName']); | |
| 766 $('cellular-apn-username').value = stringFromValue(apnDict['Username']); | |
| 767 $('cellular-apn-password').value = stringFromValue(apnDict['Password']); | |
| 768 | |
| 769 updateHidden('.apn-list-view', true); | |
| 770 updateHidden('.apn-details-view', false); | |
| 771 } | |
| 652 } | 772 } |
| 653 }; | 773 }; |
| 654 | 774 |
| 655 /** | 775 /** |
| 656 * Enables or Disables all buttons that provide operations on the cellular | 776 * Enables or Disables all buttons that provide operations on the cellular |
| 657 * network. | 777 * network. |
| 658 */ | 778 */ |
| 659 DetailsInternetPage.changeCellularButtonsState = function(disable) { | 779 DetailsInternetPage.changeCellularButtonsState = function(disable) { |
| 660 var buttonsToDisableList = | 780 var buttonsToDisableList = |
| 661 new Array('details-internet-login', | 781 new Array('details-internet-login', |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 680 DetailsInternetPage.changeCellularButtonsState(visible); | 800 DetailsInternetPage.changeCellularButtonsState(visible); |
| 681 }; | 801 }; |
| 682 | 802 |
| 683 /** | 803 /** |
| 684 * Changes the network carrier. | 804 * Changes the network carrier. |
| 685 */ | 805 */ |
| 686 DetailsInternetPage.handleCarrierChanged = function() { | 806 DetailsInternetPage.handleCarrierChanged = function() { |
| 687 var carrierSelector = $('select-carrier'); | 807 var carrierSelector = $('select-carrier'); |
| 688 var carrier = carrierSelector[carrierSelector.selectedIndex].textContent; | 808 var carrier = carrierSelector[carrierSelector.selectedIndex].textContent; |
| 689 DetailsInternetPage.showCarrierChangeSpinner(true); | 809 DetailsInternetPage.showCarrierChangeSpinner(true); |
| 690 var data = $('connection-state').data; | 810 chrome.send('setCarrier', [ |
| 691 chrome.send('setCarrier', [data.servicePath, carrier]); | 811 DetailsInternetPage.getInstance().servicePath_, carrier]); |
| 692 }; | 812 }; |
| 693 | 813 |
| 694 /** | 814 /** |
| 695 * Performs minimal initialization of the InternetDetails dialog in | 815 * Performs minimal initialization of the InternetDetails dialog in |
| 696 * preparation for showing proxy-setttings. | 816 * preparation for showing proxy-setttings. |
| 697 */ | 817 */ |
| 698 DetailsInternetPage.initializeProxySettings = function() { | 818 DetailsInternetPage.initializeProxySettings = function() { |
| 699 var detailsPage = DetailsInternetPage.getInstance(); | 819 DetailsInternetPage.getInstance().initializePageContents_(); |
| 700 detailsPage.initializePageContents_(); | |
| 701 }; | 820 }; |
| 702 | 821 |
| 703 /** | 822 /** |
| 704 * Displays the InternetDetails dialog with only the proxy settings visible. | 823 * Displays the InternetDetails dialog with only the proxy settings visible. |
| 705 */ | 824 */ |
| 706 DetailsInternetPage.showProxySettings = function() { | 825 DetailsInternetPage.showProxySettings = function() { |
| 707 var detailsPage = DetailsInternetPage.getInstance(); | 826 var detailsPage = DetailsInternetPage.getInstance(); |
| 708 $('network-details-header').hidden = true; | 827 $('network-details-header').hidden = true; |
| 709 $('buyplan-details').hidden = true; | 828 $('buyplan-details').hidden = true; |
| 710 $('activate-details').hidden = true; | 829 $('activate-details').hidden = true; |
| 711 $('view-account-details').hidden = true; | 830 $('view-account-details').hidden = true; |
| 712 $('web-proxy-auto-discovery').hidden = true; | 831 $('web-proxy-auto-discovery').hidden = true; |
| 713 detailsPage.showProxy = true; | 832 detailsPage.showProxy = true; |
| 714 updateHidden('#internet-tab', true); | 833 updateHidden('#internet-tab', true); |
| 715 updateHidden('#details-tab-strip', true); | 834 updateHidden('#details-tab-strip', true); |
| 716 updateHidden('#details-internet-page .action-area', true); | 835 updateHidden('#details-internet-page .action-area', true); |
| 717 detailsPage.updateControls(); | 836 detailsPage.updateControls_(); |
| 718 detailsPage.visible = true; | 837 detailsPage.visible = true; |
| 719 chrome.send('coreOptionsUserMetricsAction', | 838 chrome.send('coreOptionsUserMetricsAction', |
| 720 ['Options_NetworkShowProxyTab']); | 839 ['Options_NetworkShowProxyTab']); |
| 721 }; | 840 }; |
| 722 | 841 |
| 723 /** | 842 /** |
| 724 * Initializes even handling for keyboard driven flow. | 843 * Initializes even handling for keyboard driven flow. |
| 725 */ | 844 */ |
| 726 DetailsInternetPage.initializeKeyboardFlow = function() { | 845 DetailsInternetPage.initializeKeyboardFlow = function() { |
| 727 keyboard.initializeKeyboardFlow(); | 846 keyboard.initializeKeyboardFlow(); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 758 $(proxyPort).value = hostValue[1]; | 877 $(proxyPort).value = hostValue[1]; |
| 759 } | 878 } |
| 760 } | 879 } |
| 761 }; | 880 }; |
| 762 | 881 |
| 763 DetailsInternetPage.updateCarrier = function() { | 882 DetailsInternetPage.updateCarrier = function() { |
| 764 DetailsInternetPage.showCarrierChangeSpinner(false); | 883 DetailsInternetPage.showCarrierChangeSpinner(false); |
| 765 }; | 884 }; |
| 766 | 885 |
| 767 DetailsInternetPage.loginFromDetails = function() { | 886 DetailsInternetPage.loginFromDetails = function() { |
| 768 var data = $('connection-state').data; | 887 var detailsPage = DetailsInternetPage.getInstance(); |
| 769 var servicePath = data.servicePath; | 888 chrome.send('networkCommand', |
| 770 chrome.send('networkCommand', [data.type, servicePath, 'connect']); | 889 [detailsPage.type_, detailsPage.servicePath_, 'connect']); |
| 771 PageManager.closeOverlay(); | 890 PageManager.closeOverlay(); |
| 772 }; | 891 }; |
| 773 | 892 |
| 774 DetailsInternetPage.disconnectNetwork = function() { | 893 DetailsInternetPage.disconnectNetwork = function() { |
| 775 var data = $('connection-state').data; | 894 var detailsPage = DetailsInternetPage.getInstance(); |
| 776 var servicePath = data.servicePath; | 895 chrome.send('networkCommand', |
| 777 chrome.send('networkCommand', [data.type, servicePath, 'disconnect']); | 896 [detailsPage.type_, detailsPage.servicePath_, 'disconnect']); |
| 778 PageManager.closeOverlay(); | 897 PageManager.closeOverlay(); |
| 779 }; | 898 }; |
| 780 | 899 |
| 781 DetailsInternetPage.configureNetwork = function() { | 900 DetailsInternetPage.configureNetwork = function() { |
| 782 var data = $('connection-state').data; | 901 var detailsPage = DetailsInternetPage.getInstance(); |
| 783 var servicePath = data.servicePath; | 902 chrome.send('networkCommand', |
| 784 chrome.send('networkCommand', [data.type, servicePath, 'configure']); | 903 [detailsPage.type_, detailsPage.servicePath_, 'configure']); |
| 785 PageManager.closeOverlay(); | 904 PageManager.closeOverlay(); |
| 786 }; | 905 }; |
| 787 | 906 |
| 788 DetailsInternetPage.activateFromDetails = function() { | 907 DetailsInternetPage.activateFromDetails = function() { |
| 789 var data = $('connection-state').data; | 908 var detailsPage = DetailsInternetPage.getInstance(); |
| 790 var servicePath = data.servicePath; | 909 if (detailsPage.type_ == 'Cellular') { |
| 791 if (data.type == 'Cellular') | 910 chrome.send('networkCommand', |
| 792 chrome.send('networkCommand', [data.type, servicePath, 'activate']); | 911 [detailsPage.type_, detailsPage.servicePath_, 'activate']); |
| 912 } | |
| 793 PageManager.closeOverlay(); | 913 PageManager.closeOverlay(); |
| 794 }; | 914 }; |
| 795 | 915 |
| 796 DetailsInternetPage.setDetails = function() { | 916 DetailsInternetPage.setDetails = function() { |
| 797 var data = $('connection-state').data; | 917 var detailsPage = DetailsInternetPage.getInstance(); |
| 798 var servicePath = data.servicePath; | 918 var type = detailsPage.type_; |
| 799 if (data.type == 'WiFi') { | 919 var servicePath = detailsPage.servicePath_; |
| 920 if (type == 'WiFi') { | |
| 800 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', | 921 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', |
| 801 $('prefer-network-wifi')); | 922 $('prefer-network-wifi')); |
| 802 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 923 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
| 803 $('auto-connect-network-wifi')); | 924 $('auto-connect-network-wifi')); |
| 804 } else if (data.type == 'Wimax') { | 925 } else if (type == 'Wimax') { |
| 805 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 926 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
| 806 $('auto-connect-network-wimax')); | 927 $('auto-connect-network-wimax')); |
| 807 } else if (data.type == 'Cellular') { | 928 } else if (type == 'Cellular') { |
| 808 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 929 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
| 809 $('auto-connect-network-cellular')); | 930 $('auto-connect-network-cellular')); |
| 810 } else if (data.type == 'VPN') { | 931 } else if (type == 'VPN') { |
| 811 chrome.send('setServerHostname', | 932 chrome.send('setServerHostname', |
| 812 [servicePath, | 933 [servicePath, |
| 813 $('inet-server-hostname').value]); | 934 $('inet-server-hostname').value]); |
| 814 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 935 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
| 815 $('auto-connect-network-vpn')); | 936 $('auto-connect-network-vpn')); |
| 816 } | 937 } |
| 817 | 938 |
| 818 var nameServerTypes = ['automatic', 'google', 'user']; | 939 var nameServerTypes = ['automatic', 'google', 'user']; |
| 819 var nameServerType = 'automatic'; | 940 var nameServerType = 'automatic'; |
| 820 for (var i = 0; i < nameServerTypes.length; ++i) { | 941 for (var i = 0; i < nameServerTypes.length; ++i) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 userDns.removeAttribute('selected'); | 992 userDns.removeAttribute('selected'); |
| 872 break; | 993 break; |
| 873 case 'user': | 994 case 'user': |
| 874 automaticDns.removeAttribute('selected'); | 995 automaticDns.removeAttribute('selected'); |
| 875 googleDns.removeAttribute('selected'); | 996 googleDns.removeAttribute('selected'); |
| 876 userDns.setAttribute('selected', ''); | 997 userDns.setAttribute('selected', ''); |
| 877 break; | 998 break; |
| 878 } | 999 } |
| 879 }; | 1000 }; |
| 880 | 1001 |
| 881 DetailsInternetPage.updateConnectionButtonVisibilty = function(onc) { | |
| 882 if (onc.type == 'Ethernet') { | |
| 883 // Ethernet can never be connected or disconnected and can always be | |
| 884 // configured (e.g. to set security). | |
| 885 $('details-internet-login').hidden = true; | |
| 886 $('details-internet-disconnect').hidden = true; | |
| 887 $('details-internet-configure').hidden = false; | |
| 888 return; | |
| 889 } | |
| 890 | |
| 891 var connectState = onc.getActiveValue('ConnectionState'); | |
| 892 if (connectState == 'NotConnected') { | |
| 893 $('details-internet-login').hidden = false; | |
| 894 // Connecting to an unconfigured network might trigger certificate | |
| 895 // installation UI. Until that gets handled here, always enable the | |
| 896 // Connect button. | |
| 897 $('details-internet-login').disabled = false; | |
| 898 $('details-internet-disconnect').hidden = true; | |
| 899 } else { | |
| 900 $('details-internet-login').hidden = true; | |
| 901 $('details-internet-disconnect').hidden = false; | |
| 902 } | |
| 903 | |
| 904 var connectable = onc.getActiveValue('Connectable'); | |
| 905 if (connectState != 'Connected' && | |
| 906 (!connectable || this.hasSecurity || | |
| 907 (onc.type == 'Wimax' || onc.type == 'VPN'))) { | |
| 908 $('details-internet-configure').hidden = false; | |
| 909 } else { | |
| 910 $('details-internet-configure').hidden = true; | |
| 911 } | |
| 912 }; | |
| 913 | |
| 914 DetailsInternetPage.populateHeader = function(detailsPage, onc) { | |
| 915 $('network-details-title').textContent = onc.getTranslatedValue('Name'); | |
| 916 var connectionState = onc.getActiveValue('ConnectionState'); | |
| 917 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | |
| 918 detailsPage.connected = connectionState == 'Connected'; | |
| 919 $('network-details-subtitle-status').textContent = connectionStateString; | |
| 920 var typeKey; | |
| 921 if (onc.type == 'Ethernet') | |
| 922 typeKey = 'ethernetTitle'; | |
| 923 else if (onc.type == 'WiFi') | |
| 924 typeKey = 'wifiTitle'; | |
| 925 else if (onc.type == 'Wimax') | |
| 926 typeKey = 'wimaxTitle'; | |
| 927 else if (onc.type == 'Cellular') | |
| 928 typeKey = 'cellularTitle'; | |
| 929 else if (onc.type == 'VPN') | |
| 930 typeKey = 'vpnTitle'; | |
| 931 else | |
| 932 typeKey = null; | |
| 933 var typeLabel = $('network-details-subtitle-type'); | |
| 934 var typeSeparator = $('network-details-subtitle-separator'); | |
| 935 if (typeKey) { | |
| 936 typeLabel.textContent = loadTimeData.getString(typeKey); | |
| 937 typeLabel.hidden = false; | |
| 938 typeSeparator.hidden = false; | |
| 939 } else { | |
| 940 typeLabel.hidden = true; | |
| 941 typeSeparator.hidden = true; | |
| 942 } | |
| 943 }; | |
| 944 | |
| 945 DetailsInternetPage.updateConnectionData = function(update) { | 1002 DetailsInternetPage.updateConnectionData = function(update) { |
| 946 var detailsPage = DetailsInternetPage.getInstance(); | 1003 var detailsPage = DetailsInternetPage.getInstance(); |
| 947 if (!detailsPage.visible) | 1004 if (!detailsPage.visible) |
| 948 return; | 1005 return; |
| 949 | 1006 |
| 950 var data = $('connection-state').data; | 1007 if (update.servicePath != detailsPage.servicePath_) |
| 951 if (!data) | |
| 952 return; | |
| 953 | |
| 954 if (update.servicePath != data.servicePath) | |
| 955 return; | 1008 return; |
| 956 | 1009 |
| 957 // Update our cached data object. | 1010 // Update our cached data object. |
| 958 updateDataObject(data, update); | 1011 var onc = detailsPage.onc_; |
| 959 var onc = new OncData(data); | 1012 onc.updateData(update); |
| 960 | 1013 |
| 961 this.populateHeader(detailsPage, onc); | 1014 detailsPage.populateHeader_(); |
| 962 | 1015 |
| 963 var connectionState = onc.getActiveValue('ConnectionState'); | 1016 var connectionState = onc.getActiveValue('ConnectionState'); |
| 964 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | 1017 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 965 detailsPage.deviceConnected = data.deviceConnected; | 1018 if ('deviceConnected' in update) |
| 1019 detailsPage.deviceConnected = update.deviceConnected; | |
| 966 detailsPage.connected = connectionState == 'Connected'; | 1020 detailsPage.connected = connectionState == 'Connected'; |
| 967 $('connection-state').textContent = connectionStateString; | 1021 $('connection-state').textContent = connectionStateString; |
| 968 | 1022 |
| 969 this.updateConnectionButtonVisibilty(onc); | 1023 detailsPage.updateConnectionButtonVisibilty_(); |
| 970 | 1024 |
| 971 if (onc.type == 'WiFi') { | 1025 var type = detailsPage.type_; |
| 1026 if (type == 'WiFi') { | |
| 972 $('wifi-connection-state').textContent = connectionStateString; | 1027 $('wifi-connection-state').textContent = connectionStateString; |
| 973 } else if (onc.type == 'Wimax') { | 1028 } else if (type == 'Wimax') { |
| 974 $('wimax-connection-state').textContent = connectionStateString; | 1029 $('wimax-connection-state').textContent = connectionStateString; |
| 975 } else if (onc.type == 'Cellular') { | 1030 } else if (type == 'Cellular') { |
| 976 $('activation-state').textContent = | 1031 $('activation-state').textContent = |
| 977 onc.getTranslatedValue('Cellular.ActivationState'); | 1032 onc.getTranslatedValue('Cellular.ActivationState'); |
| 978 $('buyplan-details').hidden = !data.showBuyButton; | 1033 if ('showBuyButton' in update) |
|
pneubeck (no reviews)
2014/09/08 09:18:00
not sure whether that has the intended effect:
if
stevenjb
2014/09/08 19:43:12
Ugh. So, this variable isn't even used, I'll remov
| |
| 979 $('view-account-details').hidden = !data.showViewAccountButton; | 1034 $('buyplan-details').hidden = !update.showBuyButton; |
| 980 | 1035 if ('showViewAccountButton' in update) |
| 981 $('activate-details').hidden = !data.showActivateButton; | 1036 $('view-account-details').hidden = !update.showViewAccountButton; |
| 982 if (data.showActivateButton) | 1037 if ('showActivateButton' in update) |
| 1038 $('activate-details').hidden = !update.showActivateButton; | |
| 1039 if ('showActivateButton' in update && update.showActivateButton) | |
| 983 $('details-internet-login').hidden = true; | 1040 $('details-internet-login').hidden = true; |
|
pneubeck (no reviews)
2014/09/08 09:18:00
this seems to have been unreliable already in the
stevenjb
2014/09/08 19:43:12
Yeah, I fixed this one here and in showDetailedInf
stevenjb
2014/09/08 21:31:18
Actually, it turns out this overrides 'details-int
| |
| 984 | 1041 |
| 985 if (detailsPage.gsm) { | 1042 if (detailsPage.gsm) { |
| 986 var lockEnabled = | 1043 var lockEnabled = |
| 987 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); | 1044 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); |
| 988 $('sim-card-lock-enabled').checked = lockEnabled; | 1045 $('sim-card-lock-enabled').checked = lockEnabled; |
| 989 $('change-pin').hidden = !lockEnabled; | 1046 $('change-pin').hidden = !lockEnabled; |
| 990 } | 1047 } |
| 991 } | 1048 } |
| 992 | |
| 993 $('connection-state').data = data; | |
| 994 $('connection-state').onc = onc; | |
| 995 }; | 1049 }; |
| 996 | 1050 |
| 997 DetailsInternetPage.showDetailedInfo = function(data) { | 1051 DetailsInternetPage.showDetailedInfo = function(data) { |
| 1052 var onc = new OncData(data); | |
| 1053 | |
| 998 var detailsPage = DetailsInternetPage.getInstance(); | 1054 var detailsPage = DetailsInternetPage.getInstance(); |
| 1055 detailsPage.onc_ = onc; | |
| 1056 var type = onc.getActiveValue('Type'); | |
| 1057 detailsPage.type_ = type; | |
| 1058 detailsPage.servicePath_ = data.servicePath; | |
| 999 | 1059 |
| 1000 var onc = new OncData(data); | 1060 detailsPage.populateHeader_(); |
| 1001 data.type = onc.type; | |
| 1002 | |
| 1003 this.populateHeader(detailsPage, onc); | |
| 1004 | |
| 1005 // TODO(stevenjb): Find a more appropriate place to cache data. | |
| 1006 $('connection-state').data = data; | |
| 1007 $('connection-state').onc = onc; | |
| 1008 | 1061 |
| 1009 $('buyplan-details').hidden = true; | 1062 $('buyplan-details').hidden = true; |
| 1010 $('activate-details').hidden = true; | 1063 $('activate-details').hidden = true; |
| 1011 $('view-account-details').hidden = true; | 1064 $('view-account-details').hidden = true; |
| 1012 | 1065 |
| 1013 this.updateConnectionButtonVisibilty(onc); | 1066 detailsPage.updateConnectionButtonVisibilty_(); |
| 1014 | 1067 |
| 1015 $('web-proxy-auto-discovery').hidden = true; | 1068 $('web-proxy-auto-discovery').hidden = true; |
| 1016 | 1069 |
| 1017 detailsPage.deviceConnected = data.deviceConnected; | 1070 detailsPage.deviceConnected = data.deviceConnected; |
| 1018 detailsPage.connected = | 1071 detailsPage.connected = |
| 1019 onc.getActiveValue('ConnectionState') == 'Connected'; | 1072 onc.getActiveValue('ConnectionState') == 'Connected'; |
| 1020 | 1073 |
| 1021 // Only show proxy for remembered networks. | 1074 // Only show proxy for remembered networks. |
| 1022 if (data.remembered) { | 1075 if (data.remembered) { |
| 1023 detailsPage.showProxy = true; | 1076 detailsPage.showProxy = true; |
| 1024 chrome.send('selectNetwork', [data.servicePath]); | 1077 chrome.send('selectNetwork', [detailsPage.servicePath_]); |
| 1025 } else { | 1078 } else { |
| 1026 detailsPage.showProxy = false; | 1079 detailsPage.showProxy = false; |
| 1027 } | 1080 } |
| 1028 | 1081 |
| 1029 var connectionStateString = onc.getTranslatedValue('ConnectionState'); | 1082 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 1030 $('connection-state').textContent = connectionStateString; | 1083 $('connection-state').textContent = connectionStateString; |
| 1031 var restricted = onc.getActiveValue('RestrictedConnectivity'); | 1084 var restricted = onc.getActiveValue('RestrictedConnectivity'); |
| 1032 var restrictedString = loadTimeData.getString( | 1085 var restrictedString = loadTimeData.getString( |
| 1033 restricted ? 'restrictedYes' : 'restrictedNo'); | 1086 restricted ? 'restrictedYes' : 'restrictedNo'); |
| 1034 | 1087 |
| 1035 var inetAddress = {}; | 1088 var inetAddress = {}; |
| 1036 var inetNetmask = {}; | 1089 var inetNetmask = {}; |
| 1037 var inetGateway = {}; | 1090 var inetGateway = {}; |
| 1038 | 1091 |
| 1039 var inetNameServersString; | 1092 var inetNameServersString; |
| 1040 | 1093 |
| 1041 if ('IPConfigs' in data) { | 1094 var ipconfigList = onc.getActiveValue('IPConfigs'); |
| 1042 var ipconfigList = onc.getActiveValue('IPConfigs'); | 1095 if (Array.isArray(ipconfigList)) { |
| 1043 for (var i = 0; i < ipconfigList.length; ++i) { | 1096 for (var i = 0; i < ipconfigList.length; ++i) { |
| 1044 var ipconfig = ipconfigList[i]; | 1097 var ipconfig = ipconfigList[i]; |
| 1045 var type = ipconfig['Type']; | 1098 var ipType = ipconfig['Type']; |
| 1046 if (type != 'IPv4') { | 1099 if (ipType != 'IPv4') { |
| 1047 // TODO(stevenjb): Handle IPv6 properties. | 1100 // TODO(stevenjb): Handle IPv6 properties. |
| 1048 continue; | 1101 continue; |
| 1049 } | 1102 } |
| 1050 var address = ipconfig['IPAddress']; | 1103 var address = ipconfig['IPAddress']; |
| 1051 inetAddress.automatic = address; | 1104 inetAddress.automatic = address; |
| 1052 inetAddress.value = address; | 1105 inetAddress.value = address; |
| 1053 var netmask = PrefixLengthToNetmask(ipconfig['RoutingPrefix']); | 1106 var netmask = PrefixLengthToNetmask(ipconfig['RoutingPrefix']); |
| 1054 inetNetmask.automatic = netmask; | 1107 inetNetmask.automatic = netmask; |
| 1055 inetNetmask.value = netmask; | 1108 inetNetmask.value = netmask; |
| 1056 var gateway = ipconfig['Gateway']; | 1109 var gateway = ipconfig['Gateway']; |
| 1057 inetGateway.automatic = gateway; | 1110 inetGateway.automatic = gateway; |
| 1058 inetGateway.value = gateway; | 1111 inetGateway.value = gateway; |
| 1059 if ('WebProxyAutoDiscoveryUrl' in ipconfig) { | 1112 if ('WebProxyAutoDiscoveryUrl' in ipconfig) { |
| 1060 $('web-proxy-auto-discovery').hidden = false; | 1113 $('web-proxy-auto-discovery').hidden = false; |
| 1061 $('web-proxy-auto-discovery-url').value = | 1114 $('web-proxy-auto-discovery-url').value = |
| 1062 ipconfig['WebProxyAutoDiscoveryUrl']; | 1115 ipconfig['WebProxyAutoDiscoveryUrl']; |
| 1063 } | 1116 } |
| 1064 if ('NameServers' in ipconfig) { | 1117 if ('NameServers' in ipconfig) { |
| 1065 var inetNameServers = ipconfig['NameServers']; | 1118 var inetNameServers = ipconfig['NameServers']; |
| 1066 inetNameServers = inetNameServers.sort(); | 1119 inetNameServers = inetNameServers.sort(); |
| 1067 inetNameServersString = inetNameServers.join(','); | 1120 inetNameServersString = inetNameServers.join(','); |
| 1068 } | 1121 } |
| 1069 break; // Use the first IPv4 entry. | 1122 break; // Use the first IPv4 entry. |
| 1070 } | 1123 } |
| 1071 } | 1124 } |
| 1072 | 1125 |
| 1073 // Override the "automatic" values with the real saved DHCP values, | 1126 // Override the "automatic" values with the real saved DHCP values, |
| 1074 // if they are set. | 1127 // if they are set. |
| 1075 var savedNameServersString; | 1128 var savedNameServersString; |
| 1076 if ('SavedIPConfig' in data) { | 1129 var savedIpAddress = onc.getActiveValue('SavedIPConfig.IPAddress'); |
| 1077 var savedIpAddress = onc.getActiveValue('SavedIPConfig.IPAddress'); | 1130 if (savedIpAddress != undefined) { |
| 1078 if (savedIpAddress != undefined) { | 1131 inetAddress.automatic = savedIpAddress; |
| 1079 inetAddress.automatic = savedIpAddress; | 1132 inetAddress.value = savedIpAddress; |
| 1080 inetAddress.value = savedIpAddress; | 1133 } |
| 1081 } | 1134 var savedPrefix = onc.getActiveValue('SavedIPConfig.RoutingPrefix'); |
| 1082 var savedPrefix = onc.getActiveValue('SavedIPConfig.RoutingPrefix'); | 1135 if (savedPrefix != undefined) { |
| 1083 if (savedPrefix != undefined) { | 1136 var savedNetmask = PrefixLengthToNetmask(savedPrefix); |
| 1084 var savedNetmask = PrefixLengthToNetmask(savedPrefix); | 1137 inetNetmask.automatic = savedNetmask; |
| 1085 inetNetmask.automatic = savedNetmask; | 1138 inetNetmask.value = savedNetmask; |
| 1086 inetNetmask.value = savedNetmask; | 1139 } |
| 1087 } | 1140 var savedGateway = onc.getActiveValue('SavedIPConfig.Gateway'); |
| 1088 var savedGateway = onc.getActiveValue('SavedIPConfig.Gateway'); | 1141 if (savedGateway != undefined) { |
| 1089 if (savedGateway != undefined) { | 1142 inetGateway.automatic = savedGateway; |
| 1090 inetGateway.automatic = savedGateway; | 1143 inetGateway.value = savedGateway; |
| 1091 inetGateway.value = savedGateway; | 1144 } |
| 1092 } | 1145 var savedNameServers = onc.getActiveValue('SavedIPConfig.NameServers'); |
| 1093 var savedNameServers = onc.getActiveValue('SavedIPConfig.NameServers'); | 1146 if (savedNameServers) { |
| 1094 if (savedNameServers) { | 1147 savedNameServers = savedNameServers.sort(); |
| 1095 savedNameServers = savedNameServers.sort(); | 1148 savedNameServersString = savedNameServers.join(','); |
| 1096 savedNameServersString = savedNameServers.join(','); | |
| 1097 } | |
| 1098 } | 1149 } |
| 1099 | 1150 |
| 1100 var ipAutoConfig = 'automatic'; | 1151 var ipAutoConfig = 'automatic'; |
| 1101 | 1152 |
| 1102 var staticNameServersString; | 1153 var staticNameServersString; |
| 1103 if ('StaticIPConfig' in data) { | 1154 var staticIpAddress = onc.getActiveValue('StaticIPConfig.IPAddress'); |
| 1104 var staticIpAddress = onc.getActiveValue('StaticIPConfig.IPAddress'); | 1155 if (staticIpAddress != undefined) { |
| 1105 if (staticIpAddress != undefined) { | 1156 ipAutoConfig = 'user'; |
| 1106 ipAutoConfig = 'user'; | 1157 inetAddress.user = staticIpAddress; |
| 1107 inetAddress.user = staticIpAddress; | 1158 inetAddress.value = staticIpAddress; |
| 1108 inetAddress.value = staticIpAddress; | 1159 } |
| 1109 } | 1160 var staticPrefix = onc.getActiveValue('StaticIPConfig.RoutingPrefix'); |
| 1110 var staticPrefix = onc.getActiveValue('StaticIPConfig.RoutingPrefix'); | 1161 if (staticPrefix != undefined) { |
| 1111 if (staticPrefix != undefined) { | 1162 var staticNetmask = PrefixLengthToNetmask(staticPrefix); |
| 1112 var staticNetmask = PrefixLengthToNetmask(staticPrefix); | 1163 inetNetmask.user = staticNetmask; |
| 1113 inetNetmask.user = staticNetmask; | 1164 inetNetmask.value = staticNetmask; |
| 1114 inetNetmask.value = staticNetmask; | 1165 } |
| 1115 } | 1166 var staticGateway = onc.getActiveValue('StaticIPConfig.Gateway'); |
| 1116 var staticGateway = onc.getActiveValue('StaticIPConfig.Gateway'); | 1167 if (staticGateway != undefined) { |
| 1117 if (staticGateway != undefined) { | 1168 inetGateway.user = staticGateway; |
| 1118 inetGateway.user = staticGateway; | 1169 inetGateway.value = staticGateway; |
| 1119 inetGateway.value = staticGateway; | 1170 } |
| 1120 } | 1171 var staticNameServers = onc.getActiveValue('StaticIPConfig.NameServers'); |
| 1121 var staticNameServers = onc.getActiveValue('StaticIPConfig.NameServers'); | 1172 if (staticNameServers) { |
| 1122 if (staticNameServers) { | 1173 staticNameServers = staticNameServers.sort(); |
| 1123 staticNameServers = staticNameServers.sort(); | 1174 staticNameServersString = staticNameServers.join(','); |
| 1124 staticNameServersString = staticNameServers.join(','); | |
| 1125 } | |
| 1126 } | 1175 } |
| 1127 | 1176 |
| 1128 $('ip-automatic-configuration-checkbox').checked = | 1177 $('ip-automatic-configuration-checkbox').checked = |
| 1129 ipAutoConfig == 'automatic'; | 1178 ipAutoConfig == 'automatic'; |
| 1130 | 1179 |
| 1131 inetAddress.autoConfig = ipAutoConfig; | 1180 inetAddress.autoConfig = ipAutoConfig; |
| 1132 inetNetmask.autoConfig = ipAutoConfig; | 1181 inetNetmask.autoConfig = ipAutoConfig; |
| 1133 inetGateway.autoConfig = ipAutoConfig; | 1182 inetGateway.autoConfig = ipAutoConfig; |
| 1134 | 1183 |
| 1135 var configureAddressField = function(field, model) { | 1184 var configureAddressField = function(field, model) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 $(field).parentElement.hidden = false; | 1233 $(field).parentElement.hidden = false; |
| 1185 } else { | 1234 } else { |
| 1186 $(field).parentElement.hidden = true; | 1235 $(field).parentElement.hidden = true; |
| 1187 } | 1236 } |
| 1188 }; | 1237 }; |
| 1189 | 1238 |
| 1190 var networkName = onc.getTranslatedValue('Name'); | 1239 var networkName = onc.getTranslatedValue('Name'); |
| 1191 | 1240 |
| 1192 // Signal strength as percentage (for WiFi and Wimax). | 1241 // Signal strength as percentage (for WiFi and Wimax). |
| 1193 var signalStrength; | 1242 var signalStrength; |
| 1194 if (onc.type == 'WiFi' || onc.type == 'Wimax') { | 1243 if (type == 'WiFi' || type == 'Wimax') |
| 1195 signalStrength = onc.getActiveValue(onc.type + '.SignalStrength'); | 1244 signalStrength = onc.getActiveValue(type + '.SignalStrength'); |
| 1196 } | |
| 1197 if (!signalStrength) | 1245 if (!signalStrength) |
| 1198 signalStrength = 0; | 1246 signalStrength = 0; |
| 1199 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1247 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
| 1200 var strengthString = strengthFormat.replace('$1', signalStrength); | 1248 var strengthString = strengthFormat.replace('$1', signalStrength); |
| 1201 | 1249 |
| 1202 detailsPage.type = onc.type; | 1250 if (type == 'WiFi') { |
| 1203 if (onc.type == 'WiFi') { | |
| 1204 OptionsPage.showTab($('wifi-network-nav-tab')); | 1251 OptionsPage.showTab($('wifi-network-nav-tab')); |
| 1205 detailsPage.gsm = false; | 1252 detailsPage.gsm = false; |
| 1206 detailsPage.shared = data.shared; | 1253 detailsPage.shared = data.shared; |
| 1207 $('wifi-connection-state').textContent = connectionStateString; | 1254 $('wifi-connection-state').textContent = connectionStateString; |
| 1208 $('wifi-restricted-connectivity').textContent = restrictedString; | 1255 $('wifi-restricted-connectivity').textContent = restrictedString; |
| 1209 var ssid = onc.getActiveValue('WiFi.SSID'); | 1256 var ssid = onc.getActiveValue('WiFi.SSID'); |
| 1210 $('wifi-ssid').textContent = ssid ? ssid : networkName; | 1257 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
| 1211 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); | 1258 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); |
| 1212 var security = onc.getActiveValue('WiFi.Security'); | 1259 var security = onc.getActiveValue('WiFi.Security'); |
| 1213 if (security == 'None') | 1260 if (security == 'None') |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1224 setOrHideParent('wifi-hardware-address', | 1271 setOrHideParent('wifi-hardware-address', |
| 1225 onc.getActiveValue('MacAddress')); | 1272 onc.getActiveValue('MacAddress')); |
| 1226 detailsPage.showPreferred = data.remembered; | 1273 detailsPage.showPreferred = data.remembered; |
| 1227 var priority = onc.getActiveValue('Priority'); | 1274 var priority = onc.getActiveValue('Priority'); |
| 1228 $('prefer-network-wifi').checked = priority > 0; | 1275 $('prefer-network-wifi').checked = priority > 0; |
| 1229 $('prefer-network-wifi').disabled = !data.remembered; | 1276 $('prefer-network-wifi').disabled = !data.remembered; |
| 1230 $('auto-connect-network-wifi').checked = | 1277 $('auto-connect-network-wifi').checked = |
| 1231 onc.getActiveValue('AutoConnect'); | 1278 onc.getActiveValue('AutoConnect'); |
| 1232 $('auto-connect-network-wifi').disabled = !data.remembered; | 1279 $('auto-connect-network-wifi').disabled = !data.remembered; |
| 1233 detailsPage.hasSecurity = security != undefined; | 1280 detailsPage.hasSecurity = security != undefined; |
| 1234 } else if (onc.type == 'Wimax') { | 1281 } else if (type == 'Wimax') { |
| 1235 OptionsPage.showTab($('wimax-network-nav-tab')); | 1282 OptionsPage.showTab($('wimax-network-nav-tab')); |
| 1236 detailsPage.gsm = false; | 1283 detailsPage.gsm = false; |
| 1237 detailsPage.shared = data.shared; | 1284 detailsPage.shared = data.shared; |
| 1238 detailsPage.showPreferred = data.remembered; | 1285 detailsPage.showPreferred = data.remembered; |
| 1239 $('wimax-connection-state').textContent = connectionStateString; | 1286 $('wimax-connection-state').textContent = connectionStateString; |
| 1240 $('wimax-restricted-connectivity').textContent = restrictedString; | 1287 $('wimax-restricted-connectivity').textContent = restrictedString; |
| 1241 $('auto-connect-network-wimax').checked = | 1288 $('auto-connect-network-wimax').checked = |
| 1242 onc.getActiveValue('AutoConnect'); | 1289 onc.getActiveValue('AutoConnect'); |
| 1243 $('auto-connect-network-wimax').disabled = !data.remembered; | 1290 $('auto-connect-network-wimax').disabled = !data.remembered; |
| 1244 var identity = onc.getActiveValue('Wimax.EAP.Identity'); | 1291 var identity = onc.getActiveValue('Wimax.EAP.Identity'); |
| 1245 setOrHideParent('wimax-eap-identity', identity); | 1292 setOrHideParent('wimax-eap-identity', identity); |
| 1246 $('wimax-signal-strength').textContent = strengthString; | 1293 $('wimax-signal-strength').textContent = strengthString; |
| 1247 } else if (onc.type == 'Cellular') { | 1294 } else if (type == 'Cellular') { |
| 1248 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1295 OptionsPage.showTab($('cellular-conn-nav-tab')); |
| 1249 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1296 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
| 1250 var carrierSelector = $('select-carrier'); | 1297 var carrierSelector = $('select-carrier'); |
| 1251 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1298 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
| 1252 carrierSelector.options.length = 0; | 1299 carrierSelector.options.length = 0; |
| 1253 for (var i = 0; i < data.carriers.length; ++i) { | 1300 for (var i = 0; i < data.carriers.length; ++i) { |
| 1254 var option = document.createElement('option'); | 1301 var option = document.createElement('option'); |
| 1255 option.textContent = data.carriers[i]; | 1302 option.textContent = data.carriers[i]; |
| 1256 carrierSelector.add(option); | 1303 carrierSelector.add(option); |
| 1257 } | 1304 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI')); | 1347 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI')); |
| 1301 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID')); | 1348 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID')); |
| 1302 setOrHideParent('min', onc.getActiveValue('Cellular.MIN')); | 1349 setOrHideParent('min', onc.getActiveValue('Cellular.MIN')); |
| 1303 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion')); | 1350 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion')); |
| 1304 | 1351 |
| 1305 var family = onc.getActiveValue('Cellular.Family'); | 1352 var family = onc.getActiveValue('Cellular.Family'); |
| 1306 detailsPage.gsm = family == 'GSM'; | 1353 detailsPage.gsm = family == 'GSM'; |
| 1307 if (detailsPage.gsm) { | 1354 if (detailsPage.gsm) { |
| 1308 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); | 1355 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); |
| 1309 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); | 1356 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); |
| 1310 | 1357 detailsPage.initializeApnList_(onc); |
| 1311 var apnSelector = $('select-apn'); | |
| 1312 // Clear APN lists, keep only last element that "other". | |
| 1313 while (apnSelector.length != 1) | |
| 1314 apnSelector.remove(0); | |
| 1315 var otherOption = apnSelector[0]; | |
| 1316 data.selectedApn = -1; | |
| 1317 data.userApnIndex = -1; | |
| 1318 var activeApn = onc.getActiveValue('Cellular.APN.AccessPointName'); | |
| 1319 var activeUsername = onc.getActiveValue('Cellular.APN.Username'); | |
| 1320 var activePassword = onc.getActiveValue('Cellular.APN.Password'); | |
| 1321 var lastGoodApn = | |
| 1322 onc.getActiveValue('Cellular.LastGoodAPN.AccessPointName'); | |
| 1323 var lastGoodUsername = | |
| 1324 onc.getActiveValue('Cellular.LastGoodAPN.Username'); | |
| 1325 var lastGoodPassword = | |
| 1326 onc.getActiveValue('Cellular.LastGoodAPN.Password'); | |
| 1327 var apnList = onc.getActiveValue('Cellular.APNList'); | |
| 1328 for (var i = 0; i < apnList.length; i++) { | |
| 1329 var apnDict = apnList[i]; | |
| 1330 var option = document.createElement('option'); | |
| 1331 var localizedName = apnDict['LocalizedName']; | |
| 1332 var name = localizedName ? localizedName : apnDict['Name']; | |
| 1333 var accessPointName = apnDict['AccessPointName']; | |
| 1334 option.textContent = | |
| 1335 name ? (name + ' (' + accessPointName + ')') : accessPointName; | |
| 1336 option.value = i; | |
| 1337 // If this matches the active Apn, or LastGoodApn, set it as the | |
| 1338 // selected Apn. | |
| 1339 if ((activeApn == accessPointName && | |
| 1340 activeUsername == apnDict['Username'] && | |
| 1341 activePassword == apnDict['Password']) || | |
| 1342 (!activeApn && | |
| 1343 lastGoodApn == accessPointName && | |
| 1344 lastGoodUsername == apnDict['Username'] && | |
| 1345 lastGoodPassword == apnDict['Password'])) { | |
| 1346 data.selectedApn = i; | |
| 1347 } | |
| 1348 // Insert new option before "other" option. | |
| 1349 apnSelector.add(option, otherOption); | |
| 1350 } | |
| 1351 if (data.selectedApn == -1 && activeApn) { | |
| 1352 var option = document.createElement('option'); | |
| 1353 option.textContent = activeApn; | |
| 1354 option.value = -1; | |
| 1355 apnSelector.add(option, otherOption); | |
| 1356 data.selectedApn = apnSelector.length - 2; | |
| 1357 data.userApnIndex = data.selectedApn; | |
| 1358 } | |
| 1359 apnSelector.selectedIndex = data.selectedApn; | |
| 1360 updateHidden('.apn-list-view', false); | |
| 1361 updateHidden('.apn-details-view', true); | |
| 1362 var lockEnabled = | 1358 var lockEnabled = |
| 1363 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); | 1359 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); |
| 1364 $('sim-card-lock-enabled').checked = lockEnabled; | 1360 $('sim-card-lock-enabled').checked = lockEnabled; |
| 1365 $('change-pin').hidden = !lockEnabled; | 1361 $('change-pin').hidden = !lockEnabled; |
| 1366 } | 1362 } |
| 1367 $('auto-connect-network-cellular').checked = | 1363 $('auto-connect-network-cellular').checked = |
| 1368 onc.getActiveValue('AutoConnect'); | 1364 onc.getActiveValue('AutoConnect'); |
| 1369 $('auto-connect-network-cellular').disabled = false; | 1365 $('auto-connect-network-cellular').disabled = false; |
| 1370 | 1366 |
| 1371 $('buyplan-details').hidden = !data.showBuyButton; | 1367 $('buyplan-details').hidden = !data.showBuyButton; |
| 1372 $('view-account-details').hidden = !data.showViewAccountButton; | 1368 $('view-account-details').hidden = !data.showViewAccountButton; |
| 1373 $('activate-details').hidden = !data.showActivateButton; | 1369 $('activate-details').hidden = !data.showActivateButton; |
| 1374 if (data.showActivateButton) { | 1370 if (data.showActivateButton) { |
| 1375 $('details-internet-login').hidden = true; | 1371 $('details-internet-login').hidden = true; |
| 1376 } | 1372 } |
| 1377 } else if (onc.type == 'VPN') { | 1373 } else if (type == 'VPN') { |
| 1378 OptionsPage.showTab($('vpn-nav-tab')); | 1374 OptionsPage.showTab($('vpn-nav-tab')); |
| 1379 detailsPage.gsm = false; | 1375 detailsPage.gsm = false; |
| 1380 $('inet-service-name').textContent = networkName; | 1376 $('inet-service-name').textContent = networkName; |
| 1381 $('inet-provider-type').textContent = | 1377 $('inet-provider-type').textContent = |
| 1382 onc.getTranslatedValue('VPN.Type'); | 1378 onc.getTranslatedValue('VPN.Type'); |
| 1383 var providerType = onc.getActiveValue('VPN.Type'); | 1379 var providerType = onc.getActiveValue('VPN.Type'); |
| 1384 var providerKey = 'VPN.' + providerType; | 1380 var providerKey = 'VPN.' + providerType; |
| 1385 $('inet-username').textContent = | 1381 $('inet-username').textContent = |
| 1386 onc.getActiveValue(providerKey + '.Username'); | 1382 onc.getActiveValue(providerKey + '.Username'); |
| 1387 var inetServerHostname = $('inet-server-hostname'); | 1383 var inetServerHostname = $('inet-server-hostname'); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1421 indicators[i].handlePrefChange(event); | 1417 indicators[i].handlePrefChange(event); |
| 1422 var forElement = $(indicators[i].getAttribute('for')); | 1418 var forElement = $(indicators[i].getAttribute('for')); |
| 1423 if (forElement) { | 1419 if (forElement) { |
| 1424 if (event.value.controlledBy == 'policy') | 1420 if (event.value.controlledBy == 'policy') |
| 1425 forElement.disabled = true; | 1421 forElement.disabled = true; |
| 1426 if (forElement.resetHandler) | 1422 if (forElement.resetHandler) |
| 1427 indicators[i].resetHandler = forElement.resetHandler; | 1423 indicators[i].resetHandler = forElement.resetHandler; |
| 1428 } | 1424 } |
| 1429 } | 1425 } |
| 1430 | 1426 |
| 1431 detailsPage.updateControls(); | 1427 detailsPage.updateControls_(); |
| 1432 | 1428 |
| 1433 // Don't show page name in address bar and in history to prevent people | 1429 // Don't show page name in address bar and in history to prevent people |
| 1434 // navigate here by hand and solve issue with page session restore. | 1430 // navigate here by hand and solve issue with page session restore. |
| 1435 PageManager.showPageByName('detailsInternetPage', false); | 1431 PageManager.showPageByName('detailsInternetPage', false); |
| 1436 }; | 1432 }; |
| 1437 | 1433 |
| 1438 return { | 1434 return { |
| 1439 DetailsInternetPage: DetailsInternetPage | 1435 DetailsInternetPage: DetailsInternetPage |
| 1440 }; | 1436 }; |
| 1441 }); | 1437 }); |
| OLD | NEW |