1 // Copyright (c) 2010 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. 4 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ 7 #pragma once 8 9 #include <map> 10 #include <string> 11 12 // Represents the set of icons for an extension. 13 class ExtensionIconSet { 14 public: 15 ExtensionIconSet(); 16 ~ExtensionIconSet(); 17 18 // Access to the underlying map from icon size->path. 19 typedef std::map<int, std::string> IconMap; 20 const IconMap& map() const { return map_; } 21 22 // Remove all icons from the set. 23 void Clear(); 24 25 // Add an icon to the set. If the specified size is already present, it is 26 // overwritten. 27 void Add(int size, const std::string& path); 28 29 // Get an icon from the set, optionally falling back to a smaller or bigger 30 // size. MatchType is exclusive (do not OR them together). 31 enum MatchType { 32 MATCH_EXACTLY, 33 MATCH_BIGGER, 34 MATCH_SMALLER 35 }; 36 std::string Get(int size, MatchType match_type) const; 37 38 // Returns true if the set contains the specified path. 39 bool ContainsPath(const std::string& path) const; 40 41 private: 42 IconMap map_; 43 }; 44 45 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ICON_SET_H_ 46