Commit 57556783 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[User menu] Update the user menu to show profile color

This CL adds a new implementation of SetProfileIdentityInfo() within
ProfileMenuViewBase guarded by a feature flag. The new implementation:
 - adds a colored background that matches the active frame color,
 - forces the profile name to always appear (for standard profiles), and
 - replaces the previous edit action (when you click on the profile
   name) with a dedicated edit icon.

https://screenshot.googleplex.com/1OV5VXrCVKK

Bug: 1099286
Change-Id: I20fff5b4a117aeb47174c3337900347057eb4b34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2266958
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786216}
parent affcc770
...@@ -425,14 +425,16 @@ void ProfileMenuView::BuildIdentity() { ...@@ -425,14 +425,16 @@ void ProfileMenuView::BuildIdentity() {
GetProfileAttributesEntry(profile); GetProfileAttributesEntry(profile);
base::string16 profile_name; base::string16 profile_name;
base::Optional<EditButtonParams> edit_button; base::Optional<EditButtonParams> edit_button_params;
// Profile names are not supported on ChromeOS. // Profile names are not supported on ChromeOS.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
size_t num_of_profiles = size_t num_of_profiles =
g_browser_process->profile_manager()->GetNumberOfProfiles(); g_browser_process->profile_manager()->GetNumberOfProfiles();
if (num_of_profiles > 1 || !profile_attributes->IsUsingDefaultName()) { if (num_of_profiles > 1 || !profile_attributes->IsUsingDefaultName() ||
base::FeatureList::IsEnabled(features::kNewProfilePicker)) {
profile_name = profile_attributes->GetLocalProfileName(); profile_name = profile_attributes->GetLocalProfileName();
edit_button = EditButtonParams( edit_button_params = EditButtonParams(
&vector_icons::kEditIcon,
l10n_util::GetStringUTF16(IDS_SETTINGS_EDIT_PERSON), l10n_util::GetStringUTF16(IDS_SETTINGS_EDIT_PERSON),
base::BindRepeating(&ProfileMenuView::OnEditProfileButtonClicked, base::BindRepeating(&ProfileMenuView::OnEditProfileButtonClicked,
base::Unretained(this))); base::Unretained(this)));
...@@ -441,7 +443,7 @@ void ProfileMenuView::BuildIdentity() { ...@@ -441,7 +443,7 @@ void ProfileMenuView::BuildIdentity() {
if (account_info.has_value()) { if (account_info.has_value()) {
SetProfileIdentityInfo( SetProfileIdentityInfo(
profile_name, edit_button, profile_name, edit_button_params,
account_info.value().account_image.AsImageSkia(), account_info.value().account_image.AsImageSkia(),
base::UTF8ToUTF16(account_info.value().full_name), base::UTF8ToUTF16(account_info.value().full_name),
IsSyncPaused(profile) IsSyncPaused(profile)
...@@ -449,7 +451,7 @@ void ProfileMenuView::BuildIdentity() { ...@@ -449,7 +451,7 @@ void ProfileMenuView::BuildIdentity() {
: base::UTF8ToUTF16(account_info.value().email)); : base::UTF8ToUTF16(account_info.value().email));
} else { } else {
SetProfileIdentityInfo( SetProfileIdentityInfo(
profile_name, edit_button, profile_name, edit_button_params,
profile_attributes->GetAvatarIcon().AsImageSkia(), profile_attributes->GetAvatarIcon().AsImageSkia(),
/*title=*/base::string16(), /*title=*/base::string16(),
l10n_util::GetStringUTF16(IDS_PROFILES_LOCAL_PROFILE_STATE)); l10n_util::GetStringUTF16(IDS_PROFILES_LOCAL_PROFILE_STATE));
......
...@@ -69,13 +69,14 @@ class ProfileMenuViewBase : public content::WebContentsDelegate, ...@@ -69,13 +69,14 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
kNoPrimaryAccount, kNoPrimaryAccount,
}; };
// TODO(crbug.com/1099286): Add the edit icon into this struct.
struct EditButtonParams { struct EditButtonParams {
EditButtonParams(const base::string16& edit_tooltip_text, EditButtonParams(const gfx::VectorIcon* edit_icon,
const base::string16& edit_tooltip_text,
base::RepeatingClosure edit_action); base::RepeatingClosure edit_action);
EditButtonParams(const EditButtonParams&); EditButtonParams(const EditButtonParams&);
~EditButtonParams(); ~EditButtonParams();
const gfx::VectorIcon* edit_icon;
base::string16 edit_tooltip_text; base::string16 edit_tooltip_text;
base::RepeatingClosure edit_action; base::RepeatingClosure edit_action;
}; };
......
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