Chromium Code Reviews| 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..ac8681e958897255ccefb6d6804632aee750fb57 100644 |
| --- a/chrome/browser/resources/options/manage_profile_overlay.js |
| +++ b/chrome/browser/resources/options/manage_profile_overlay.js |
| @@ -379,27 +379,37 @@ 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); |
| - |
| - // Check if another supervised user also exists with that name. |
| - var nameIsUnique = true; |
| - var j; |
| - for (j = i + 1; j < supervisedUsers.length; ++j) { |
| - if (supervisedUsers[j].name == newName) { |
| - nameIsUnique = false; |
| - break; |
| - } |
| + if (supervisedUsers[i].name != newName) |
| + continue; |
| + // Check if another supervised user also exists with that name. |
| + var nameIsUnique = true; |
| + // Handling the case when multiple supervised users with the same |
| + // name exist, but not all of them are on the device. |
| + // If at least one is not imported, we want to offer that |
| + // option to the user. This could happen due to a bug that allowed |
| + // creating SUs with the same name. |
|
Pam (message me for reviews)
2015/12/16 18:38:50
This sentence could be misinterpreted as hypotheti
atanasova
2015/12/17 09:28:40
Done.
|
| + var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice; |
| + var j; |
| + for (j = i + 1; j < supervisedUsers.length; ++j) { |
| + if (supervisedUsers[j].name == newName) { |
| + nameIsUnique = false; |
| + allOnCurrentDevice = allOnCurrentDevice && |
| + supervisedUsers[j].onCurrentDevice; |
| } |
| - $('supervised-user-import-existing').onclick = |
| - this.getImportHandler_(supervisedUsers[i], nameIsUnique); |
| - $('create-profile-ok').disabled = true; |
| - return; |
| } |
| + |
| + 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; |
| + return; |
| } |
| }, |