Commit d232f656 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Add 'Close all windows' button

... to the regular and the guest profile menu.

Bug: 995720
Change-Id: I3fc6e47dce135e42b5861ed593a65ba81cde1a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859991Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705569}
parent 20170114
...@@ -175,7 +175,6 @@ void ProfileMenuView::BuildMenu() { ...@@ -175,7 +175,6 @@ void ProfileMenuView::BuildMenu() {
if (profile->IsRegularProfile()) { if (profile->IsRegularProfile()) {
BuildIdentity(); BuildIdentity();
BuildSyncInfo(); BuildSyncInfo();
BuildFeatureButtons();
BuildAutofillButtons(); BuildAutofillButtons();
} else if (profile->IsGuestSession()) { } else if (profile->IsGuestSession()) {
BuildGuestIdentity(); BuildGuestIdentity();
...@@ -183,6 +182,7 @@ void ProfileMenuView::BuildMenu() { ...@@ -183,6 +182,7 @@ void ProfileMenuView::BuildMenu() {
NOTREACHED(); NOTREACHED();
} }
BuildFeatureButtons();
BuildProfileManagementHeading(); BuildProfileManagementHeading();
BuildSelectableProfiles(); BuildSelectableProfiles();
BuildProfileManagementFeatureButtons(); BuildProfileManagementFeatureButtons();
...@@ -547,23 +547,35 @@ void ProfileMenuView::BuildSyncInfo() { ...@@ -547,23 +547,35 @@ void ProfileMenuView::BuildSyncInfo() {
void ProfileMenuView::BuildFeatureButtons() { void ProfileMenuView::BuildFeatureButtons() {
signin::IdentityManager* identity_manager = signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(browser()->profile()); IdentityManagerFactory::GetForProfile(browser()->profile());
if (!identity_manager->HasUnconsentedPrimaryAccount()) const bool is_guest = browser()->profile()->IsGuestSession();
return; const bool has_unconsented_account =
!is_guest && identity_manager->HasUnconsentedPrimaryAccount();
const bool has_primary_account =
!is_guest && identity_manager->HasPrimaryAccount();
AddFeatureButton( if (has_unconsented_account) {
AddFeatureButton(
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
// The Google G icon needs to be shrunk, so it won't look too big // The Google G icon needs to be shrunk, so it won't look too big
// compared to the other icons. // compared to the other icons.
ImageForMenu(kGoogleGLogoIcon, /*icon_to_image_ratio=*/0.75), ImageForMenu(kGoogleGLogoIcon, /*icon_to_image_ratio=*/0.75),
#else #else
gfx::ImageSkia(), gfx::ImageSkia(),
#endif #endif
l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT), l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT),
base::BindRepeating(&ProfileMenuView::OnManageGoogleAccountButtonClicked, base::BindRepeating(
&ProfileMenuView::OnManageGoogleAccountButtonClicked,
base::Unretained(this)));
}
AddFeatureButton(
ImageForMenu(kCloseAllIcon),
l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON),
base::BindRepeating(&ProfileMenuView::OnExitProfileButtonClicked,
base::Unretained(this))); base::Unretained(this)));
if (!identity_manager->HasPrimaryAccount()) { // The sign-out button is always at the bottom.
// The sign-out button is only shown when sync is off. if (has_unconsented_account && !has_primary_account) {
AddFeatureButton( AddFeatureButton(
ImageForMenu(kSignOutIcon), ImageForMenu(kSignOutIcon),
l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT), l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT),
......
...@@ -764,6 +764,7 @@ constexpr ProfileMenuViewBase::ActionableItem ...@@ -764,6 +764,7 @@ constexpr ProfileMenuViewBase::ActionableItem
ProfileMenuViewBase::ActionableItem::kCreditCardsButton, ProfileMenuViewBase::ActionableItem::kCreditCardsButton,
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSigninButton, ProfileMenuViewBase::ActionableItem::kSigninButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton, ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kOtherProfileButton, ProfileMenuViewBase::ActionableItem::kOtherProfileButton,
ProfileMenuViewBase::ActionableItem::kOtherProfileButton, ProfileMenuViewBase::ActionableItem::kOtherProfileButton,
...@@ -789,6 +790,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = { ...@@ -789,6 +790,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = {
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSyncSettingsButton, ProfileMenuViewBase::ActionableItem::kSyncSettingsButton,
ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton, ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton, ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton, ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton, ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
...@@ -814,6 +816,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = { ...@@ -814,6 +816,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = {
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSyncErrorButton, ProfileMenuViewBase::ActionableItem::kSyncErrorButton,
ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton, ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton, ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton, ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton, ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
...@@ -840,6 +843,7 @@ constexpr ProfileMenuViewBase::ActionableItem ...@@ -840,6 +843,7 @@ constexpr ProfileMenuViewBase::ActionableItem
ProfileMenuViewBase::ActionableItem::kAddressesButton, ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSigninAccountButton, ProfileMenuViewBase::ActionableItem::kSigninAccountButton,
ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton, ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kSignoutButton, ProfileMenuViewBase::ActionableItem::kSignoutButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton, ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton, ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
...@@ -874,12 +878,13 @@ PROFILE_MENU_CLICK_TEST( ...@@ -874,12 +878,13 @@ PROFILE_MENU_CLICK_TEST(
// 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_GuestProfile[] = constexpr ProfileMenuViewBase::ActionableItem kActionableItems_GuestProfile[] =
{ProfileMenuViewBase::ActionableItem::kManageProfilesButton, {ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kOtherProfileButton, ProfileMenuViewBase::ActionableItem::kOtherProfileButton,
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::kManageProfilesButton}; ProfileMenuViewBase::ActionableItem::kExitProfileButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_GuestProfile, PROFILE_MENU_CLICK_TEST(kActionableItems_GuestProfile,
ProfileMenuClickTest_GuestProfile) { ProfileMenuClickTest_GuestProfile) {
......
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