Commit a58ba7dd authored by Gayane Petrosyan's avatar Gayane Petrosyan Committed by Commit Bot

[Chrome Colors] Picker color value should be the user selected value.

Set picker value to the exact value that user selected instead of the
darkest of the calculated colors. These 2 colors are similar but not
always the same. Therefor picker value to the exact value so that selected color doesn't jump
after OnThemeUpdate.

Bug: 990379
Change-Id: Iac9ddae122be5daf01ec95bca571ec832aa5a981
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737330
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684413}
parent 6f6a5238
......@@ -2316,12 +2316,13 @@ customize.colorsMenuPreselectTile = function() {
}
} else if (
configData.chromeColorsCustomColorPicker && themeInfo.colorDark &&
themeInfo.colorLight) {
themeInfo.colorLight && themeInfo.colorPicked) {
// Custom color is selected.
tile = $(customize.IDS.COLOR_PICKER_TILE);
// Update color picker tile colors.
$(customize.IDS.COLOR_PICKER).value = colorArrayToHex(themeInfo.colorDark);
$(customize.IDS.COLOR_PICKER).value =
colorArrayToHex(themeInfo.colorPicked);
$(customize.IDS.COLORS_MENU)
.style.setProperty(
'--custom-color-border', colorArrayToHex(themeInfo.colorDark));
......
......@@ -746,6 +746,7 @@ void InstantService::BuildThemeInfo() {
theme_provider.GetColor(ThemeProperties::COLOR_FRAME);
theme_info_->color_light =
theme_provider.GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
theme_info_->color_picked = theme_service->GetThemeColor();
}
}
......
......@@ -83,4 +83,5 @@ IPC_STRUCT_TRAITS_BEGIN(ThemeBackgroundInfo)
IPC_STRUCT_TRAITS_MEMBER(color_id)
IPC_STRUCT_TRAITS_MEMBER(color_dark)
IPC_STRUCT_TRAITS_MEMBER(color_light)
IPC_STRUCT_TRAITS_MEMBER(color_picked)
IPC_STRUCT_TRAITS_END()
......@@ -29,7 +29,8 @@ bool ThemeBackgroundInfo::operator==(const ThemeBackgroundInfo& rhs) const {
logo_alternate == rhs.logo_alternate &&
has_theme_image == rhs.has_theme_image &&
theme_name == rhs.theme_name && color_id == rhs.color_id &&
color_dark == rhs.color_dark && color_light == rhs.color_light;
color_dark == rhs.color_dark && color_light == rhs.color_light &&
color_picked == rhs.color_picked;
}
InstantMostVisitedItem::InstantMostVisitedItem()
......
......@@ -115,13 +115,17 @@ struct ThemeBackgroundInfo {
// The color id for Chrome Colors. It is -1 if Chrome Colors is not set, 0
// when Chrome Colors is set but not from predefined color list, and > 0 if
// Chrome Colors is set from predefined color list.
int color_id = 0;
int color_id = -1;
// The dark color for Chrome Colors. Valid only if Chrome Colors is set.
SkColor color_dark = gfx::kPlaceholderColor;
// The light color for Chrome Colors. Valid only if Chrome Colors is set.
SkColor color_light = gfx::kPlaceholderColor;
// The picked custom color for Chrome Colors. Valid only if Chrome Colors is
// set.
SkColor color_picked = gfx::kPlaceholderColor;
};
struct InstantMostVisitedItem {
......
......@@ -445,6 +445,8 @@ v8::Local<v8::Object> GenerateThemeBackgroundInfo(
if (theme_info.color_id != -1) {
builder.Set("colorDark", SkColorToArray(isolate, theme_info.color_dark));
builder.Set("colorLight", SkColorToArray(isolate, theme_info.color_light));
builder.Set("colorPicked",
SkColorToArray(isolate, theme_info.color_picked));
}
return builder.Build();
......
......@@ -800,6 +800,7 @@ test.customizeMenu.testColors_PreselectColorPicker = function() {
colorId: 0,
colorDark: [100, 100, 100],
colorLight: [200, 200, 200],
colorPicked: [90, 90, 90],
};
init();
$(test.customizeMenu.IDS.EDIT_BG).click();
......
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