Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_EXTENSIONS_EXTENSION_ICON_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 // Represents the set of icons for an extension. | 11 // Represents the set of icons for an extension. |
| 12 class ExtensionIconSet { | 12 class ExtensionIconSet { |
| 13 public: | 13 public: |
| 14 // NOTE: If you change this list, you should also change kIconSizes in the cc | 14 // NOTE: If you change this list, you should also change kExtensionIconSizes |
| 15 // file. | 15 // in extension_constants.cc. |
| 16 enum Icons { | 16 enum ExtensionIcons { |
|
Aaron Boodman
2012/08/13 23:33:25
Can you move this enum to extension_constants, too
tbarzic
2012/08/14 18:06:57
Done.
| |
| 17 EXTENSION_ICON_GIGANTOR = 512, | 17 EXTENSION_ICON_GIGANTOR = 512, |
| 18 EXTENSION_ICON_EXTRA_LARGE = 256, | 18 EXTENSION_ICON_EXTRA_LARGE = 256, |
| 19 EXTENSION_ICON_LARGE = 128, | 19 EXTENSION_ICON_LARGE = 128, |
| 20 EXTENSION_ICON_MEDIUM = 48, | 20 EXTENSION_ICON_MEDIUM = 48, |
| 21 EXTENSION_ICON_SMALL = 32, | 21 EXTENSION_ICON_SMALL = 32, |
| 22 EXTENSION_ICON_SMALLISH = 24, | 22 EXTENSION_ICON_SMALLISH = 24, |
| 23 EXTENSION_ICON_BITTY = 16, | 23 EXTENSION_ICON_BITTY = 16, |
| 24 EXTENSION_ICON_INVALID = 0, | 24 EXTENSION_ICON_INVALID = 0, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 // Get an icon from the set, optionally falling back to a smaller or bigger | 27 // Get an icon from the set, optionally falling back to a smaller or bigger |
| 28 // size. MatchType is exclusive (do not OR them together). | 28 // size. MatchType is exclusive (do not OR them together). |
| 29 enum MatchType { | 29 enum MatchType { |
| 30 MATCH_EXACTLY, | 30 MATCH_EXACTLY, |
| 31 MATCH_BIGGER, | 31 MATCH_BIGGER, |
| 32 MATCH_SMALLER | 32 MATCH_SMALLER |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 // Access to the underlying map from icon size->path. | 35 // Access to the underlying map from icon size->{path, bitmap}. |
| 36 typedef std::map<Icons, std::string> IconMap; | 36 typedef std::map<int, std::string> IconMap; |
| 37 | |
| 38 // Icon sizes used by the extension system. | |
| 39 static const Icons kIconSizes[]; | |
| 40 static const size_t kNumIconSizes; | |
| 41 | 37 |
| 42 ExtensionIconSet(); | 38 ExtensionIconSet(); |
| 43 ~ExtensionIconSet(); | 39 ~ExtensionIconSet(); |
| 44 | 40 |
| 45 const IconMap& map() const { return map_; } | 41 const IconMap& map() const { return map_; } |
| 46 | 42 |
| 47 // Remove all icons from the set. | 43 // Remove all icons from the set. |
| 48 void Clear(); | 44 void Clear(); |
| 49 | 45 |
| 50 // Add an icon to the set. If the specified size is already present, it is | 46 // Add an icon path to the set. If a path for the specified size is already |
| 51 // overwritten. | 47 // present, it is overwritten. |
| 52 void Add(Icons size, const std::string& path); | 48 void Add(int size, const std::string& path); |
| 53 | 49 |
| 50 // Gets path value of the icon found when searching for |size| using | |
| 51 // |mathc_type|. | |
| 54 std::string Get(int size, MatchType match_type) const; | 52 std::string Get(int size, MatchType match_type) const; |
| 55 | 53 |
| 56 // Returns true if the set contains the specified path. | 54 // Returns true iff the set contains the specified path. |
| 57 bool ContainsPath(const std::string& path) const; | 55 bool ContainsPath(const std::string& path) const; |
| 58 | 56 |
| 59 // Returns icon size if the set contains the specified path or 0 if not found. | 57 // Returns icon size if the set contains the specified path or 0 if not found. |
| 60 Icons GetIconSizeFromPath(const std::string& path) const; | 58 int GetIconSizeFromPath(const std::string& path) const; |
| 61 | 59 |
| 62 private: | 60 private: |
| 63 IconMap map_; | 61 IconMap map_; |
| 64 }; | 62 }; |
| 65 | 63 |
| 66 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ | 64 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ |
| OLD | NEW |