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

Unified Diff: chrome/browser/chromeos/login/new_user_view.cc

Issue 6069006: Trim whitespaces from username (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/new_user_view.cc
diff --git a/chrome/browser/chromeos/login/new_user_view.cc b/chrome/browser/chromeos/login/new_user_view.cc
index d340a0ba4ade4d0bd62bd0499417415f76c54866..0f469731757d5be908c5dd4f86203a96073972c1 100644
--- a/chrome/browser/chromeos/login/new_user_view.cc
+++ b/chrome/browser/chromeos/login/new_user_view.cc
@@ -63,14 +63,20 @@ class UsernameField : public chromeos::TextfieldWithMargin {
// views::Textfield overrides:
virtual void WillLoseFocus() {
- if (!text().empty()) {
- std::string username = UTF16ToUTF8(text());
+ string16 user_input;
+ bool was_trim = TrimWhitespace(text(), TRIM_ALL, &user_input) != TRIM_NONE;
+ if (!user_input.empty()) {
+ std::string username = UTF16ToUTF8(user_input);
if (username.find('@') == std::string::npos) {
username += kDefaultDomain;
SetText(UTF8ToUTF16(username));
+ was_trim = false;
}
}
+
+ if (was_trim)
+ SetText(user_input);
}
// Overridden from views::View:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698