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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 cr.define('options.internet', function() { 5 cr.define('options.internet', function() {
6 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
8 /** @const */ var IPAddressField = options.internet.IPAddressField; 8 /** @const */ var IPAddressField = options.internet.IPAddressField;
9 9
10 /** 10 /**
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 updateHidden('.apn-details-view', true); 182 updateHidden('.apn-details-view', true);
183 }); 183 });
184 184
185 $('cellular-apn-set').addEventListener('click', function(event) { 185 $('cellular-apn-set').addEventListener('click', function(event) {
186 if ($('cellular-apn').value == '') 186 if ($('cellular-apn').value == '')
187 return; 187 return;
188 188
189 var data = $('connection-state').data; 189 var data = $('connection-state').data;
190 var apnSelector = $('select-apn'); 190 var apnSelector = $('select-apn');
191 191
192 data.apn.apn = String($('cellular-apn').value); 192 var apn = {
193 data.apn.username = String($('cellular-apn-username').value); 193 'apn': $('cellular-apn').value,
194 data.apn.password = String($('cellular-apn-password').value); 194 'username': $('cellular-apn-username').value,
195 'password': $('cellular-apn-password').value
196 };
197 data.apn.apn = apn.apn ? String(apn.apn) : '';
198 data.apn.username = apn.username ? String(apn.username) : '';
199 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.
195 chrome.send('setApn', [data.servicePath, 200 chrome.send('setApn', [data.servicePath,
196 String(data.apn.apn), 201 data.apn.apn,
197 String(data.apn.username), 202 data.apn.username,
198 String(data.apn.password)]); 203 data.apn.password]);
199 204
200 if (data.userApnIndex != -1) { 205 if (data.userApnIndex != -1) {
201 apnSelector.remove(data.userApnIndex); 206 apnSelector.remove(data.userApnIndex);
202 data.userApnIndex = -1; 207 data.userApnIndex = -1;
203 } 208 }
204 209
205 var option = document.createElement('option'); 210 var option = document.createElement('option');
206 option.textContent = data.apn.apn; 211 option.textContent = data.apn.apn;
207 option.value = -1; 212 option.value = -1;
208 option.selected = true; 213 option.selected = true;
209 apnSelector.add(option, apnSelector[apnSelector.length - 1]); 214 apnSelector.add(option, apnSelector[apnSelector.length - 1]);
210 data.userApnIndex = apnSelector.length - 2; 215 data.userApnIndex = apnSelector.length - 2;
211 data.selectedApn = data.userApnIndex; 216 data.selectedApn = data.userApnIndex;
212 217
213 updateHidden('.apn-list-view', false); 218 updateHidden('.apn-list-view', false);
214 updateHidden('.apn-details-view', true); 219 updateHidden('.apn-details-view', true);
215 }); 220 });
216 221
217 $('cellular-apn-cancel').addEventListener('click', function(event) { 222 $('cellular-apn-cancel').addEventListener('click', function(event) {
218 $('select-apn').selectedIndex = $('connection-state').data.selectedApn; 223 $('select-apn').selectedIndex = $('connection-state').data.selectedApn;
219 updateHidden('.apn-list-view', false); 224 updateHidden('.apn-list-view', false);
220 updateHidden('.apn-details-view', true); 225 updateHidden('.apn-details-view', true);
221 }); 226 });
222 227
223 $('select-apn').addEventListener('change', function(event) { 228 $('select-apn').addEventListener('change', function(event) {
224 var data = $('connection-state').data; 229 var data = $('connection-state').data;
225 var apnSelector = $('select-apn'); 230 var apnSelector = $('select-apn');
231 var sanitizeApn = function(apn) {
232 return {
233 'apn': apn.apn ? apn.apn : '',
234 'username': apn.username ? apn.username : '',
235 'password': apn.password ? apn.password : ''
236 };
237 };
stevenjb 2013/08/30 16:34:05 Rather than using this, could just use StringFromF
armansito 2013/08/30 23:55:20 Done.
226 if (apnSelector[apnSelector.selectedIndex].value != -1) { 238 if (apnSelector[apnSelector.selectedIndex].value != -1) {
227 var apnList = data.providerApnList.value; 239 var apnList = data.providerApnList.value;
240 var apnToSet = sanitizeApn(apnList[apnSelector.selectedIndex]);
228 chrome.send('setApn', [data.servicePath, 241 chrome.send('setApn', [data.servicePath,
229 String(apnList[apnSelector.selectedIndex].apn), 242 String(apnToSet.apn),
230 String(apnList[apnSelector.selectedIndex].username), 243 String(apnToSet.username),
231 String(apnList[apnSelector.selectedIndex].password) 244 String(apnToSet.password)]);
232 ]);
233 data.selectedApn = apnSelector.selectedIndex; 245 data.selectedApn = apnSelector.selectedIndex;
234 } else if (apnSelector.selectedIndex == data.userApnIndex) { 246 } else if (apnSelector.selectedIndex == data.userApnIndex) {
247 var apnToSet = sanitizeApn(data.apn);
235 chrome.send('setApn', [data.servicePath, 248 chrome.send('setApn', [data.servicePath,
236 String(data.apn.apn), 249 String(apnToSet.apn),
237 String(data.apn.username), 250 String(apnToSet.username),
238 String(data.apn.password)]); 251 String(apnToSet.password)]);
239 data.selectedApn = apnSelector.selectedIndex; 252 data.selectedApn = apnSelector.selectedIndex;
240 } else { 253 } else {
241 $('cellular-apn').value = data.apn.apn; 254 var apnToSet = sanitizeApn(data.apn);
242 var username = data.apn.username; 255 $('cellular-apn').value = apnToSet.apn;
243 var password = data.apn.password; 256 $('cellular-apn-username').value = apnToSet.username;
244 $('cellular-apn-username').value = username ? username : ''; 257 $('cellular-apn-password').value = apnToSet.password;
245 $('cellular-apn-password').value = password ? password : '';
246 258
247 updateHidden('.apn-list-view', true); 259 updateHidden('.apn-list-view', true);
248 updateHidden('.apn-details-view', false); 260 updateHidden('.apn-details-view', false);
249 } 261 }
250 }); 262 });
251 263
252 $('sim-card-lock-enabled').addEventListener('click', function(event) { 264 $('sim-card-lock-enabled').addEventListener('click', function(event) {
253 var newValue = $('sim-card-lock-enabled').checked; 265 var newValue = $('sim-card-lock-enabled').checked;
254 // Leave value as is because user needs to enter PIN code first. 266 // Leave value as is because user needs to enter PIN code first.
255 // When PIN will be entered and value changed, 267 // When PIN will be entered and value changed,
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 1252
1241 // Don't show page name in address bar and in history to prevent people 1253 // Don't show page name in address bar and in history to prevent people
1242 // navigate here by hand and solve issue with page session restore. 1254 // navigate here by hand and solve issue with page session restore.
1243 OptionsPage.showPageByName('detailsInternetPage', false); 1255 OptionsPage.showPageByName('detailsInternetPage', false);
1244 }; 1256 };
1245 1257
1246 return { 1258 return {
1247 DetailsInternetPage: DetailsInternetPage 1259 DetailsInternetPage: DetailsInternetPage
1248 }; 1260 };
1249 }); 1261 });
OLDNEW
« 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