Commit 38c17356 authored by Alex Ilin's avatar Alex Ilin Committed by Commit Bot

[profiles] Update new default colored avatars colors

New colored avatars use the following colors:
- Background color is equal to the frame color
- Stroke color depends on whether the background color is dark:
  * If the background color is dark, the stroke color is white
  * Otherwise, the stroke color is computed from the background color
    by decreasing the lightness by 0.5

Bug: 1100835
Change-Id: I40d77064cf4baef339c931211eb12153e2f6e0c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362592
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799467}
parent ebaa69c5
......@@ -40,6 +40,7 @@
#if !defined(OS_ANDROID)
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
#endif
namespace {
......@@ -717,14 +718,12 @@ ProfileThemeColors ProfileAttributesEntry::GetDefaultProfileThemeColors(
return {SK_ColorRED, SK_ColorRED, SK_ColorRED};
#else
ProfileThemeColors default_colors;
// TODO(https://crbug.com/1102384): update this with the right colors, once we
// have them.
default_colors.profile_highlight_color = ThemeProperties::GetDefaultColor(
ThemeProperties::COLOR_FRAME_ACTIVE, /*incognito=*/false, dark_mode);
default_colors.default_avatar_fill_color = ThemeProperties::GetDefaultColor(
ThemeProperties::COLOR_FRAME_ACTIVE, /*incognito=*/false, dark_mode);
default_colors.default_avatar_stroke_color = ThemeProperties::GetDefaultColor(
ThemeProperties::COLOR_TOOLBAR, /*incognito=*/false, dark_mode);
default_colors.default_avatar_stroke_color =
GetAvatarStrokeColor(default_colors.default_avatar_fill_color);
return default_colors;
#endif
}
......
......@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
......@@ -48,14 +49,12 @@ void ProfileThemeUpdateService::UpdateProfileThemeColors() {
const ui::ThemeProvider& theme_provider =
ThemeService::GetThemeProviderForProfile(profile_);
ProfileThemeColors colors;
// TODO(https://crbug.com/1102384): update this with the right colors, once we
// have them.
colors.profile_highlight_color =
theme_provider.GetColor(ThemeProperties::COLOR_FRAME_ACTIVE);
colors.default_avatar_fill_color =
theme_provider.GetColor(ThemeProperties::COLOR_FRAME_ACTIVE);
colors.default_avatar_stroke_color =
theme_provider.GetColor(ThemeProperties::COLOR_TOOLBAR);
GetAvatarStrokeColor(colors.default_avatar_fill_color);
entry->SetProfileThemeColors(colors);
}
......
......@@ -33,6 +33,17 @@ SkColor GetProfileForegroundIconColor(SkColor profile_highlight_color) {
.color;
}
SkColor GetAvatarStrokeColor(SkColor avatar_fill_color) {
if (color_utils::IsDark(avatar_fill_color)) {
return SK_ColorWHITE;
}
color_utils::HSL color_hsl;
color_utils::SkColorToHSL(avatar_fill_color, &color_hsl);
color_hsl.l = std::max(0., color_hsl.l - 0.5);
return color_utils::HSLToSkColor(color_hsl, SkColorGetA(avatar_fill_color));
}
chrome_colors::ColorInfo GenerateNewProfileColor() {
// TODO(crbug.com/1108295):
// - Implement more sophisticated algorithm to pick the new profile color.
......
......@@ -23,6 +23,9 @@ SkColor GetProfileForegroundTextColor(SkColor profile_highlight_color);
// highlight color.
SkColor GetProfileForegroundIconColor(SkColor profile_highlight_color);
// Returns the color that should be used to generate the default avatar icon.
SkColor GetAvatarStrokeColor(SkColor avatar_fill_color);
// Returns a new color for a profile, based on the colors of the existing
// profiles.
chrome_colors::ColorInfo GenerateNewProfileColor();
......
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