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

Unified Diff: chrome/common/extensions/extension_action.cc

Issue 306044: Refactor implementation of BrowserActions, and add support for (Closed)
Patch Set: Make it work on linux too Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_action.h ('k') | chrome/common/extensions/extension_action2.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_action.cc
diff --git a/chrome/common/extensions/extension_action.cc b/chrome/common/extensions/extension_action.cc
index de15f178cd2f4b8a0049b83987c6619151c997de..246961f1a3410ee0719713641df3546c9b53095c 100644
--- a/chrome/common/extensions/extension_action.cc
+++ b/chrome/common/extensions/extension_action.cc
@@ -20,11 +20,19 @@ ExtensionAction::~ExtensionAction() {
}
void ExtensionActionState::PaintBadge(gfx::Canvas* canvas,
- const gfx::Rect& bounds) const {
- const std::string& text = badge_text();
+ const gfx::Rect& bounds,
+ const std::string& text,
+ SkColor text_color,
+ SkColor background_color) {
if (text.empty())
return;
+ if (SkColorGetA(text_color) == 0x00)
+ text_color = SK_ColorWHITE;
+
+ if (SkColorGetA(background_color) == 0x00)
+ background_color = SkColorSetARGB(255, 218, 0, 24); // default badge color
+
// Different platforms need slightly different constants to look good.
#if defined(OS_LINUX)
const int kTextSize = 9;
@@ -49,7 +57,7 @@ void ExtensionActionState::PaintBadge(gfx::Canvas* canvas,
SkTypeface* typeface = SkTypeface::CreateFromName("Arial", SkTypeface::kBold);
SkPaint text_paint;
text_paint.setAntiAlias(true);
- text_paint.setColor(badge_text_color());
+ text_paint.setColor(text_color);
text_paint.setFakeBoldText(true);
text_paint.setTextAlign(SkPaint::kLeft_Align);
text_paint.setTextSize(SkIntToScalar(kTextSize));
@@ -81,7 +89,7 @@ void ExtensionActionState::PaintBadge(gfx::Canvas* canvas,
SkPaint rect_paint;
rect_paint.setStyle(SkPaint::kFill_Style);
rect_paint.setAntiAlias(true);
- rect_paint.setColor(badge_background_color());
+ rect_paint.setColor(background_color);
canvas->drawRoundRect(rect, SkIntToScalar(2), SkIntToScalar(2), rect_paint);
// Overlay the gradient. It is stretchy, so we do this in three parts.
« no previous file with comments | « chrome/common/extensions/extension_action.h ('k') | chrome/common/extensions/extension_action2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698