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() {
if (profile->IsRegularProfile()) {
BuildIdentity();
BuildSyncInfo();
BuildFeatureButtons();
BuildAutofillButtons();
} else if (profile->IsGuestSession()) {
BuildGuestIdentity();
......@@ -183,6 +182,7 @@ void ProfileMenuView::BuildMenu() {
NOTREACHED();
}
BuildFeatureButtons();
BuildProfileManagementHeading();
BuildSelectableProfiles();
BuildProfileManagementFeatureButtons();
......@@ -547,23 +547,35 @@ void ProfileMenuView::BuildSyncInfo() {
void ProfileMenuView::BuildFeatureButtons() {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(browser()->profile());
if (!identity_manager->HasUnconsentedPrimaryAccount())
return;
const bool is_guest = browser()->profile()->IsGuestSession();
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)
// The Google G icon needs to be shrunk, so it won't look too big
// compared to the other icons.
ImageForMenu(kGoogleGLogoIcon, /*icon_to_image_ratio=*/0.75),
// The Google G icon needs to be shrunk, so it won't look too big
// compared to the other icons.
ImageForMenu(kGoogleGLogoIcon, /*icon_to_image_ratio=*/0.75),
#else
gfx::ImageSkia(),
gfx::ImageSkia(),
#endif
l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT),
base::BindRepeating(&ProfileMenuView::OnManageGoogleAccountButtonClicked,
l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT),
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)));
if (!identity_manager->HasPrimaryAccount()) {
// The sign-out button is only shown when sync is off.
// The sign-out button is always at the bottom.
if (has_unconsented_account && !has_primary_account) {
AddFeatureButton(
ImageForMenu(kSignOutIcon),
l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT),
......
......@@ -764,6 +764,7 @@ constexpr ProfileMenuViewBase::ActionableItem
ProfileMenuViewBase::ActionableItem::kCreditCardsButton,
ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSigninButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kOtherProfileButton,
ProfileMenuViewBase::ActionableItem::kOtherProfileButton,
......@@ -789,6 +790,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncEnabled[] = {
ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSyncSettingsButton,
ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
......@@ -814,6 +816,7 @@ constexpr ProfileMenuViewBase::ActionableItem kActionableItems_SyncError[] = {
ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSyncErrorButton,
ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
ProfileMenuViewBase::ActionableItem::kAddNewProfileButton,
......@@ -840,6 +843,7 @@ constexpr ProfileMenuViewBase::ActionableItem
ProfileMenuViewBase::ActionableItem::kAddressesButton,
ProfileMenuViewBase::ActionableItem::kSigninAccountButton,
ProfileMenuViewBase::ActionableItem::kManageGoogleAccountButton,
ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kSignoutButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kGuestProfileButton,
......@@ -874,12 +878,13 @@ PROFILE_MENU_CLICK_TEST(
// 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_GuestProfile[] =
{ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
{ProfileMenuViewBase::ActionableItem::kExitProfileButton,
ProfileMenuViewBase::ActionableItem::kManageProfilesButton,
ProfileMenuViewBase::ActionableItem::kOtherProfileButton,
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::kManageProfilesButton};
ProfileMenuViewBase::ActionableItem::kExitProfileButton};
PROFILE_MENU_CLICK_TEST(kActionableItems_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