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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
8 var ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 9 |
10 /** | 10 /** |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 */ | 372 */ |
373 receiveExistingSupervisedUsers_: function(supervisedUsers) { | 373 receiveExistingSupervisedUsers_: function(supervisedUsers) { |
374 $('import-existing-supervised-user-link').hidden = | 374 $('import-existing-supervised-user-link').hidden = |
375 supervisedUsers.length === 0; | 375 supervisedUsers.length === 0; |
376 if (!$('create-profile-supervised').checked) | 376 if (!$('create-profile-supervised').checked) |
377 return; | 377 return; |
378 | 378 |
379 var newName = $('create-profile-name').value; | 379 var newName = $('create-profile-name').value; |
380 var i; | 380 var i; |
381 for (i = 0; i < supervisedUsers.length; ++i) { | 381 for (i = 0; i < supervisedUsers.length; ++i) { |
382 if (supervisedUsers[i].name == newName && | 382 if (supervisedUsers[i].name == newName) { |
383 !supervisedUsers[i].onCurrentDevice) { | |
384 var errorHtml = loadTimeData.getStringF( | |
385 'manageProfilesExistingSupervisedUser', | |
386 HTMLEscape(elide(newName, /* maxLength */ 50))); | |
387 this.showErrorBubble_(errorHtml, 'create', true); | |
388 | |
389 // Check if another supervised user also exists with that name. | 383 // Check if another supervised user also exists with that name. |
390 var nameIsUnique = true; | 384 var nameIsUnique = true; |
385 var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice; | |
Marc Treib
2015/12/10 11:36:41
I think this is worth a comment: You're handling t
Pam (message me for reviews)
2015/12/15 14:31:37
It can happen if the first SU with that name hasn'
atanasova
2015/12/15 17:57:36
I added a comment to explain this case. It can hap
| |
391 var j; | 386 var j; |
392 for (j = i + 1; j < supervisedUsers.length; ++j) { | 387 for (j = i + 1; j < supervisedUsers.length; ++j) { |
393 if (supervisedUsers[j].name == newName) { | 388 if (supervisedUsers[j].name == newName) { |
394 nameIsUnique = false; | 389 nameIsUnique = false; |
395 break; | 390 allOnCurrentDevice = allOnCurrentDevice && |
391 supervisedUsers[j].onCurrentDevice; | |
396 } | 392 } |
397 } | 393 } |
394 | |
395 var errorHtml = allOnCurrentDevice ? | |
396 loadTimeData.getStringF( | |
397 'managedProfilesExistingLocalSupervisedUser') : | |
398 loadTimeData.getStringF( | |
399 'manageProfilesExistingSupervisedUser', | |
400 HTMLEscape(elide(newName, /* maxLength */ 50))); | |
401 this.showErrorBubble_(errorHtml, 'create', true); | |
402 | |
398 $('supervised-user-import-existing').onclick = | 403 $('supervised-user-import-existing').onclick = |
399 this.getImportHandler_(supervisedUsers[i], nameIsUnique); | 404 this.getImportHandler_(supervisedUsers[i], nameIsUnique); |
400 $('create-profile-ok').disabled = true; | 405 $('create-profile-ok').disabled = true; |
401 return; | 406 return; |
402 } | 407 } |
403 } | 408 } |
404 }, | 409 }, |
405 | 410 |
406 /** | 411 /** |
407 * Called in case the request for the list of supervised users fails because | 412 * Called in case the request for the list of supervised users fails because |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 'updateSignedInStatus', | 866 'updateSignedInStatus', |
862 'updateSupervisedUsersAllowed', | 867 'updateSupervisedUsersAllowed', |
863 ]); | 868 ]); |
864 | 869 |
865 // Export | 870 // Export |
866 return { | 871 return { |
867 ManageProfileOverlay: ManageProfileOverlay, | 872 ManageProfileOverlay: ManageProfileOverlay, |
868 CreateProfileOverlay: CreateProfileOverlay, | 873 CreateProfileOverlay: CreateProfileOverlay, |
869 }; | 874 }; |
870 }); | 875 }); |
OLD | NEW |