Home | History | Annotate | Download | only in common
      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 #ifndef CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
      6 #define CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
      7 
      8 #include <string>
      9 
     10 #include "chrome/common/extensions/api/extension_action/action_info.h"
     11 #include "ui/gfx/image/canvas_image_source.h"
     12 #include "ui/gfx/image/image_skia.h"
     13 
     14 namespace gfx {
     15 class Size;
     16 }
     17 
     18 // CanvasImageSource for creating extension icon with a badge.
     19 class IconWithBadgeImageSource
     20     : public gfx::CanvasImageSource {
     21  public:
     22   IconWithBadgeImageSource(
     23       const gfx::ImageSkia& icon,
     24       const gfx::Size& icon_size,
     25       const gfx::Size& spacing,
     26       const std::string& text,
     27       const SkColor& text_color,
     28       const SkColor& background_color,
     29       extensions::ActionInfo::Type action_type);
     30   virtual ~IconWithBadgeImageSource();
     31 
     32  private:
     33   virtual void Draw(gfx::Canvas* canvas) OVERRIDE;
     34 
     35   // Browser action icon image.
     36   gfx::ImageSkia icon_;
     37 
     38   // Extra spacing for badge compared to icon bounds.
     39   gfx::Size spacing_;
     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 
     53   DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource);
     54 };
     55 
     56 #endif  // CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
     57