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

Propagate the toolbar color to related elements regardless if toolbar

image is specified.

Bug: 929393
Change-Id: Id7a0ad132f2266e4e5ce5843034379ceca3c468c
Reviewed-on: https://chromium-review.googlesource.com/c/1457336
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629818}
parent bd41feb6
...@@ -634,6 +634,10 @@ void BrowserThemePack::BuildFromExtension( ...@@ -634,6 +634,10 @@ void BrowserThemePack::BuildFromExtension(
pack->CropImages(&pack->images_); pack->CropImages(&pack->images_);
// Set toolbar related elements' colors (e.g. status bubble, info bar,
// download shelf, detached bookmark bar) to toolbar color.
pack->SetToolbarRelatedColors();
// Create toolbar image, and generate toolbar color from image where relevant. // Create toolbar image, and generate toolbar color from image where relevant.
// This must be done after reading colors from JSON (so they can be used for // This must be done after reading colors from JSON (so they can be used for
// compositing the image). // compositing the image).
...@@ -1272,6 +1276,19 @@ void BrowserThemePack::CropImages(ImageCache* images) const { ...@@ -1272,6 +1276,19 @@ void BrowserThemePack::CropImages(ImageCache* images) const {
} }
} }
void BrowserThemePack::SetToolbarRelatedColors() {
// Propagate the user-specified Toolbar Color to similar elements (for
// backwards-compatibility with themes written before this toolbar processing
// was introduced).
SkColor toolbar_color;
if (GetColor(TP::COLOR_TOOLBAR, &toolbar_color)) {
SetColor(TP::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND, toolbar_color);
SetColor(TP::COLOR_INFOBAR, toolbar_color);
SetColor(TP::COLOR_DOWNLOAD_SHELF, toolbar_color);
SetColor(TP::COLOR_STATUS_BUBBLE, toolbar_color);
}
}
void BrowserThemePack::CreateToolbarImageAndColors(ImageCache* images) { void BrowserThemePack::CreateToolbarImageAndColors(ImageCache* images) {
ImageCache temp_output; ImageCache temp_output;
...@@ -1285,15 +1302,7 @@ void BrowserThemePack::CreateToolbarImageAndColors(ImageCache* images) { ...@@ -1285,15 +1302,7 @@ void BrowserThemePack::CreateToolbarImageAndColors(ImageCache* images) {
constexpr int kToolbarColorId = TP::COLOR_TOOLBAR; constexpr int kToolbarColorId = TP::COLOR_TOOLBAR;
SkColor toolbar_color; SkColor toolbar_color;
// Propagate the user-specified Toolbar Color to similar elements (for if (!GetColor(kToolbarColorId, &toolbar_color)) {
// backwards-compatibility with themes written before this toolbar processing
// was introduced).
if (GetColor(kToolbarColorId, &toolbar_color)) {
SetColor(TP::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND, toolbar_color);
SetColor(TP::COLOR_INFOBAR, toolbar_color);
SetColor(TP::COLOR_DOWNLOAD_SHELF, toolbar_color);
SetColor(TP::COLOR_STATUS_BUBBLE, toolbar_color);
} else {
toolbar_color = TP::GetDefaultColor(kToolbarColorId, false); toolbar_color = TP::GetDefaultColor(kToolbarColorId, false);
} }
......
...@@ -167,6 +167,10 @@ class BrowserThemePack : public CustomThemeSupplier { ...@@ -167,6 +167,10 @@ class BrowserThemePack : public CustomThemeSupplier {
// can be of any size. Source and destination is |images|. // can be of any size. Source and destination is |images|.
void CropImages(ImageCache* images) const; void CropImages(ImageCache* images) const;
// Set toolbar related elements' colors (e.g. status bubble, info bar,
// download shelf, detached bookmark bar) to toolbar color.
void SetToolbarRelatedColors();
// Creates a composited toolbar image. Source and destination is |images|. // Creates a composited toolbar image. Source and destination is |images|.
// Also sets toolbar color corresponding to this image. // Also sets toolbar color corresponding to this image.
void CreateToolbarImageAndColors(ImageCache* images); void CreateToolbarImageAndColors(ImageCache* images);
......
...@@ -1014,6 +1014,30 @@ TEST_F(BrowserThemePackTest, TestToolbarColorPropagation) { ...@@ -1014,6 +1014,30 @@ TEST_F(BrowserThemePackTest, TestToolbarColorPropagation) {
EXPECT_EQ(infobar_color, status_bubble_color); EXPECT_EQ(infobar_color, status_bubble_color);
} }
// Ensure that a specified 'toolbar' color is propagated to other 'bar' and
// 'shelf' colors (before a new color is computed from the toolbar image).
TEST_F(BrowserThemePackTest, TestToolbarColorPropagationNoImage) {
scoped_refptr<BrowserThemePack> pack;
BuildTestExtensionTheme("theme_test_toolbar_color_no_image", &pack);
SkColor infobar_color;
SkColor bookmark_bar_color;
SkColor download_shelf_color;
SkColor status_bubble_color;
EXPECT_TRUE(pack->GetColor(TP::COLOR_INFOBAR, &infobar_color));
EXPECT_TRUE(pack->GetColor(TP::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND,
&bookmark_bar_color));
EXPECT_TRUE(pack->GetColor(TP::COLOR_DOWNLOAD_SHELF, &download_shelf_color));
EXPECT_TRUE(pack->GetColor(TP::COLOR_STATUS_BUBBLE, &status_bubble_color));
constexpr SkColor kExpectedColor = SkColorSetRGB(0, 255, 0);
EXPECT_EQ(infobar_color, kExpectedColor);
EXPECT_EQ(infobar_color, bookmark_bar_color);
EXPECT_EQ(infobar_color, download_shelf_color);
EXPECT_EQ(infobar_color, status_bubble_color);
}
// Ensure that, given an explicit toolbar color and a toolbar image, the output // Ensure that, given an explicit toolbar color and a toolbar image, the output
// color in COLOR_TOOLBAR reflects the color of the image (not the explicit // color in COLOR_TOOLBAR reflects the color of the image (not the explicit
// color). // color).
......
{
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuGMyBRIRAOiUgubfmS+4RHiNi/u/okGcU17xoKTXnziTiwmo7lq4V7unr3Vn4wWSG5bIG+yhQhQAG1TvfsXimBIUrrVKX4b9IADZIHR5akWgb1K4EV111PW/D8RDOwYgTPHPx5eA49TxB0Yw36DNC9LE0tPZOGgDR9hCFgaN1bcszlmJBcBmx39iGCeKPIjKB4bp5hXe33T5IUdoyuW4JHf4JDqC6unwQ1Y9nwzCRUbFis7YevbGQCgWP3I+Hp+bOo30mC2/Gq2UZfIczR4vIOrarxBV8IO4Ue4gzaDl6dGkGKnkZ3JdZKbLeRke1DmaKfjVSsTUp++X2nfMaPZphQIDAQAB",
"manifest_version": 2,
"name": "Toolbar Color with No Image Test",
"theme": {
"colors": {
"frame": [ 255, 0, 255 ],
"toolbar": [ 0, 255, 0 ]
}
},
"version": "0.0.1"
}
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