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 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) { |
|
Marc Treib
2015/12/16 09:26:54
optional nit: You could say
if (supervisedUsers[i]
atanasova
2015/12/16 14:35:37
Done.
| |
| 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 // Handling the case when multiple supervised users with the same | |
| 386 // name exist, but not all of them are on the device. | |
| 387 // If at least one is not imported, we want to offer that | |
| 388 // option to the user. This could happen due to a bug that allowed | |
| 389 // creating SUs with the same name. | |
| 390 var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice; | |
| 391 var j; | 391 var j; |
| 392 for (j = i + 1; j < supervisedUsers.length; ++j) { | 392 for (j = i + 1; j < supervisedUsers.length; ++j) { |
| 393 if (supervisedUsers[j].name == newName) { | 393 if (supervisedUsers[j].name == newName) { |
| 394 nameIsUnique = false; | 394 nameIsUnique = false; |
| 395 break; | 395 allOnCurrentDevice = allOnCurrentDevice && |
| 396 supervisedUsers[j].onCurrentDevice; | |
| 396 } | 397 } |
| 397 } | 398 } |
| 399 | |
| 400 var errorHtml = allOnCurrentDevice ? | |
| 401 loadTimeData.getStringF( | |
| 402 'managedProfilesExistingLocalSupervisedUser') : | |
| 403 loadTimeData.getStringF( | |
| 404 'manageProfilesExistingSupervisedUser', | |
| 405 HTMLEscape(elide(newName, /* maxLength */ 50))); | |
| 406 this.showErrorBubble_(errorHtml, 'create', true); | |
| 407 | |
| 398 $('supervised-user-import-existing').onclick = | 408 $('supervised-user-import-existing').onclick = |
| 399 this.getImportHandler_(supervisedUsers[i], nameIsUnique); | 409 this.getImportHandler_(supervisedUsers[i], nameIsUnique); |
| 400 $('create-profile-ok').disabled = true; | 410 $('create-profile-ok').disabled = true; |
| 401 return; | 411 return; |
| 402 } | 412 } |
| 403 } | 413 } |
| 404 }, | 414 }, |
| 405 | 415 |
| 406 /** | 416 /** |
| 407 * Called in case the request for the list of supervised users fails because | 417 * 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', | 871 'updateSignedInStatus', |
| 862 'updateSupervisedUsersAllowed', | 872 'updateSupervisedUsersAllowed', |
| 863 ]); | 873 ]); |
| 864 | 874 |
| 865 // Export | 875 // Export |
| 866 return { | 876 return { |
| 867 ManageProfileOverlay: ManageProfileOverlay, | 877 ManageProfileOverlay: ManageProfileOverlay, |
| 868 CreateProfileOverlay: CreateProfileOverlay, | 878 CreateProfileOverlay: CreateProfileOverlay, |
| 869 }; | 879 }; |
| 870 }); | 880 }); |
| OLD | NEW |