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 8c93fbc7349ef058347e78360d90809acabd239b..7dcc27aa2d9d453a680b23d5c2d54fcfdaf85bfc 100644 |
--- a/chrome/browser/resources/options/manage_profile_overlay.js |
+++ b/chrome/browser/resources/options/manage_profile_overlay.js |
@@ -394,8 +394,8 @@ cr.define('options', function() { |
self.hideErrorBubble_('create'); |
CreateProfileOverlay.updateCreateInProgress(true); |
chrome.send('createProfile', |
- [supervisedUser.name, supervisedUser.iconURL, false, true, |
- supervisedUser.id]); |
+ [supervisedUser.name.trim(), supervisedUser.iconURL, |
+ false, true, supervisedUser.id]); |
} |
} |
}; |
@@ -424,11 +424,13 @@ cr.define('options', function() { |
* @private |
*/ |
updateOkButton_: function(mode) { |
+ var nameElement = $(mode + '-profile-name'); |
Dan Beam
2014/09/04 23:06:07
nit: move a line lower (right above first use)
|
var oldName = this.profileInfo_.name; |
- var newName = $(mode + '-profile-name').value; |
+ var newName = nameElement.value; |
var nameIsDuplicate = this.existingProfileNames_[newName] != undefined; |
if (mode == 'manage' && oldName == newName) |
nameIsDuplicate = false; |
+ |
if (nameIsDuplicate) { |
var errorHtml = |
loadTimeData.getString('manageProfilesDuplicateNameError'); |
@@ -436,7 +438,10 @@ cr.define('options', function() { |
} else { |
this.hideErrorBubble_(mode); |
- var nameIsValid = $(mode + '-profile-name').validity.valid; |
+ // A name containing all spaces is not valid. |
+ nameElement.setCustomValidity(newName.trim() == '' ? ' ' : ''); |
+ |
+ var nameIsValid = nameElement.validity.valid; |
$(mode + '-profile-ok').disabled = !nameIsValid; |
} |
}, |
@@ -447,7 +452,7 @@ cr.define('options', function() { |
* @private |
*/ |
submitManageChanges_: function() { |
- var name = $('manage-profile-name').value; |
+ var name = $('manage-profile-name').value.trim(); |
var iconURL = $('manage-profile-icon-grid').selectedItem; |
chrome.send('setProfileIconAndName', |
@@ -480,7 +485,7 @@ cr.define('options', function() { |
// 'createProfile' is handled by the CreateProfileHandler. |
chrome.send('createProfile', |
- [name, iconUrl, createShortcut, |
+ [name.trim(), iconUrl, createShortcut, |
isSupervised, existingSupervisedUserId]); |
}, |