| 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 b94e3f46d6005b34f086516cd492b84fc4068ae1..8b6eccfb14a9625d5d6371461c1dc6a37f9b72cd 100644
|
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
|
| @@ -619,13 +619,19 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| }
|
|
|
| - (void)saveProfileName:(id)sender {
|
| - NSString* text = [profileNameTextField_ stringValue];
|
| + base::string16 newProfileName =
|
| + base::SysNSStringToUTF16([profileNameTextField_ stringValue]);
|
| +
|
| // Empty profile names are not allowed, and are treated as a cancel.
|
| - if ([text length] > 0) {
|
| - profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text));
|
| + base::TrimWhitespace(newProfileName, base::TRIM_ALL, &newProfileName);
|
| + if (!newProfileName.empty()) {
|
| + profiles::UpdateProfileName(profile_, newProfileName);
|
| [controller_
|
| postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME];
|
| - [self setTitle:text];
|
| + [self setTitle:base::SysUTF16ToNSString(newProfileName)];
|
| + } else {
|
| + // Since the text is empty and not allowed, revert it from the textbox.
|
| + [profileNameTextField_ setStringValue:[self title]];
|
| }
|
| [profileNameTextField_ setHidden:YES];
|
| }
|
|
|