X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fprofiles%2Fprofiles_state.cc;h=864ac7eab85c033acedae6d2d348d9c43fe07c17;hb=d41e52f18cc3fee3627acf2db026b2a86c2a9d18;hp=8552cdf606c84819aab06963619d0a3551381ae0;hpb=4e9e197c26c34b7055b2c5de6d4a770d317b468c;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/profiles/profiles_state.cc b/src/chrome/browser/profiles/profiles_state.cc index 8552cdf..864ac7e 100644 --- a/src/chrome/browser/profiles/profiles_state.cc +++ b/src/chrome/browser/profiles/profiles_state.cc @@ -59,21 +59,19 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) { if (index == std::string::npos) 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 (i.e. of the form Person %d), it should - // display IDS_SINGLE_PROFILE_DISPLAY_NAME. If this is a signed in profile, - // or the user has edited the profile name, or there are multiple profiles, - // it will return the actual name of the profile. + // 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); + bool has_default_name = cache.ProfileIsUsingDefaultNameAtIndex(index) && + cache.IsDefaultProfileName(profile_name); - if (cache.GetNumberOfProfiles() == 1 && has_default_name && - cache.GetUserNameOfProfileAtIndex(index).empty()) { + if (cache.GetNumberOfProfiles() == 1 && has_default_name) display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); - } else { + else display_name = profile_name; - } } return display_name; } @@ -93,15 +91,19 @@ base::string16 GetAvatarButtonTextForProfile(Profile* profile) { void UpdateProfileName(Profile* profile, const base::string16& new_profile_name) { - PrefService* pref_service = profile->GetPrefs(); ProfileInfoCache& cache = g_browser_process->profile_manager()->GetProfileInfoCache(); + size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); + if (profile_index == std::string::npos) + return; + + if (new_profile_name == cache.GetNameOfProfileAtIndex(profile_index)) + return; // This is only called when updating the profile name through the UI, // so we can assume the user has done this on purpose. - size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); - if (profile_index != std::string::npos) - pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false); + PrefService* pref_service = profile->GetPrefs(); + pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false); // Updating the profile preference will cause the cache to be updated for // this preference.