Index: chrome/browser/resources/options/manage_profile_overlay.js |
diff --git a/chrome/browser/resources/options/manage_profile_overlay.js b/chrome/browser/resources/options/manage_profile_overlay.js |
index df9862b545f1c027297dbf3f5fed425fdef660cf..dad70ea564b32bf28e345222aa2a36b61a05b5be 100644 |
--- a/chrome/browser/resources/options/manage_profile_overlay.js |
+++ b/chrome/browser/resources/options/manage_profile_overlay.js |
@@ -379,22 +379,27 @@ cr.define('options', function() { |
var newName = $('create-profile-name').value; |
var i; |
for (i = 0; i < supervisedUsers.length; ++i) { |
- if (supervisedUsers[i].name == newName && |
- !supervisedUsers[i].onCurrentDevice) { |
- var errorHtml = loadTimeData.getStringF( |
- 'manageProfilesExistingSupervisedUser', |
- HTMLEscape(elide(newName, /* maxLength */ 50))); |
- this.showErrorBubble_(errorHtml, 'create', true); |
- |
+ if (supervisedUsers[i].name == newName) { |
// Check if another supervised user also exists with that name. |
var nameIsUnique = true; |
+ 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
|
var j; |
for (j = i + 1; j < supervisedUsers.length; ++j) { |
if (supervisedUsers[j].name == newName) { |
nameIsUnique = false; |
- break; |
+ allOnCurrentDevice = allOnCurrentDevice && |
+ supervisedUsers[j].onCurrentDevice; |
} |
} |
+ |
+ var errorHtml = allOnCurrentDevice ? |
+ loadTimeData.getStringF( |
+ 'managedProfilesExistingLocalSupervisedUser') : |
+ loadTimeData.getStringF( |
+ 'manageProfilesExistingSupervisedUser', |
+ HTMLEscape(elide(newName, /* maxLength */ 50))); |
+ this.showErrorBubble_(errorHtml, 'create', true); |
+ |
$('supervised-user-import-existing').onclick = |
this.getImportHandler_(supervisedUsers[i], nameIsUnique); |
$('create-profile-ok').disabled = true; |