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..cbccaf1e1d3b8afb01d27e0b216118021cff7275 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::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:originalText]; |
|
Alexei Svitkine (slow)
2014/08/15 17:40:46
If this really needs to be |originalText| instead
noms (inactive)
2014/08/15 18:14:28
Oh, now that I am doing the trimming you're right,
|
| } |
| [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). |
|
Alexei Svitkine (slow)
2014/08/15 17:40:47
If the previous string was rejected, then it would
noms (inactive)
2014/08/15 18:14:28
If the string is incorrect, we cancel editing, don
|
| + [profileNameTextField_ setStringValue:[self title]]; |
| [profileNameTextField_ setHidden:NO]; |
| [[self window] makeFirstResponder:profileNameTextField_]; |
| } |