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

Unified Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 474123002: [Mac, Win] Don't allow blank spaces in profile names in the new avatar bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
index b1171c13c0b7fe98e75590a01f4d511ba0f710dd..75eae60318c897bee72a7578736cfaf5ef38d8f8 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
@@ -623,18 +623,24 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
}
- (void)saveProfileName:(id)sender {
- NSString* text = [profileNameTextField_ stringValue];
+ NSString* originalText = [profileNameTextField_ stringValue];
+ base::string16 newProfileName = base::SysNSStringToUTF16(originalText);
+
// Empty profile names are not allowed, and are treated as a cancel.
- if ([text length] > 0) {
- profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text));
+ base::TrimString(newProfileName, base::ASCIIToUTF16(" "), &newProfileName);
Alexei Svitkine (slow) 2014/08/15 17:25:26 Why not use base::TrimWhitespace() instead, so it
noms (inactive) 2014/08/15 17:37:40 Done.
+ if (!newProfileName.empty()) {
+ profiles::UpdateProfileName(profile_, newProfileName);
[controller_
postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME];
- [self setTitle:text];
+ [self setTitle:originalText];
}
[profileNameTextField_ setHidden:YES];
}
- (void)showEditableView:(id)sender {
+ // Update the textbox to the correct string, just in case we had previously
+ // entered a string that was rejected (eg. all spaces).
+ [profileNameTextField_ setStringValue:[self title]];
[profileNameTextField_ setHidden:NO];
[[self window] makeFirstResponder:profileNameTextField_];
}

Powered by Google App Engine
This is Rietveld 408576698