Commit 5bf513dc authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[Dice] Special case single web account in user menu

When there's only one web account to turn on sync,
the "Sync to another account" button should directly open
the sign-in flow for a new account instead of opening
a submenu with only the "Use another account" button.

Bug: 812269
Change-Id: I99757042f9a03b78c8145cb13faea893b64db32a
Reviewed-on: https://chromium-review.googlesource.com/924185
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537622}
parent cfcaf86c
...@@ -672,9 +672,17 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -672,9 +672,17 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
browser_, signin_with_gaia_account_button_->account().value(), browser_, signin_with_gaia_account_button_->account().value(),
access_point_); access_point_);
} else if (sender == sync_to_another_account_button_) { } else if (sender == sync_to_another_account_button_) {
// Display a submenu listing the GAIA web accounts (without the first one). // Extract the promo accounts for the submenu, i.e. remove the first
// one from the list because it is already shown in a separate button.
std::vector<AccountInfo> accounts(dice_sync_promo_accounts_.begin() + 1, std::vector<AccountInfo> accounts(dice_sync_promo_accounts_.begin() + 1,
dice_sync_promo_accounts_.end()); dice_sync_promo_accounts_.end());
if (accounts.empty()) {
// If there is no account to list for the submenu, directly open the
// sign-in page.
ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
return;
}
// Display the submenu to list |accounts|.
// Using base::Unretained(this) is safe here because |dice_accounts_menu_| // Using base::Unretained(this) is safe here because |dice_accounts_menu_|
// is owned by |ProfileChooserView|, i.e. |this|. // is owned by |ProfileChooserView|, i.e. |this|.
dice_accounts_menu_ = std::make_unique<DiceAccountsMenu>( dice_accounts_menu_ = std::make_unique<DiceAccountsMenu>(
...@@ -1095,11 +1103,15 @@ views::View* ProfileChooserView::CreateDiceSigninView() { ...@@ -1095,11 +1103,15 @@ views::View* ProfileChooserView::CreateDiceSigninView() {
new views::ImageView()); new views::ImageView());
switch_account_icon_view->SetImage(gfx::CreateVectorIcon( switch_account_icon_view->SetImage(gfx::CreateVectorIcon(
kSyncSwitchAccountIcon, kSmallMenuIconSize, gfx::kChromeIconGrey)); kSyncSwitchAccountIcon, kSmallMenuIconSize, gfx::kChromeIconGrey));
sync_to_another_account_button_ = new HoverButton( // The accounts submenu is only needed when there are additional accounts to
this, std::move(switch_account_icon_view), // list, i.e. when there is more than 1 account (the first account has it's
l10n_util::GetStringUTF16( // own button).
IDS_PROFILES_DICE_SIGNIN_WITH_ANOTHER_ACCOUNT_BUTTON), const bool show_submenu_arrow = dice_sync_promo_accounts_.size() > 1;
base::string16() /* subtitle */, true /* show right arrow */); sync_to_another_account_button_ =
new HoverButton(this, std::move(switch_account_icon_view),
l10n_util::GetStringUTF16(
IDS_PROFILES_DICE_SIGNIN_WITH_ANOTHER_ACCOUNT_BUTTON),
base::string16() /* subtitle */, show_submenu_arrow);
view->AddChildView(sync_to_another_account_button_); view->AddChildView(sync_to_another_account_button_);
return view; return view;
} }
......
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