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

Unified Diff: chrome/common/extensions/extension_icon_set.h

Issue 10843014: Generalize ExtensionIconSet to store icon paths for custom size sets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension_icon_set.h
diff --git a/chrome/common/extensions/extension_icon_set.h b/chrome/common/extensions/extension_icon_set.h
index dc58813f27f03bda7afe3ab37e676276fe334fe7..9da1a558d1e401a9acc28feb7c33a427317ab9be 100644
--- a/chrome/common/extensions/extension_icon_set.h
+++ b/chrome/common/extensions/extension_icon_set.h
@@ -11,9 +11,14 @@
// Represents the set of icons for an extension.
class ExtensionIconSet {
public:
- // NOTE: If you change this list, you should also change kIconSizes in the cc
- // file.
- enum Icons {
+ // TODO(tbarzic): add types for extension actions and script badges.
+ enum IconSetType {
+ ICON_SET_MANIFEST_ICONS
+ };
+
+ // NOTE: If you change this list, you should also change kManifestIconSizes in
+ // the cc file Icons {
Aaron Boodman 2012/08/10 23:01:57 s/ file Icons {/./
tbarzic 2012/08/11 00:58:45 Done.
+ enum ExtensionIcons {
EXTENSION_ICON_GIGANTOR = 512,
EXTENSION_ICON_EXTRA_LARGE = 256,
EXTENSION_ICON_LARGE = 128,
@@ -32,14 +37,10 @@ class ExtensionIconSet {
MATCH_SMALLER
};
- // Access to the underlying map from icon size->path.
- typedef std::map<Icons, std::string> IconMap;
-
- // Icon sizes used by the extension system.
- static const Icons kIconSizes[];
- static const size_t kNumIconSizes;
+ // Access to the underlying map from icon size->{path, bitmap}.
+ typedef std::map<int, std::string> IconMap;
- ExtensionIconSet();
+ explicit ExtensionIconSet(IconSetType type);
~ExtensionIconSet();
const IconMap& map() const { return map_; }
@@ -47,19 +48,27 @@ class ExtensionIconSet {
// Remove all icons from the set.
void Clear();
- // Add an icon to the set. If the specified size is already present, it is
- // overwritten.
- void Add(Icons size, const std::string& path);
+ // Add an icon path to the set. If a path for the specified size is already
+ // present, it is overwritten.
+ void Add(int size, const std::string& path);
+ // Gets path value of the icon found when searching for |size| using
+ // |mathc_type|.
std::string Get(int size, MatchType match_type) const;
- // Returns true if the set contains the specified path.
+ // Returns true iff the set contains the specified path.
bool ContainsPath(const std::string& path) const;
// Returns icon size if the set contains the specified path or 0 if not found.
- Icons GetIconSizeFromPath(const std::string& path) const;
+ int GetIconSizeFromPath(const std::string& path) const;
+
+ const int* const allowed_sizes() const { return allowed_sizes_; }
+
+ size_t num_allowed_sizes() const { return num_allowed_sizes_; }
private:
+ const int* allowed_sizes_;
+ size_t num_allowed_sizes_;
IconMap map_;
};

Powered by Google App Engine
This is Rietveld 408576698