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 // Handling the case when multiple SU user with the same | |
Pam (message me for reviews)
2015/12/15 22:20:13
nit:
user with the same name are created
->
users
atanasova
2015/12/16 09:21:13
Done.
| |
386 // name are created, 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. | |
389 var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice; | |
391 var j; | 390 var j; |
392 for (j = i + 1; j < supervisedUsers.length; ++j) { | 391 for (j = i + 1; j < supervisedUsers.length; ++j) { |
393 if (supervisedUsers[j].name == newName) { | 392 if (supervisedUsers[j].name == newName) { |
394 nameIsUnique = false; | 393 nameIsUnique = false; |
395 break; | 394 allOnCurrentDevice = allOnCurrentDevice && |
395 supervisedUsers[j].onCurrentDevice; | |
396 } | 396 } |
397 } | 397 } |
398 | |
399 var errorHtml = allOnCurrentDevice ? | |
400 loadTimeData.getStringF( | |
401 'managedProfilesExistingLocalSupervisedUser') : | |
402 loadTimeData.getStringF( | |
403 'manageProfilesExistingSupervisedUser', | |
404 HTMLEscape(elide(newName, /* maxLength */ 50))); | |
405 this.showErrorBubble_(errorHtml, 'create', true); | |
406 | |
398 $('supervised-user-import-existing').onclick = | 407 $('supervised-user-import-existing').onclick = |
399 this.getImportHandler_(supervisedUsers[i], nameIsUnique); | 408 this.getImportHandler_(supervisedUsers[i], nameIsUnique); |
400 $('create-profile-ok').disabled = true; | 409 $('create-profile-ok').disabled = true; |
401 return; | 410 return; |
402 } | 411 } |
403 } | 412 } |
404 }, | 413 }, |
405 | 414 |
406 /** | 415 /** |
407 * Called in case the request for the list of supervised users fails because | 416 * 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', | 870 'updateSignedInStatus', |
862 'updateSupervisedUsersAllowed', | 871 'updateSupervisedUsersAllowed', |
863 ]); | 872 ]); |
864 | 873 |
865 // Export | 874 // Export |
866 return { | 875 return { |
867 ManageProfileOverlay: ManageProfileOverlay, | 876 ManageProfileOverlay: ManageProfileOverlay, |
868 CreateProfileOverlay: CreateProfileOverlay, | 877 CreateProfileOverlay: CreateProfileOverlay, |
869 }; | 878 }; |
870 }); | 879 }); |
OLD | NEW |