Commit 2aea4aff authored by noms@chromium.org's avatar noms@chromium.org

[Win, Profiles] Changing your default avatar should not change your default name

Two things going wrong:
- the Windows new avatar button wasn't listening to avatar changes, so
its display would be out of sync with the avatar bubble
- when saving the avatar photo, this was also considered a name save
(even though the name wouldn't change), which made the default name an
explicit user decision (which it wasn't)

BUG=405750

Review URL: https://codereview.chromium.org/493113002

Cr-Commit-Position: refs/heads/master@{#291258}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291258 0039d316-1c4b-4281-b951-d872f2087c98
parent fbd07566
...@@ -93,15 +93,19 @@ base::string16 GetAvatarButtonTextForProfile(Profile* profile) { ...@@ -93,15 +93,19 @@ base::string16 GetAvatarButtonTextForProfile(Profile* profile) {
void UpdateProfileName(Profile* profile, void UpdateProfileName(Profile* profile,
const base::string16& new_profile_name) { const base::string16& new_profile_name) {
PrefService* pref_service = profile->GetPrefs();
ProfileInfoCache& cache = ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache(); 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, // This is only called when updating the profile name through the UI,
// so we can assume the user has done this on purpose. // so we can assume the user has done this on purpose.
size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); PrefService* pref_service = profile->GetPrefs();
if (profile_index != std::string::npos) pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false);
pref_service->SetBoolean(prefs::kProfileUsingDefaultName, false);
// Updating the profile preference will cause the cache to be updated for // Updating the profile preference will cause the cache to be updated for
// this preference. // this preference.
......
...@@ -127,6 +127,11 @@ void NewAvatarButton::OnProfileNameChanged( ...@@ -127,6 +127,11 @@ void NewAvatarButton::OnProfileNameChanged(
UpdateAvatarButtonAndRelayoutParent(); UpdateAvatarButtonAndRelayoutParent();
} }
void NewAvatarButton::OnProfileAvatarChanged(
const base::FilePath& profile_path) {
UpdateAvatarButtonAndRelayoutParent();
}
void NewAvatarButton::OnProfileSupervisedUserIdChanged( void NewAvatarButton::OnProfileSupervisedUserIdChanged(
const base::FilePath& profile_path) { const base::FilePath& profile_path) {
UpdateAvatarButtonAndRelayoutParent(); UpdateAvatarButtonAndRelayoutParent();
......
...@@ -42,6 +42,8 @@ class NewAvatarButton : public views::MenuButton, ...@@ -42,6 +42,8 @@ class NewAvatarButton : public views::MenuButton,
virtual void OnProfileNameChanged( virtual void OnProfileNameChanged(
const base::FilePath& profile_path, const base::FilePath& profile_path,
const base::string16& old_profile_name) OVERRIDE; const base::string16& old_profile_name) OVERRIDE;
virtual void OnProfileAvatarChanged(
const base::FilePath& profile_path) OVERRIDE;
virtual void OnProfileSupervisedUserIdChanged( virtual void OnProfileSupervisedUserIdChanged(
const base::FilePath& profile_path) OVERRIDE; const base::FilePath& profile_path) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment