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

Side by Side 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: Final (??) Windows and GTK support 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_action_util.h"
6
7 #include "chrome/browser/themes/theme_service.h"
8 #include "chrome/common/extensions/extension_action.h"
9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "third_party/skia/include/effects/SkGradientShader.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/color_utils.h"
13 #include "ui/gfx/rect.h"
14
15 namespace extensions {
16
17 void PaintExtensionActionBackground(const ExtensionAction& action,
18 int tab_id,
19 gfx::Canvas* canvas,
20 const gfx::Rect& bounds,
21 SkColor text_color,
22 SkColor background_color) {
23 if (action.WantsAttention(tab_id)) {
24 SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()),
25 SkIntToScalar(bounds.y())},
26 {SkIntToScalar(bounds.x()),
27 SkIntToScalar(bounds.bottom())} };
28 SkColor gradient_colors[2] = {
29 color_utils::AlphaBlend(text_color, background_color, 0x13),
30 color_utils::AlphaBlend(text_color, background_color, 0x1d)
31 };
32 SkShader* gradient = SkGradientShader::CreateLinear(
33 gradient_bounds, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
34 SkPaint paint;
35 paint.setShader(gradient);
36 gradient->unref();
37 canvas->DrawRect(bounds, paint);
38
39 SkColor border_color =
40 color_utils::AlphaBlend(text_color, background_color, 0x55);
41 canvas->DrawLine(gfx::Point(bounds.x(), bounds.y()),
42 gfx::Point(bounds.x(), bounds.bottom()),
43 border_color);
44 // "-1" because gfx::Rects are half-open, not including their right or
45 // bottom edges.
46 canvas->DrawLine(gfx::Point(bounds.right() - 1, bounds.y()),
47 gfx::Point(bounds.right() - 1, bounds.bottom()),
48 border_color);
49 }
50 }
51
52 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698