Commit 46d13c69 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-name] Hide profile name for single profiles with default name

Bug: 1018191
Change-Id: I2db59d17037f4933751545a85ea372841241d010
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879295
Auto-Submit: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709448}
parent 26b6fcaf
...@@ -436,11 +436,15 @@ void ProfileMenuView::BuildIdentity() { ...@@ -436,11 +436,15 @@ void ProfileMenuView::BuildIdentity() {
account); account);
ProfileAttributesEntry* profile_attributes = ProfileAttributesEntry* profile_attributes =
GetProfileAttributesEntry(profile); GetProfileAttributesEntry(profile);
size_t num_of_profiles =
SetHeading(profile_attributes->GetLocalProfileName(), g_browser_process->profile_manager()->GetNumberOfProfiles();
l10n_util::GetStringUTF16(IDS_SETTINGS_EDIT_PERSON),
base::BindRepeating(&ProfileMenuView::OnEditProfileButtonClicked, if (num_of_profiles > 1 || !profile_attributes->IsUsingDefaultName()) {
base::Unretained(this))); SetHeading(profile_attributes->GetLocalProfileName(),
l10n_util::GetStringUTF16(IDS_SETTINGS_EDIT_PERSON),
base::BindRepeating(&ProfileMenuView::OnEditProfileButtonClicked,
base::Unretained(this)));
}
if (account_info.has_value()) { if (account_info.has_value()) {
SetIdentityInfo(account_info.value().account_image.AsImageSkia(), SetIdentityInfo(account_info.value().account_image.AsImageSkia(),
......
...@@ -786,6 +786,29 @@ class ProfileMenuClickTest : public SyncTest, ...@@ -786,6 +786,29 @@ class ProfileMenuClickTest : public SyncTest,
\ \
IN_PROC_BROWSER_TEST_P(test_case_name, test_case_name) IN_PROC_BROWSER_TEST_P(test_case_name, test_case_name)
// List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list.
constexpr ProfileMenuViewBase::ActionableItem
kActionableItems_SingleProfileWithCustomName[] = {
ProfileMenuViewBase::ActionableItem::kEditProfileButton,
ProfileMenuViewBase::ActionableItem::kPasswordsButton,
ProfileMenuViewBase::ActionableItem::kCreditCardsButton,
ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSigninButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuViewBase::ActionableItem::kEditProfileButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_SingleProfileWithCustomName,
ProfileMenuClickTest_SingleProfileWithCustomName) {
profiles::UpdateProfileName(browser()->profile(),
base::UTF8ToUTF16("Custom name"));
RunTest();
}
// List of actionable items in the correct order as they appear in the menu. // List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list. // If a new button is added to the menu, it should also be added to this list.
constexpr ProfileMenuViewBase::ActionableItem constexpr ProfileMenuViewBase::ActionableItem
...@@ -820,7 +843,6 @@ PROFILE_MENU_CLICK_TEST(kActionableItems_MultipleProfiles, ...@@ -820,7 +843,6 @@ PROFILE_MENU_CLICK_TEST(kActionableItems_MultipleProfiles,
// List of actionable items in the correct order as they appear in the menu. // List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list. // If a new button is added to the menu, it should also be added to this list.
constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = { constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = {
ProfileMenuViewBase::ActionableItem::kEditProfileButton,
ProfileMenuViewBase::ActionableItem::kPasswordsButton, ProfileMenuViewBase::ActionableItem::kPasswordsButton,
ProfileMenuViewBase::ActionableItem::kCreditCardsButton, ProfileMenuViewBase::ActionableItem::kCreditCardsButton,
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
...@@ -831,7 +853,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = { ...@@ -831,7 +853,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = {
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton, ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that // The first button is added again to finish the cycle and test that
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuViewBase::ActionableItem::kEditProfileButton}; ProfileMenuViewBase::ActionableItem::kPasswordsButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_SyncEnabled, PROFILE_MENU_CLICK_TEST(kActionableItems_SyncEnabled,
ProfileMenuClickTest_SyncEnabled) { ProfileMenuClickTest_SyncEnabled) {
...@@ -846,7 +868,6 @@ PROFILE_MENU_CLICK_TEST(kActionableItems_SyncEnabled, ...@@ -846,7 +868,6 @@ PROFILE_MENU_CLICK_TEST(kActionableItems_SyncEnabled,
// List of actionable items in the correct order as they appear in the menu. // List of actionable items in the correct order as they appear in the menu.
// If a new button is added to the menu, it should also be added to this list. // If a new button is added to the menu, it should also be added to this list.
constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = { constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = {
ProfileMenuViewBase::ActionableItem::kEditProfileButton,
ProfileMenuViewBase::ActionableItem::kPasswordsButton, ProfileMenuViewBase::ActionableItem::kPasswordsButton,
ProfileMenuViewBase::ActionableItem::kCreditCardsButton, ProfileMenuViewBase::ActionableItem::kCreditCardsButton,
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
...@@ -857,7 +878,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = { ...@@ -857,7 +878,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = {
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton, ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that // The first button is added again to finish the cycle and test that
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuViewBase::ActionableItem::kEditProfileButton}; ProfileMenuViewBase::ActionableItem::kPasswordsButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_SyncError, PROFILE_MENU_CLICK_TEST(kActionableItems_SyncError,
ProfileMenuClickTest_SyncError) { ProfileMenuClickTest_SyncError) {
...@@ -873,7 +894,6 @@ PROFILE_MENU_CLICK_TEST(kActionableItems_SyncError, ...@@ -873,7 +894,6 @@ PROFILE_MENU_CLICK_TEST(kActionableItems_SyncError,
// If a new button is added to the menu, it should also be added to this list. // If a new button is added to the menu, it should also be added to this list.
constexpr ProfileMenuViewBase::ActionableItem constexpr ProfileMenuViewBase::ActionableItem
kActionableItems_WithUnconsentedPrimaryAccount[] = { kActionableItems_WithUnconsentedPrimaryAccount[] = {
ProfileMenuViewBase::ActionableItem::kEditProfileButton,
ProfileMenuViewBase::ActionableItem::kPasswordsButton, ProfileMenuViewBase::ActionableItem::kPasswordsButton,
ProfileMenuViewBase::ActionableItem::kCreditCardsButton, ProfileMenuViewBase::ActionableItem::kCreditCardsButton,
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
...@@ -885,7 +905,7 @@ constexpr ProfileMenuViewBase::ActionableItem ...@@ -885,7 +905,7 @@ constexpr ProfileMenuViewBase::ActionableItem
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton, ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that // The first button is added again to finish the cycle and test that
// there are no other buttons at the end. // there are no other buttons at the end.
ProfileMenuViewBase::ActionableItem::kEditProfileButton}; ProfileMenuViewBase::ActionableItem::kPasswordsButton};
// TODO(crbug.com/1015429): Failing on Mac 10.12. // TODO(crbug.com/1015429): Failing on Mac 10.12.
PROFILE_MENU_CLICK_TEST( PROFILE_MENU_CLICK_TEST(
......
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