Commit 38b5795d authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Update guest profile menu

 - The profile feature buttons are added
 - Browser tests for the guest profile are
   re-enabled after crrev.com/c/1848371
 - Autofill buttons are not shown in incognito mode
 - The guest profile is moved to selectable profiles

Bug: 995720
Change-Id: I8499848add6fcc06bb984ce79c4bc5f36ac4546a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850155Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704608}
parent 09a46b5c
......@@ -178,17 +178,17 @@ void ProfileMenuView::BuildMenu() {
BuildSyncInfo();
BuildAccountFeatureButtons();
BuildAutofillButtons();
BuildProfileFeatureButtons();
} else if (profile->IsIncognitoProfile()) {
BuildIncognitoIdentity();
BuildAutofillButtons();
} else {
DCHECK(profile->IsGuestSession());
} else if (profile->IsGuestSession()) {
BuildGuestIdentity();
} else {
NOTREACHED();
}
BuildProfileHeading();
BuildSelectableProfiles();
BuildProfileFeatureButtons();
}
void ProfileMenuView::OnAvatarMenuChanged(
......@@ -610,6 +610,14 @@ void ProfileMenuView::BuildSelectableProfiles() {
base::BindRepeating(&ProfileMenuView::OnOtherProfileSelected,
base::Unretained(this), profile_entry->GetPath()));
}
if (!browser()->profile()->IsGuestSession()) {
AddSelectableProfile(
profiles::GetGuestAvatar(),
l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME),
base::BindRepeating(&ProfileMenuView::OnGuestProfileButtonClicked,
base::Unretained(this)));
}
}
void ProfileMenuView::BuildProfileFeatureButtons() {
......@@ -619,12 +627,6 @@ void ProfileMenuView::BuildProfileFeatureButtons() {
base::BindRepeating(&ProfileMenuView::OnManageProfilesButtonClicked,
base::Unretained(this)));
AddProfileFeatureButton(
profiles::GetGuestAvatar(),
l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME),
base::BindRepeating(&ProfileMenuView::OnGuestProfileButtonClicked,
base::Unretained(this)));
AddProfileFeatureButton(
ImageForMenu(kAddIcon, /*icon_to_image_ratio=*/0.75),
l10n_util::GetStringUTF16(IDS_ADD),
......
......@@ -928,11 +928,13 @@ class ProfileMenuClickTest_GuestProfile : public ProfileMenuClickTest {
public:
// 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.
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[2] =
{ProfileMenuView::ActionableItem::kOtherProfileButton,
static constexpr ProfileMenuView::ActionableItem kOrderedActionableItems[4] =
{ProfileMenuView::ActionableItem::kManageProfilesButton,
ProfileMenuView::ActionableItem::kOtherProfileButton,
ProfileMenuView::ActionableItem::kAddNewProfileButton,
// The first button is added again to finish the cycle and test that
// there are no other buttons at the end.
ProfileMenuView::ActionableItem::kOtherProfileButton};
ProfileMenuView::ActionableItem::kManageProfilesButton};
ProfileMenuClickTest_GuestProfile() = default;
......@@ -948,9 +950,7 @@ class ProfileMenuClickTest_GuestProfile : public ProfileMenuClickTest {
constexpr ProfileMenuView::ActionableItem
ProfileMenuClickTest_GuestProfile::kOrderedActionableItems[];
// TODO(crbug.com/1012167): Flaky.
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_GuestProfile,
DISABLED_SetupAndRunTest) {
IN_PROC_BROWSER_TEST_P(ProfileMenuClickTest_GuestProfile, SetupAndRunTest) {
profiles::SwitchToGuestProfile(ProfileManager::CreateCallback());
ui_test_utils::WaitForBrowserToOpen();
Profile* guest = g_browser_process->profile_manager()->GetProfileByPath(
......
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