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

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: alexei nits. unfortunately a rebase sneaked in :( 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 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];
}
« 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