Chromium Code Reviews| 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_]; |
| } |