| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 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_BROWSER_EXTENSIONS_EXTENSION_ICON_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 |
| 16 class Extension; |
| 17 |
| 18 class ExtensionIconManager : public ImageLoadingTracker::Observer { |
| 19 public: |
| 20 ExtensionIconManager(); |
| 21 |
| 22 // Start loading the icon for the given extension. |
| 23 void LoadIcon(Extension* extension); |
| 24 |
| 25 // This returns a bitmap of width/height kFavIconSize, loaded either from an |
| 26 // entry specified in the extension's 'icon' section of the manifest, or a |
| 27 // default extension icon. |
| 28 const SkBitmap& GetIcon(const std::string& extension_id); |
| 29 |
| 30 // Removes the extension's icon from memory. |
| 31 void RemoveIcon(const std::string& extension_id); |
| 32 |
| 33 // Implements the ImageLoadingTracker::Observer interface. |
| 34 virtual void OnImageLoaded(SkBitmap* image, ExtensionResource resource, |
| 35 int index); |
| 36 |
| 37 void set_monochrome(bool value) { monochrome_ = value; } |
| 38 |
| 39 private: |
| 40 // Makes sure we've done one-time initialization of the default extension icon |
| 41 // default_icon_. |
| 42 void EnsureDefaultIcon(); |
| 43 |
| 44 // Helper function to return a copy of |src| with the proper scaling and |
| 45 // coloring. |
| 46 SkBitmap ApplyTransforms(const SkBitmap& src); |
| 47 |
| 48 // Used for loading extension icons. |
| 49 ImageLoadingTracker image_tracker_; |
| 50 |
| 51 // Maps extension id to an SkBitmap with the icon for that extension. |
| 52 std::map<std::string, SkBitmap> icons_; |
| 53 |
| 54 // Set of extension IDs waiting for icons to load. |
| 55 std::set<std::string> pending_icons_; |
| 56 |
| 57 // The default icon we'll use if an extension doesn't have one. |
| 58 SkBitmap default_icon_; |
| 59 |
| 60 // If true, we will desaturate the icons to make them monochromatic. |
| 61 bool monochrome_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(ExtensionIconManager); |
| 64 }; |
| 65 |
| 66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_MANAGER_H_ |
| OLD | NEW |