Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: extensions/common/extension_icon_set.h

Issue 2626923002: Make ExtensionIconSet::ContainsPath use StringPiece. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/BUILD.gn ('k') | extensions/common/extension_icon_set.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « extensions/common/BUILD.gn ('k') | extensions/common/extension_icon_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698