Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4791)

Unified Diff: chrome/browser/resources/options/chromeos/internet_detail.js

Issue 23629010: internet_detail.js: Handle undefined APN fields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/chromeos/internet_detail.js
diff --git a/chrome/browser/resources/options/chromeos/internet_detail.js b/chrome/browser/resources/options/chromeos/internet_detail.js
index 05958eb6a3a4f721c24a92a20c708c7a090311b0..662163c867bfeee560538437e90eacb02837da10 100644
--- a/chrome/browser/resources/options/chromeos/internet_detail.js
+++ b/chrome/browser/resources/options/chromeos/internet_detail.js
@@ -189,13 +189,18 @@ cr.define('options.internet', function() {
var data = $('connection-state').data;
var apnSelector = $('select-apn');
- data.apn.apn = String($('cellular-apn').value);
- data.apn.username = String($('cellular-apn-username').value);
- data.apn.password = String($('cellular-apn-password').value);
+ var apn = {
+ 'apn': $('cellular-apn').value,
+ 'username': $('cellular-apn-username').value,
+ 'password': $('cellular-apn-password').value
+ };
+ data.apn.apn = apn.apn ? String(apn.apn) : '';
+ data.apn.username = apn.username ? String(apn.username) : '';
+ data.apn.password = apn.password ? String(apn.password) : '';
stevenjb 2013/08/30 16:34:05 Seems like this could all be simplified with a hel
armansito 2013/08/30 23:55:20 Done.
chrome.send('setApn', [data.servicePath,
- String(data.apn.apn),
- String(data.apn.username),
- String(data.apn.password)]);
+ data.apn.apn,
+ data.apn.username,
+ data.apn.password]);
if (data.userApnIndex != -1) {
apnSelector.remove(data.userApnIndex);
@@ -223,26 +228,33 @@ cr.define('options.internet', function() {
$('select-apn').addEventListener('change', function(event) {
var data = $('connection-state').data;
var apnSelector = $('select-apn');
+ var sanitizeApn = function(apn) {
+ return {
+ 'apn': apn.apn ? apn.apn : '',
+ 'username': apn.username ? apn.username : '',
+ 'password': apn.password ? apn.password : ''
+ };
+ };
stevenjb 2013/08/30 16:34:05 Rather than using this, could just use StringFromF
armansito 2013/08/30 23:55:20 Done.
if (apnSelector[apnSelector.selectedIndex].value != -1) {
var apnList = data.providerApnList.value;
+ var apnToSet = sanitizeApn(apnList[apnSelector.selectedIndex]);
chrome.send('setApn', [data.servicePath,
- String(apnList[apnSelector.selectedIndex].apn),
- String(apnList[apnSelector.selectedIndex].username),
- String(apnList[apnSelector.selectedIndex].password)
- ]);
+ String(apnToSet.apn),
+ String(apnToSet.username),
+ String(apnToSet.password)]);
data.selectedApn = apnSelector.selectedIndex;
} else if (apnSelector.selectedIndex == data.userApnIndex) {
+ var apnToSet = sanitizeApn(data.apn);
chrome.send('setApn', [data.servicePath,
- String(data.apn.apn),
- String(data.apn.username),
- String(data.apn.password)]);
+ String(apnToSet.apn),
+ String(apnToSet.username),
+ String(apnToSet.password)]);
data.selectedApn = apnSelector.selectedIndex;
} else {
- $('cellular-apn').value = data.apn.apn;
- var username = data.apn.username;
- var password = data.apn.password;
- $('cellular-apn-username').value = username ? username : '';
- $('cellular-apn-password').value = password ? password : '';
+ var apnToSet = sanitizeApn(data.apn);
+ $('cellular-apn').value = apnToSet.apn;
+ $('cellular-apn-username').value = apnToSet.username;
+ $('cellular-apn-password').value = apnToSet.password;
updateHidden('.apn-list-view', true);
updateHidden('.apn-details-view', false);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698