Chromium Code Reviews| Index: chrome/browser/profiles/profiles_state.cc |
| diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc |
| index 488964e1de16c883d3f3fcaea60e7d42d04768bb..ccf0bb79eaa0f37374411c62a629fdf16ff559af 100644 |
| --- a/chrome/browser/profiles/profiles_state.cc |
| +++ b/chrome/browser/profiles/profiles_state.cc |
| @@ -50,20 +50,38 @@ void RegisterPrefs(PrefRegistrySimple* registry) { |
| registry->RegisterListPref(prefs::kProfilesLastActive); |
| } |
| -base::string16 GetActiveProfileDisplayName(Browser* browser) { |
| - base::string16 profile_name; |
| - Profile* profile = browser->profile(); |
| +base::string16 GetAvatarButtonDisplayNameForProfile(Profile* profile) { |
| + base::string16 display_name; |
| if (profile->IsGuestSession()) { |
| - profile_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME); |
| + display_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME); |
| } else { |
| ProfileInfoCache& cache = |
| g_browser_process->profile_manager()->GetProfileInfoCache(); |
| size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| - if (index != std::string::npos) |
| - profile_name = cache.GetNameOfProfileAtIndex(index); |
| + |
| + if (index == std::string::npos) |
|
rpetterson
2014/02/20 21:41:32
shouldn't this be at least 0?
noms (inactive)
2014/02/24 22:35:06
Not always. GetIndexOfProfile returns std::string:
|
| + return l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
| + |
| + // Using the --new-profile-management flag, there's a couple of rules |
| + // about what the avatar button displays. If there's a single, local |
| + // profile, with a default name, it should display |
| + // IDS_SINGLE_PROFILE_DISPLAY_NAME. If this is a signed in profile, or |
| + // the user has edited the profile name, it should display the actual |
| + // name of the profile. In all other cases, it should also display the |
| + // actual name of the profile. |
| + base::string16 profile_name = cache.GetNameOfProfileAtIndex(index); |
| + bool has_default_name = profile_name.find(l10n_util::GetStringFUTF16( |
| + IDS_NEW_NUMBERED_PROFILE_NAME, base::string16())) != std::string::npos; |
| + |
| + if (cache.GetNumberOfProfiles() == 1 && has_default_name && |
| + cache.GetUserNameOfProfileAtIndex(index).empty()) { |
| + display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
| + } else { |
| + display_name = profile_name; |
| + } |
| } |
| - return profile_name; |
| + return display_name; |
| } |
| void UpdateProfileName(Profile* profile, |