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.
5 #ifndef CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
6 #define CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/image/canvas_image_source.h"
12 #include "ui/gfx/image/image.h"
18 // CanvasImageSource for creating extension icon with a badge.
19 // TODO(devlin): This class and its buddy badge_util don't really belong in
21 class IconWithBadgeImageSource
: public gfx::CanvasImageSource
{
23 // The data representing a badge to be painted over the base image.
25 Badge(std::string text
, SkColor text_color
, SkColor background_color
);
30 SkColor background_color
;
33 DISALLOW_COPY_AND_ASSIGN(Badge
);
36 explicit IconWithBadgeImageSource(const gfx::Size
& size
);
37 ~IconWithBadgeImageSource() override
;
39 void SetIcon(const gfx::Image
& icon
);
40 void SetBadge(scoped_ptr
<Badge
> badge
);
41 void set_grayscale(bool grayscale
) { grayscale_
= grayscale
; }
42 void set_paint_decoration(bool paint_decoration
) {
43 paint_decoration_
= paint_decoration
;
46 bool grayscale() const { return grayscale_
; }
47 bool paint_decoration() const { return paint_decoration_
; }
50 // gfx::CanvasImageSource:
51 void Draw(gfx::Canvas
* canvas
) override
;
53 // Paints a decoration over the base icon to indicate that the action wants to
55 void PaintDecoration(gfx::Canvas
* canvas
);
57 // The base icon to draw.
60 // An optional badge to draw over the base icon.
61 scoped_ptr
<Badge
> badge_
;
63 // Whether or not the icon should be grayscaled (e.g., to show it is
67 // Whether or not to paint a decoration over the base icon to indicate the
68 // represented action wants to run.
69 bool paint_decoration_
;
71 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource
);
74 #endif // CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_