Commit 369bd31e authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Add tooltips to toolbar avatar button

These tooltips are not yet UX approved but can be used as placeholders
until we have the final strings.

This change also makes use of the generic "Current user" tooltip when
there is only one non-signed-in user and the generic icon is used, in
place of the default otherwise unexpected "Person 1" profile name.

Bug: chromium:822070
Change-Id: Ia6941511c6e19a02b635edb688933c2abe6ba92f
Reviewed-on: https://chromium-review.googlesource.com/1080787
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565126}
parent 00d0b2bb
......@@ -5502,9 +5502,15 @@ the Bookmarks menu.">
<message name="IDS_GENERIC_USER_AVATAR_LABEL" desc="Label shown for the user that is currently active, when there are multiple user accounts.">
Current user
</message>
<message name="IDS_INCOGNITO_AVATAR_BUTTON_TOOLTIP" desc="Tooltip for the inactive avatar button when the user is in incognito mode.">
<message name="IDS_AVATAR_BUTTON_INCOGNITO_TOOLTIP" desc="Tooltip for the inactive avatar button when the user is in incognito mode.">
You're incognito
</message>
<message name="IDS_AVATAR_BUTTON_SYNC_PAUSED" desc="Tooltip for the avatar button when sync is paused for the current profile.">
<ph name="PROFILE_NAME">$1<ex>User</ex></ph>: Sync paused
</message>
<message name="IDS_AVATAR_BUTTON_SYNC_ERROR" desc="Tooltip for the avatar button when there are sync errors for the current profile.">
<ph name="PROFILE_NAME">$1<ex>User</ex></ph>: Sync isn't working
</message>
<message name="IDS_LEGACY_SUPERVISED_USER_NEW_AVATAR_LABEL" desc="Label shown in the new avatar menu for a supervised user.">
<ph name="PROFILE_DISPLAY_NAME">$1<ex>Markus</ex></ph> (Supervised)
</message>
......
......@@ -70,16 +70,12 @@ void AvatarToolbarButton::UpdateIcon() {
}
void AvatarToolbarButton::UpdateTooltipText() {
if (IsIncognito()) {
SetTooltipText(
l10n_util::GetStringUTF16(IDS_INCOGNITO_AVATAR_BUTTON_TOOLTIP));
} else {
SetTooltipText(profiles::GetAvatarNameForProfile(profile_->GetPath()));
}
SetTooltipText(GetAvatarTooltipText());
}
void AvatarToolbarButton::OnAvatarErrorChanged() {
UpdateIcon();
UpdateTooltipText();
}
void AvatarToolbarButton::OnProfileAdded(const base::FilePath& profile_path) {
......@@ -123,6 +119,30 @@ bool AvatarToolbarButton::ShouldShowGenericIcon() const {
!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated();
}
base::string16 AvatarToolbarButton::GetAvatarTooltipText() {
if (IsIncognito())
return l10n_util::GetStringUTF16(IDS_AVATAR_BUTTON_INCOGNITO_TOOLTIP);
if (ShouldShowGenericIcon())
return l10n_util::GetStringUTF16(IDS_GENERIC_USER_AVATAR_LABEL);
const base::string16 profile_name =
profiles::GetAvatarNameForProfile(profile_->GetPath());
switch (GetSyncState()) {
case SyncState::kNormal:
return profile_name;
case SyncState::kPaused:
return l10n_util::GetStringFUTF16(IDS_AVATAR_BUTTON_SYNC_PAUSED,
profile_name);
case SyncState::kError:
return l10n_util::GetStringFUTF16(IDS_AVATAR_BUTTON_SYNC_ERROR,
profile_name);
}
NOTREACHED();
return base::string16();
}
gfx::ImageSkia AvatarToolbarButton::GetAvatarIcon() {
const int icon_size =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled() ? 24 : 20;
......
......@@ -40,6 +40,7 @@ class AvatarToolbarButton : public ToolbarButton,
bool IsIncognito() const;
bool ShouldShowGenericIcon() const;
base::string16 GetAvatarTooltipText();
gfx::ImageSkia GetAvatarIcon();
gfx::Image GetIconImageFromProfile() const;
SyncState GetSyncState();
......
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