| Index: chrome/common/extensions/extension_action.h
|
| diff --git a/chrome/common/extensions/extension_action.h b/chrome/common/extensions/extension_action.h
|
| index 5fc860fee53e6f6ec19de3d56e8579039c2c7186..48c258215440d75e8b08ed58e264af8000ebcdbe 100644
|
| --- a/chrome/common/extensions/extension_action.h
|
| +++ b/chrome/common/extensions/extension_action.h
|
| @@ -23,8 +23,9 @@ class SkDevice;
|
|
|
| namespace gfx {
|
| class Canvas;
|
| -class Image;
|
| +class ImageSkia;
|
| class Rect;
|
| +class Size;
|
| }
|
|
|
| // ExtensionAction encapsulates the state of a browser action, page action, or
|
| @@ -162,16 +163,16 @@ class ExtensionAction {
|
| // result.
|
| //
|
| // If an image is cached redundantly, the first load will be used.
|
| - void CacheIcon(const std::string& path, const gfx::Image& icon);
|
| + void CacheIcon(const std::string& path, const gfx::ImageSkia& icon);
|
|
|
| // Set this action's icon bitmap on a specific tab.
|
| - void SetIcon(int tab_id, const SkBitmap& bitmap);
|
| + void SetIcon(int tab_id, const gfx::ImageSkia& bitmap);
|
|
|
| // Get the icon for a tab, or the default if no icon was set for this tab,
|
| // retrieving icons that have been specified by path from the previous
|
| // arguments to CacheIcon(). If the default icon isn't found in the cache,
|
| // returns the puzzle piece icon.
|
| - gfx::Image GetIcon(int tab_id) const;
|
| + gfx::ImageSkia GetIcon(int tab_id) const;
|
|
|
| // Set this action's icon index for a specific tab. For use with
|
| // icon_paths(), only used in page actions.
|
| @@ -237,6 +238,11 @@ class ExtensionAction {
|
| // If the specified tab has a badge, paint it into the provided bounds.
|
| void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds, int tab_id);
|
|
|
| + // Returns icon image with badge for specified tab.
|
| + gfx::ImageSkia GetIconWithBadge(const gfx::ImageSkia& icon,
|
| + int tab_id,
|
| + const gfx::Size& spacing) const;
|
| +
|
| // Gets a weak reference to the icon animation for a tab, if any. The
|
| // reference will only have a value while the animation is running.
|
| base::WeakPtr<IconAnimation> GetIconAnimation(int tab_id) const;
|
| @@ -245,7 +251,10 @@ class ExtensionAction {
|
| // Runs an animation on a tab.
|
| void RunIconAnimation(int tab_id);
|
|
|
| + private:
|
| class IconAnimationWrapper;
|
| + class AnimatedIconImageSource;
|
| + class IconWithBadgeImageSource;
|
|
|
| // Finds the icon animation wrapper for a tab, if any. If the animation for
|
| // this tab has recently completed, also removes up any other dead wrappers
|
| @@ -254,7 +263,16 @@ class ExtensionAction {
|
|
|
| // If the icon animation is running on tab |tab_id|, applies it to
|
| // |orig| and returns the result. Otherwise, just returns |orig|.
|
| - gfx::Image ApplyIconAnimation(int tab_id, const gfx::Image& orig) const;
|
| + gfx::ImageSkia ApplyIconAnimation(int tab_id,
|
| + const gfx::ImageSkia& orig) const;
|
| +
|
| + // Paints badge with specified parameters to |canvas|.
|
| + static void DoPaintBadge(gfx::Canvas* canvas,
|
| + const gfx::Rect& bounds,
|
| + const std::string& text,
|
| + const SkColor& text_color_in,
|
| + const SkColor& background_color_in,
|
| + int icon_width);
|
|
|
| template <class T>
|
| struct ValueTraits {
|
| @@ -289,7 +307,7 @@ class ExtensionAction {
|
| // kDefaultTabId), or tab-specific state (stored with the tab_id as the key).
|
| std::map<int, GURL> popup_url_;
|
| std::map<int, std::string> title_;
|
| - std::map<int, gfx::Image> icon_;
|
| + std::map<int, gfx::ImageSkia> icon_;
|
| std::map<int, int> icon_index_; // index into icon_paths_
|
| std::map<int, std::string> badge_text_;
|
| std::map<int, SkColor> badge_background_color_;
|
| @@ -315,7 +333,7 @@ class ExtensionAction {
|
| std::vector<std::string> icon_paths_;
|
|
|
| // Saves the arguments from CacheIcon() calls.
|
| - std::map<std::string, gfx::Image> path_to_icon_cache_;
|
| + std::map<std::string, gfx::ImageSkia> path_to_icon_cache_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionAction);
|
| };
|
|
|