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

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: use TrimWhitespace ftw 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_];
}
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698