Commit 1cf04352 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

Restrict concatenation of the Gaia email and local profile name

This CL restricts the concatenation of the Gaia email and the local profile name
to Chrome instances with kProfileMenuRevamp enabled. This should simplify
the finch configuration for rolling out the profile menu revamp and at the same
time reduce the risk as users using the old profile menu will not be affected
by the profile name being the concatenation of the Gaia email and the local
profile name.

Bug: 1018202

Change-Id: I4c28dba17e2c3d8e13b2efeeedcd788909f550e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879291Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709834}
parent 644224e8
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -45,8 +46,6 @@ int NextAvailableMetricsBucketIndex() { ...@@ -45,8 +46,6 @@ int NextAvailableMetricsBucketIndex() {
const base::Feature kPersistUPAInProfileInfoCache{ const base::Feature kPersistUPAInProfileInfoCache{
"PersistUPAInProfileInfoCache", base::FEATURE_ENABLED_BY_DEFAULT}; "PersistUPAInProfileInfoCache", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kConcatenateGaiaAndProfileName{
"ConcatenateGaiaAndProfileName", base::FEATURE_ENABLED_BY_DEFAULT};
const char ProfileAttributesEntry::kAvatarIconKey[] = "avatar_icon"; const char ProfileAttributesEntry::kAvatarIconKey[] = "avatar_icon";
const char ProfileAttributesEntry::kBackgroundAppsKey[] = "background_apps"; const char ProfileAttributesEntry::kBackgroundAppsKey[] = "background_apps";
...@@ -68,6 +67,11 @@ ProfileAttributesEntry::ProfileAttributesEntry() ...@@ -68,6 +67,11 @@ ProfileAttributesEntry::ProfileAttributesEntry()
prefs_(nullptr), prefs_(nullptr),
profile_path_(base::FilePath()) {} profile_path_(base::FilePath()) {}
// static
bool ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName() {
return base::FeatureList::IsEnabled(features::kProfileMenuRevamp);
}
void ProfileAttributesEntry::Initialize(ProfileInfoCache* cache, void ProfileAttributesEntry::Initialize(ProfileInfoCache* cache,
const base::FilePath& path, const base::FilePath& path,
PrefService* prefs) { PrefService* prefs) {
...@@ -178,7 +182,7 @@ bool ProfileAttributesEntry::ShouldShowProfileLocalName( ...@@ -178,7 +182,7 @@ bool ProfileAttributesEntry::ShouldShowProfileLocalName(
} }
base::string16 ProfileAttributesEntry::GetNameToDisplay() const { base::string16 ProfileAttributesEntry::GetNameToDisplay() const {
DCHECK(base::FeatureList::IsEnabled(kConcatenateGaiaAndProfileName)); DCHECK(ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName);
base::string16 name_to_display = GetGAIANameToDisplay(); base::string16 name_to_display = GetGAIANameToDisplay();
base::string16 local_profile_name = GetLocalProfileName(); base::string16 local_profile_name = GetLocalProfileName();
...@@ -208,10 +212,9 @@ bool ProfileAttributesEntry::HasProfileNameChanged() { ...@@ -208,10 +212,9 @@ bool ProfileAttributesEntry::HasProfileNameChanged() {
} }
base::string16 ProfileAttributesEntry::GetName() const { base::string16 ProfileAttributesEntry::GetName() const {
if (base::FeatureList::IsEnabled(kConcatenateGaiaAndProfileName)) return ShouldConcatenateGaiaAndProfileName()
return GetNameToDisplay(); ? GetNameToDisplay()
: profile_info_cache_->GetNameOfProfileAtIndex(profile_index());
return profile_info_cache_->GetNameOfProfileAtIndex(profile_index());
} }
base::string16 ProfileAttributesEntry::GetShortcutName() const { base::string16 ProfileAttributesEntry::GetShortcutName() const {
......
...@@ -33,7 +33,6 @@ enum class SigninState { ...@@ -33,7 +33,6 @@ enum class SigninState {
}; };
extern const base::Feature kPersistUPAInProfileInfoCache; extern const base::Feature kPersistUPAInProfileInfoCache;
extern const base::Feature kConcatenateGaiaAndProfileName;
class ProfileAttributesEntry { class ProfileAttributesEntry {
public: public:
...@@ -42,6 +41,10 @@ class ProfileAttributesEntry { ...@@ -42,6 +41,10 @@ class ProfileAttributesEntry {
ProfileAttributesEntry(); ProfileAttributesEntry();
virtual ~ProfileAttributesEntry() {} virtual ~ProfileAttributesEntry() {}
// Returns whether the profile name is the concatenation of the Gaia name and
// of the local profile name.
static bool ShouldConcatenateGaiaAndProfileName();
// Gets the name of the profile to be displayed in the User Menu. The name can // Gets the name of the profile to be displayed in the User Menu. The name can
// be the GAIA name, local profile name or a combination of them. // be the GAIA name, local profile name or a combination of them.
base::string16 GetName() const; base::string16 GetName() const;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/profiles/profile_avatar_downloader.h" #include "chrome/browser/profiles/profile_avatar_downloader.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h" #include "chrome/browser/supervised_user/supervised_user_constants.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h" #include "chrome/test/base/testing_profile_manager.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
...@@ -289,6 +291,8 @@ TEST_F(ProfileAttributesStorageTest, InitialValues) { ...@@ -289,6 +291,8 @@ TEST_F(ProfileAttributesStorageTest, InitialValues) {
} }
TEST_F(ProfileAttributesStorageTest, EntryAccessors) { TEST_F(ProfileAttributesStorageTest, EntryAccessors) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kProfileMenuRevamp);
AddTestingProfile(); AddTestingProfile();
base::FilePath path = GetProfilePath("testing_profile_path0"); base::FilePath path = GetProfilePath("testing_profile_path0");
......
...@@ -233,7 +233,7 @@ base::string16 ProfileInfoCache::GetNameToDisplayOfProfileAtIndex( ...@@ -233,7 +233,7 @@ base::string16 ProfileInfoCache::GetNameToDisplayOfProfileAtIndex(
} }
base::string16 ProfileInfoCache::GetNameOfProfileAtIndex(size_t index) const { base::string16 ProfileInfoCache::GetNameOfProfileAtIndex(size_t index) const {
DCHECK(!base::FeatureList::IsEnabled(kConcatenateGaiaAndProfileName)); DCHECK(!ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName());
base::string16 name; base::string16 name;
// Unless the user has customized the profile name, we should use the // Unless the user has customized the profile name, we should use the
// profile's Gaia given name, if it's available. // profile's Gaia given name, if it's available.
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
...@@ -133,10 +134,9 @@ class ProfileInfoCacheTestWithParam ...@@ -133,10 +134,9 @@ class ProfileInfoCacheTestWithParam
ProfileInfoCacheTestWithParam() : ProfileInfoCacheTest() { ProfileInfoCacheTestWithParam() : ProfileInfoCacheTest() {
concatenate_enabled_ = GetParam(); concatenate_enabled_ = GetParam();
if (concatenate_enabled_) { if (concatenate_enabled_) {
scoped_feature_list_.InitAndEnableFeature(kConcatenateGaiaAndProfileName); scoped_feature_list_.InitAndEnableFeature(features::kProfileMenuRevamp);
} else { } else {
scoped_feature_list_.InitAndDisableFeature( scoped_feature_list_.InitAndDisableFeature(features::kProfileMenuRevamp);
kConcatenateGaiaAndProfileName);
} }
} }
...@@ -285,7 +285,7 @@ TEST_F(ProfileInfoCacheTest, ConcatenateGaiaNameAndProfileName) { ...@@ -285,7 +285,7 @@ TEST_F(ProfileInfoCacheTest, ConcatenateGaiaNameAndProfileName) {
// If one of the two conditions hold, we will show the profile name in this // If one of the two conditions hold, we will show the profile name in this
// format |GAIA name (Profile local name)| // format |GAIA name (Profile local name)|
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(kConcatenateGaiaAndProfileName); scoped_feature_list.InitAndEnableFeature(features::kProfileMenuRevamp);
// Single profile. // Single profile.
GetCache()->AddProfileToCache( GetCache()->AddProfileToCache(
GetProfilePath("path_1"), ASCIIToUTF16("Person 1"), std::string(), GetProfilePath("path_1"), ASCIIToUTF16("Person 1"), std::string(),
......
...@@ -134,7 +134,7 @@ void UpdateProfileName(Profile* profile, ...@@ -134,7 +134,7 @@ void UpdateProfileName(Profile* profile,
} }
base::string16 current_profile_name = base::string16 current_profile_name =
base::FeatureList::IsEnabled(kConcatenateGaiaAndProfileName) ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()
? entry->GetLocalProfileName() ? entry->GetLocalProfileName()
: entry->GetName(); : entry->GetName();
......
...@@ -153,7 +153,7 @@ ProfileInfoHandler::GetAccountNameAndIcon() const { ...@@ -153,7 +153,7 @@ ProfileInfoHandler::GetAccountNameAndIcon() const {
->GetProfileAttributesStorage() ->GetProfileAttributesStorage()
.GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) {
name = base::UTF16ToUTF8( name = base::UTF16ToUTF8(
base::FeatureList::IsEnabled(kConcatenateGaiaAndProfileName) ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()
? entry->GetLocalProfileName() ? entry->GetLocalProfileName()
: entry->GetName()); : entry->GetName());
// TODO(crbug.com/710660): return chrome://theme/IDR_PROFILE_AVATAR_* // TODO(crbug.com/710660): return chrome://theme/IDR_PROFILE_AVATAR_*
......
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