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

Side by Side Diff: chrome/common/icon_with_badge_image_source.h

Issue 1214243003: [Extensions UI] Clean up extension icon generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/skia/ImageSkia Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_ 5 #ifndef CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
6 #define CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_ 6 #define CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/common/extensions/api/extension_action/action_info.h" 10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/image/canvas_image_source.h" 11 #include "ui/gfx/image/canvas_image_source.h"
12 #include "ui/gfx/image/image_skia.h" 12 #include "ui/gfx/image/image.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 class Size; 15 class Size;
16 } 16 }
17 17
18 // CanvasImageSource for creating extension icon with a badge. 18 // CanvasImageSource for creating extension icon with a badge.
19 class IconWithBadgeImageSource 19 // TODO(devlin): This class and its buddy badge_util don't really belong in
20 : public gfx::CanvasImageSource { 20 // chrome/common/.
21 class IconWithBadgeImageSource : public gfx::CanvasImageSource {
21 public: 22 public:
22 IconWithBadgeImageSource( 23 // The data representing a badge to be painted over the base image.
23 const gfx::ImageSkia& icon, 24 struct Badge {
24 const gfx::Size& icon_size, 25 Badge(std::string text, SkColor text_color, SkColor background_color);
25 const gfx::Size& spacing, 26 ~Badge();
26 const std::string& text, 27
27 const SkColor& text_color, 28 std::string text;
28 const SkColor& background_color, 29 SkColor text_color;
29 extensions::ActionInfo::Type action_type); 30 SkColor background_color;
31
32 private:
33 DISALLOW_COPY_AND_ASSIGN(Badge);
34 };
35
36 explicit IconWithBadgeImageSource(const gfx::Size& size);
30 ~IconWithBadgeImageSource() override; 37 ~IconWithBadgeImageSource() override;
31 38
39 void SetIcon(const gfx::Image& icon);
40 void SetBadge(scoped_ptr<Badge> badge);
41
32 private: 42 private:
43 // gfx::CanvasImageSource:
33 void Draw(gfx::Canvas* canvas) override; 44 void Draw(gfx::Canvas* canvas) override;
34 45
35 // Browser action icon image. 46 // The base icon to draw.
36 gfx::ImageSkia icon_; 47 gfx::Image icon_;
37 48
38 // Extra spacing for badge compared to icon bounds. 49 // An optional badge to draw over the base icon.
39 gfx::Size spacing_; 50 scoped_ptr<Badge> badge_;
40
41 // Text to be displayed on the badge.
42 std::string text_;
43
44 // Color of badge text.
45 SkColor text_color_;
46
47 // Color of the badge.
48 SkColor background_color_;
49
50 // Type of extension action this is for.
51 extensions::ActionInfo::Type action_type_;
52 51
53 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource); 52 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource);
54 }; 53 };
55 54
56 #endif // CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_ 55 #endif // CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698