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

Update profile icons to render as circles in the Mac people menu

This patch enables rounding of the profile icons in the Mac's people
menu to align with the GM2 circular icons used elsewhere in Chrome.
This is achieved by applying a circular mask to the image and
increasing the resolution of the avatar icons requested.

This CL also avoid a call to AvatarMenu::GetImageForMenuButton() and
calls GetAvatarIcon() directly (the additional logic of
GetImageForMenuButton() is not needed here).

Bug: 857064
Change-Id: I1444dc6081f3af6289be7fa6a886153a70c9ecf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517059
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Auto-Submit: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarThomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825957}
parent 327d8005
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/feature_list.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/canvas_image_source.h" #include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
...@@ -50,6 +52,12 @@ ...@@ -50,6 +52,12 @@
#include "ui/gfx/icon_util.h" // For Iconutil::kLargeIconSize. #include "ui/gfx/icon_util.h" // For Iconutil::kLargeIconSize.
#endif #endif
#if defined(OS_MAC)
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
#endif
// Helper methods for transforming and drawing avatar icons. // Helper methods for transforming and drawing avatar icons.
namespace { namespace {
...@@ -419,12 +427,26 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, ...@@ -419,12 +427,26 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
#if defined(OS_MAC) #if defined(OS_MAC)
gfx::Image GetAvatarIconForNSMenu(const base::FilePath& profile_path) { gfx::Image GetAvatarIconForNSMenu(const base::FilePath& profile_path) {
// TODO(crbug.com/857064): Call ProfileAttributesEntry::GetAvatarIcon() ProfileAttributesEntry* entry;
// directly and pass in in larger desired size so that it can be smoothly if (!g_browser_process->profile_manager()
// clipped to a circle. ->GetProfileAttributesStorage()
.GetProfileAttributesWithPath(profile_path, &entry)) {
// This can happen if the user deletes the current profile.
return gfx::Image();
}
if (base::FeatureList::IsEnabled(features::kNewProfilePicker)) {
// Get a higher res than 16px so it looks good after cropping to a circle.
gfx::Image icon =
entry->GetAvatarIcon(kAvatarIconSize, /*download_high_res=*/false);
return profiles::GetSizedAvatarIcon(icon, /*is_rectangle=*/true,
gfx::kFaviconSize, gfx::kFaviconSize,
profiles::SHAPE_CIRCLE);
}
constexpr int kMenuAvatarIconSize = 38; constexpr int kMenuAvatarIconSize = 38;
gfx::Image icon; gfx::Image icon =
AvatarMenu::GetImageForMenuButton(profile_path, &icon, kMenuAvatarIconSize); entry->GetAvatarIcon(kMenuAvatarIconSize, /*download_high_res=*/false);
// The image might be too large and need to be resized, e.g. if this is a // The image might be too large and need to be resized, e.g. if this is a
// signed-in user using the GAIA profile photo. // signed-in user using the GAIA profile photo.
......
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