Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/ui/extensions/icon_with_badge_image_source.cc

Issue 2093973002: Ignore alpha value in extension-specified badge bg color. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: commentary Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h" 5 #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void IconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { 161 void IconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) {
162 if (!badge_ || badge_->text.empty()) 162 if (!badge_ || badge_->text.empty())
163 return; 163 return;
164 164
165 SkColor text_color = SkColorGetA(badge_->text_color) == SK_AlphaTRANSPARENT 165 SkColor text_color = SkColorGetA(badge_->text_color) == SK_AlphaTRANSPARENT
166 ? SK_ColorWHITE 166 ? SK_ColorWHITE
167 : badge_->text_color; 167 : badge_->text_color;
168 168
169 SkColor background_color = ui::MaterialDesignController::IsModeMaterial() 169 SkColor background_color = ui::MaterialDesignController::IsModeMaterial()
170 ? gfx::kGoogleBlue500 170 ? gfx::kGoogleBlue500
171 : SkColorSetARGB(255, 218, 0, 24); 171 : SkColorSetRGB(218, 0, 24);
172 if (SkColorGetA(badge_->background_color) != SK_AlphaTRANSPARENT) 172 if (SkColorGetA(badge_->background_color) != SK_AlphaTRANSPARENT)
173 background_color = badge_->background_color; 173 background_color = badge_->background_color;
174 // Make sure the background color is opaque. See http://crbug.com/619499
175 if (ui::MaterialDesignController::IsModeMaterial())
176 background_color = SkColorSetA(background_color, SK_AlphaOPAQUE);
174 177
175 canvas->Save(); 178 canvas->Save();
176 179
177 SkPaint* text_paint = nullptr; 180 SkPaint* text_paint = nullptr;
178 int text_width = 0; 181 int text_width = 0;
179 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); 182 ResourceBundle* rb = &ResourceBundle::GetSharedInstance();
180 gfx::FontList base_font = rb->GetFontList(ResourceBundle::BaseFont) 183 gfx::FontList base_font = rb->GetFontList(ResourceBundle::BaseFont)
181 .DeriveWithHeightUpperBound(kBadgeHeight); 184 .DeriveWithHeightUpperBound(kBadgeHeight);
182 base::string16 utf16_text = base::UTF8ToUTF16(badge_->text); 185 base::string16 utf16_text = base::UTF8ToUTF16(badge_->text);
183 186
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 309 }
307 310
308 void IconWithBadgeImageSource::PaintBlockedActionDecoration( 311 void IconWithBadgeImageSource::PaintBlockedActionDecoration(
309 gfx::Canvas* canvas) { 312 gfx::Canvas* canvas) {
310 canvas->Save(); 313 canvas->Save();
311 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 314 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
312 IDR_BLOCKED_EXTENSION_SCRIPT); 315 IDR_BLOCKED_EXTENSION_SCRIPT);
313 canvas->DrawImageInt(img, size().width() - img.width(), 0); 316 canvas->DrawImageInt(img, size().width() - img.width(), 0);
314 canvas->Restore(); 317 canvas->Restore();
315 } 318 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698