diff options
author | Hui Guo <guohui@chromium.org> | 2014-08-26 17:37:15 -0400 |
---|---|---|
committer | Hui Guo <guohui@chromium.org> | 2014-08-26 21:38:51 +0000 |
commit | 5882a9b0b88936ce138d4c2dc39632c474ea2c76 (patch) | |
tree | 3589ccadda9a5d426050b4a8bf60d0b85759b37f | |
parent | 1e43eae41beb2341cb7117916da48f852a539f02 (diff) | |
download | chromium_src-5882a9b0b88936ce138d4c2dc39632c474ea2c76.zip chromium_src-5882a9b0b88936ce138d4c2dc39632c474ea2c76.tar.gz chromium_src-5882a9b0b88936ce138d4c2dc39632c474ea2c76.tar.bz2 |
Merge: Use 'You' as profile name for a single signed profile whose gaia name is not available yet
BUG=399674
TBR=guohui@chromium.org
Review URL: https://codereview.chromium.org/504453002
Cr-Commit-Position: refs/heads/master@{#291522}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291522 0039d316-1c4b-4281-b951-d872f2087c98
(cherry picked from commit 78186a4d876b87c708cf7313b81aef8340bc9f20)
Review URL: https://codereview.chromium.org/503343004
Cr-Commit-Position: refs/branch-heads/2125@{#109}
Cr-Branched-From: b68026d94bda36dd106a3d91a098719f952a9477-refs/heads/master@{#290040}
-rw-r--r-- | chrome/browser/profiles/profile_manager_unittest.cc | 18 | ||||
-rw-r--r-- | chrome/browser/profiles/profiles_state.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/cocoa_profile_test.mm | 2 |
3 files changed, 24 insertions, 16 deletions
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 1645dc1..6e47eb3 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc @@ -1085,17 +1085,27 @@ TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1->GetPath())); - // We should display the actual profile name for signed in profiles. + // For a signed in profile with a default name we still display + // IDS_SINGLE_PROFILE_DISPLAY_NAME. cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com")); EXPECT_EQ(profile_name1, cache.GetNameOfProfileAtIndex(0)); - EXPECT_EQ(profile_name1, + EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1->GetPath())); + // For a signed in profile with a non-default Gaia given name we display the + // Gaia given name. + cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com")); + const base::string16 gaia_given_name(ASCIIToUTF16("given name")); + cache.SetGAIAGivenNameOfProfileAtIndex(0, gaia_given_name); + EXPECT_EQ(gaia_given_name, cache.GetNameOfProfileAtIndex(0)); + EXPECT_EQ(gaia_given_name, + profiles::GetAvatarNameForProfile(profile1->GetPath())); + // Multiple profiles means displaying the actual profile names. const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); Profile* profile2 = AddProfileToCache(profile_manager, "path_2", profile_name2); - EXPECT_EQ(profile_name1, + EXPECT_EQ(gaia_given_name, profiles::GetAvatarNameForProfile(profile1->GetPath())); EXPECT_EQ(profile_name2, profiles::GetAvatarNameForProfile(profile2->GetPath())); @@ -1105,7 +1115,7 @@ TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { ProfileManager::CreateCallback()); // Spin the message loop so that all the callbacks can finish running. base::RunLoop().RunUntilIdle(); - EXPECT_EQ(profile_name1, + EXPECT_EQ(gaia_given_name, profiles::GetAvatarNameForProfile(profile1->GetPath())); } #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc index 8552cdf..8bbf49f 100644 --- a/chrome/browser/profiles/profiles_state.cc +++ b/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; } diff --git a/chrome/browser/ui/cocoa/cocoa_profile_test.mm b/chrome/browser/ui/cocoa/cocoa_profile_test.mm index 34a1195..87f757c 100644 --- a/chrome/browser/ui/cocoa/cocoa_profile_test.mm +++ b/chrome/browser/ui/cocoa/cocoa_profile_test.mm @@ -46,7 +46,7 @@ void CocoaProfileTest::SetUp() { ASSERT_TRUE(profile_manager_.SetUp()); - profile_ = profile_manager_.CreateTestingProfile("default"); + profile_ = profile_manager_.CreateTestingProfile("Person 1"); ASSERT_TRUE(profile_); // TODO(shess): These are needed in case someone creates a browser |