[BuildBreak] Linux: Fix g++ 4.8 compilation for error: multi-line comment [-Werror...
[chromium-blink-merge.git] / extensions / common / extension_icon_set.h
blob6a7697bb259148e897140b3ca99cb085b2c004b3
1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_
6 #define EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_
8 #include <map>
9 #include <string>
11 // Represents the set of icons for an extension.
12 class ExtensionIconSet {
13 public:
14 // Get an icon from the set, optionally falling back to a smaller or bigger
15 // size. MatchType is exclusive (do not OR them together).
16 enum MatchType {
17 MATCH_EXACTLY,
18 MATCH_BIGGER,
19 MATCH_SMALLER
22 // Access to the underlying map from icon size->{path, bitmap}.
23 typedef std::map<int, std::string> IconMap;
25 ExtensionIconSet();
26 ~ExtensionIconSet();
28 const IconMap& map() const { return map_; }
29 bool empty() const { return map_.empty(); }
31 // Remove all icons from the set.
32 void Clear();
34 // Add an icon path to the set. If a path for the specified size is already
35 // present, it is overwritten.
36 void Add(int size, const std::string& path);
38 // Gets path value of the icon found when searching for |size| using
39 // |mathc_type|.
40 std::string Get(int size, MatchType match_type) const;
42 // Returns true iff the set contains the specified path.
43 bool ContainsPath(const std::string& path) const;
45 // Returns icon size if the set contains the specified path or 0 if not found.
46 int GetIconSizeFromPath(const std::string& path) const;
48 private:
49 IconMap map_;
52 #endif // EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_