| 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..1bce0cfb538ca454656aab3bd9042e49973f9e62
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/extension_action_util.cc
|
| @@ -0,0 +1,52 @@
|
| +// 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 PaintExtensionActionBackground(const ExtensionAction& action,
|
| + int tab_id,
|
| + gfx::Canvas* canvas,
|
| + const gfx::Rect& bounds,
|
| + SkColor text_color,
|
| + SkColor background_color) {
|
| + if (action.WantsAttention(tab_id)) {
|
| + SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()),
|
| + SkIntToScalar(bounds.y())},
|
| + {SkIntToScalar(bounds.x()),
|
| + SkIntToScalar(bounds.bottom())} };
|
| + 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
|
|
|