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

Unified Diff: chrome/browser/extensions/extension_action_util.cc

Issue 10834279: Give request-to-act badges a grey background, and increase spacing to make it fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use theme service to pick colors for icon background Created 8 years, 3 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/browser/extensions/extension_action_util.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_action_util.cc
diff --git a/chrome/browser/extensions/extension_action_util.cc b/chrome/browser/extensions/extension_action_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2460e4ce4cf00b26175bdfb775b4d01a3319e2f3
--- /dev/null
+++ b/chrome/browser/extensions/extension_action_util.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_action_util.h"
+
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/common/extensions/extension_action.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_utils.h"
+#include "ui/gfx/rect.h"
+
+namespace extensions {
+
+void PaintBackground(const ExtensionAction& action,
+ int tab_id,
+ gfx::Canvas* canvas,
+ const gfx::Rect& bounds,
+ const ui::ThemeProvider& theme) {
+ if (action.WantsAttention(tab_id)) {
+ SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.y())},
+ {SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.bottom())} };
+ const SkColor text_color = theme.GetColor(ThemeService::COLOR_NTP_TEXT);
Jeffrey Yasskin 2012/09/05 21:10:19 This isn't exactly right, since chrome-themes can
+ const SkColor background_color =
+ theme.GetColor(ThemeService::COLOR_NTP_BACKGROUND);
+ SkColor gradient_colors[2] = {
+ color_utils::AlphaBlend(text_color, background_color, 0x13),
+ color_utils::AlphaBlend(text_color, background_color, 0x1d)
+ };
+ SkShader* gradient = SkGradientShader::CreateLinear(
+ gradient_bounds, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
+ SkPaint paint;
+ paint.setShader(gradient);
+ gradient->unref();
+ canvas->DrawRect(bounds, paint);
+
+ SkColor border_color =
+ color_utils::AlphaBlend(text_color, background_color, 0x55);
+ canvas->DrawLine(gfx::Point(bounds.x(), bounds.y()),
+ gfx::Point(bounds.x(), bounds.bottom()),
+ border_color);
+ // "-1" because gfx::Rects are half-open, not including their right or
+ // bottom edges.
+ canvas->DrawLine(gfx::Point(bounds.right() - 1, bounds.y()),
+ gfx::Point(bounds.right() - 1, bounds.bottom()),
+ border_color);
+ }
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_action_util.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698