| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_ | 5 #ifndef EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_ |
| 6 #define EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_ | 6 #define EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/strings/string_piece.h" |
| 13 |
| 12 namespace base { | 14 namespace base { |
| 13 class FilePath; | 15 class FilePath; |
| 14 } | 16 } |
| 15 | 17 |
| 16 // Represents the set of icons for an extension. | 18 // Represents the set of icons for an extension. |
| 17 class ExtensionIconSet { | 19 class ExtensionIconSet { |
| 18 public: | 20 public: |
| 19 // Get an icon from the set, optionally falling back to a smaller or bigger | 21 // Get an icon from the set, optionally falling back to a smaller or bigger |
| 20 // size. MatchType is exclusive (do not OR them together). | 22 // size. MatchType is exclusive (do not OR them together). |
| 21 enum MatchType { | 23 enum MatchType { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 | 41 |
| 40 // Add an icon path to the set. If a path for the specified size is already | 42 // Add an icon path to the set. If a path for the specified size is already |
| 41 // present, it is overwritten. | 43 // present, it is overwritten. |
| 42 void Add(int size, const std::string& path); | 44 void Add(int size, const std::string& path); |
| 43 | 45 |
| 44 // Gets path value of the icon found when searching for |size| using | 46 // Gets path value of the icon found when searching for |size| using |
| 45 // |mathc_type|. | 47 // |mathc_type|. |
| 46 const std::string& Get(int size, MatchType match_type) const; | 48 const std::string& Get(int size, MatchType match_type) const; |
| 47 | 49 |
| 48 // Returns true iff the set contains the specified path. | 50 // Returns true iff the set contains the specified path. |
| 49 bool ContainsPath(const std::string& path) const; | 51 bool ContainsPath(base::StringPiece path) const; |
| 50 | 52 |
| 51 // Returns icon size if the set contains the specified path or 0 if not found. | 53 // Returns icon size if the set contains the specified path or 0 if not found. |
| 52 int GetIconSizeFromPath(const std::string& path) const; | 54 int GetIconSizeFromPath(base::StringPiece path) const; |
| 53 | 55 |
| 54 // Add the paths of all icons in this set into |paths|, handling the | 56 // Add the paths of all icons in this set into |paths|, handling the |
| 55 // conversion of (string) -> (base::FilePath). Note that these paths are not | 57 // conversion of (string) -> (base::FilePath). Note that these paths are not |
| 56 // validated in any way, so they may be invalid paths or reference | 58 // validated in any way, so they may be invalid paths or reference |
| 57 // nonexistent files. | 59 // nonexistent files. |
| 58 void GetPaths(std::set<base::FilePath>* paths) const; | 60 void GetPaths(std::set<base::FilePath>* paths) const; |
| 59 | 61 |
| 60 private: | 62 private: |
| 61 IconMap map_; | 63 IconMap map_; |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 #endif // EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_ | 66 #endif // EXTENSIONS_COMMON_EXTENSION_ICON_SET_H_ |
| OLD | NEW |