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

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

Issue 532023003: [Profiles] Trim profile names in chrome://settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 | « no previous file | no next file » | 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 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]);
},
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698