Chromium Code Reviews| 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 |