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 | |
15 // file. | |
16 enum Icons { | |
17 EXTENSION_ICON_GIGANTOR = 512, | |
18 EXTENSION_ICON_EXTRA_LARGE = 256, | |
19 EXTENSION_ICON_LARGE = 128, | |
20 EXTENSION_ICON_MEDIUM = 48, | |
21 EXTENSION_ICON_SMALL = 32, | |
22 EXTENSION_ICON_SMALLISH = 24, | |
23 EXTENSION_ICON_BITTY = 16, | |
24 EXTENSION_ICON_INVALID = 0, | |
25 }; | |
26 | |
27 // Get an icon from the set, optionally falling back to a smaller or bigger | 14 // Get an icon from the set, optionally falling back to a smaller or bigger |
28 // size. MatchType is exclusive (do not OR them together). | 15 // size. MatchType is exclusive (do not OR them together). |
29 enum MatchType { | 16 enum MatchType { |
30 MATCH_EXACTLY, | 17 MATCH_EXACTLY, |
31 MATCH_BIGGER, | 18 MATCH_BIGGER, |
32 MATCH_SMALLER | 19 MATCH_SMALLER |
33 }; | 20 }; |
34 | 21 |
35 // Access to the underlying map from icon size->path. | 22 // Access to the underlying map from icon size->{path, bitmap}. |
36 typedef std::map<Icons, std::string> IconMap; | 23 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 | 24 |
42 ExtensionIconSet(); | 25 ExtensionIconSet(); |
43 ~ExtensionIconSet(); | 26 ~ExtensionIconSet(); |
44 | 27 |
45 const IconMap& map() const { return map_; } | 28 const IconMap& map() const { return map_; } |
46 | 29 |
47 // Remove all icons from the set. | 30 // Remove all icons from the set. |
48 void Clear(); | 31 void Clear(); |
49 | 32 |
50 // Add an icon to the set. If the specified size is already present, it is | 33 // Add an icon path to the set. If a path for the specified size is already |
51 // overwritten. | 34 // present, it is overwritten. |
52 void Add(Icons size, const std::string& path); | 35 void Add(int size, const std::string& path); |
53 | 36 |
| 37 // Gets path value of the icon found when searching for |size| using |
| 38 // |mathc_type|. |
54 std::string Get(int size, MatchType match_type) const; | 39 std::string Get(int size, MatchType match_type) const; |
55 | 40 |
56 // Returns true if the set contains the specified path. | 41 // Returns true iff the set contains the specified path. |
57 bool ContainsPath(const std::string& path) const; | 42 bool ContainsPath(const std::string& path) const; |
58 | 43 |
59 // Returns icon size if the set contains the specified path or 0 if not found. | 44 // Returns icon size if the set contains the specified path or 0 if not found. |
60 Icons GetIconSizeFromPath(const std::string& path) const; | 45 int GetIconSizeFromPath(const std::string& path) const; |
61 | 46 |
62 private: | 47 private: |
63 IconMap map_; | 48 IconMap map_; |
64 }; | 49 }; |
65 | 50 |
66 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ | 51 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ |
OLD | NEW |