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

Unified Diff: chrome/browser/profiles/profiles_state.cc

Issue 556003007: [Profiles] Improve the display name for default profiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test + typo Created 6 years, 3 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
Index: chrome/browser/profiles/profiles_state.cc
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index 068ddff1a6900fd5b2c3545adc939ed8c9e61c54..2a254993e1c8b363d3941bca7913cca7cdcfb58a 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -67,16 +67,18 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) {
// Using the --new-avatar-menu flag, there's a couple of rules about what
// the avatar button displays. If there's a single profile, with a default
// name (i.e. of the form Person %d) not manually set, it should display
- // IDS_SINGLE_PROFILE_DISPLAY_NAME. Otherwise, it will return the actual
- // name of the profile.
- base::string16 profile_name = cache.GetNameOfProfileAtIndex(index);
- bool has_default_name = cache.ProfileIsUsingDefaultNameAtIndex(index) &&
+ // IDS_SINGLE_PROFILE_DISPLAY_NAME. If the profile is signed in but is using
+ // a default name, use the profiles's email address. Otherwise, it
+ // will return the actual name of the profile.
+ const base::string16 profile_name = cache.GetNameOfProfileAtIndex(index);
+ const base::string16 email = cache.GetUserNameOfProfileAtIndex(index);
+ bool is_default_name = cache.ProfileIsUsingDefaultNameAtIndex(index) &&
cache.IsDefaultProfileName(profile_name);
- if (cache.GetNumberOfProfiles() == 1 && has_default_name)
+ if (cache.GetNumberOfProfiles() == 1 && is_default_name)
display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
else
- display_name = profile_name;
+ display_name = (is_default_name && !email.empty()) ? email : profile_name;
}
return display_name;
}

Powered by Google App Engine
This is Rietveld 408576698