Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1076)

Unified Diff: chrome/browser/resources/options/manage_profile_overlay.js

Issue 1506353007: Show warning message when trying to create SU with existing name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5fef4c2e3bff54247723f191d393bb531401cbfe 100644
--- a/chrome/browser/resources/options/manage_profile_overlay.js
+++ b/chrome/browser/resources/options/manage_profile_overlay.js
@@ -379,22 +379,32 @@ 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) {
Marc Treib 2015/12/16 09:26:54 optional nit: You could say if (supervisedUsers[i]
atanasova 2015/12/16 14:35:37 Done.
// 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.
+ var allOnCurrentDevice = supervisedUsers[i].onCurrentDevice;
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;
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698