Roll src/third_party/WebKit b3f094a:f697bbd (svn 194310:194313)
[chromium-blink-merge.git] / extensions / common / extension_icon_set.h
blobe491b72c111724200c792dde5c0fd9be98ce72da
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 <set>
10 #include <string>
12 namespace base {
13 class FilePath;
16 // Represents the set of icons for an extension.
17 class ExtensionIconSet {
18 public:
19 // Get an icon from the set, optionally falling back to a smaller or bigger
20 // size. MatchType is exclusive (do not OR them together).
21 enum MatchType {
22 MATCH_EXACTLY,
23 MATCH_BIGGER,
24 MATCH_SMALLER
27 // Access to the underlying map from icon size->{path, bitmap}.
28 typedef std::map<int, std::string> IconMap;
30 ExtensionIconSet();
31 ~ExtensionIconSet();
33 const IconMap& map() const { return map_; }
34 bool empty() const { return map_.empty(); }
36 // Remove all icons from the set.
37 void Clear();
39 // Add an icon path to the set. If a path for the specified size is already
40 // present, it is overwritten.
41 void Add(int size, const std::string& path);
43 // Gets path value of the icon found when searching for |size| using
44 // |mathc_type|.
45 const std::string& Get(int size, MatchType match_type) const;
47 // Returns true iff the set contains the specified path.
48 bool ContainsPath(const std::string& path) const;
50 // Returns icon size if the set contains the specified path or 0 if not found.
51 int GetIconSizeFromPath(const std::string& path) const;
53 // Add the paths of all icons in this set into |paths|, handling the
54 // conversion of (string) -> (base::FilePath). Note that these paths are not
55 // validated in any way, so they may be invalid paths or reference
56 // nonexistent files.
57 void GetPaths(std::set<base::FilePath>* paths) const;
59 private:
60 IconMap map_;
63 #endif // EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_