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

[Dice] Use first name for signin/sync promo

For the personalized sync promo in the user menu
and the contextual promos "Sync as <FIRST>"
should be displayed instead of "Sync as <FIRST> <LAST>".
This CL fixes this.

Bug: 810865
Change-Id: Idf3f40b9f9a7ecac8dff4d2ab293cafda8399249
Reviewed-on: https://chromium-review.googlesource.com/939396Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539803}
parent 030b6cd0
...@@ -37,6 +37,21 @@ int GetDividerAndArrowReservedWidth() { ...@@ -37,6 +37,21 @@ int GetDividerAndArrowReservedWidth() {
kDropDownArrowButtonWidth; kDropDownArrowButtonWidth;
} }
base::string16 GetButtonTitleForAccount(const AccountInfo& account) {
if (!account.given_name.empty()) {
return l10n_util::GetStringFUTF16(
IDS_PROFILES_DICE_SIGNIN_FIRST_ACCOUNT_BUTTON,
base::UTF8ToUTF16(account.given_name));
}
if (!account.full_name.empty()) {
return l10n_util::GetStringFUTF16(
IDS_PROFILES_DICE_SIGNIN_FIRST_ACCOUNT_BUTTON,
base::UTF8ToUTF16(account.full_name));
}
return l10n_util::GetStringUTF16(
IDS_PROFILES_DICE_SIGNIN_FIRST_ACCOUNT_BUTTON_NO_NAME);
}
// Sizes |image| to 40x40, adds a white background in case it is transparent and // Sizes |image| to 40x40, adds a white background in case it is transparent and
// shapes it circular. // shapes it circular.
gfx::ImageSkia PrepareAvatarImage(const gfx::Image& image) { gfx::ImageSkia PrepareAvatarImage(const gfx::Image& image) {
...@@ -98,14 +113,7 @@ DiceSigninButton::DiceSigninButton(const AccountInfo& account, ...@@ -98,14 +113,7 @@ DiceSigninButton::DiceSigninButton(const AccountInfo& account,
} }
// Set the title text for main Sign-in button. // Set the title text for main Sign-in button.
base::string16 button_title = SetText(GetButtonTitleForAccount(account));
account_->full_name.empty()
? l10n_util::GetStringUTF16(
IDS_PROFILES_DICE_SIGNIN_FIRST_ACCOUNT_BUTTON_NO_NAME)
: l10n_util::GetStringFUTF16(
IDS_PROFILES_DICE_SIGNIN_FIRST_ACCOUNT_BUTTON,
base::UTF8ToUTF16(account_->full_name));
SetText(button_title);
SetFocusForPlatform(); SetFocusForPlatform();
SetProminent(true); SetProminent(true);
SetHorizontalAlignment(gfx::ALIGN_LEFT); SetHorizontalAlignment(gfx::ALIGN_LEFT);
......
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