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

Unified Diff: chrome/common/extensions/extension_icon_set.cc

Issue 10843014: Generalize ExtensionIconSet to store icon paths for custom size sets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension_icon_set.cc
diff --git a/chrome/common/extensions/extension_icon_set.cc b/chrome/common/extensions/extension_icon_set.cc
index 588d0546f12f0cd5baffee63fb8c3fce781f9fb3..bb8c763df38469d923a295e6b04e27d47f80abff 100644
--- a/chrome/common/extensions/extension_icon_set.cc
+++ b/chrome/common/extensions/extension_icon_set.cc
@@ -10,24 +10,11 @@ ExtensionIconSet::ExtensionIconSet() {}
ExtensionIconSet::~ExtensionIconSet() {}
-const ExtensionIconSet::Icons ExtensionIconSet::kIconSizes[] = {
- EXTENSION_ICON_GIGANTOR,
- EXTENSION_ICON_EXTRA_LARGE,
- EXTENSION_ICON_LARGE,
- EXTENSION_ICON_MEDIUM,
- EXTENSION_ICON_SMALL,
- EXTENSION_ICON_SMALLISH,
- EXTENSION_ICON_BITTY
-};
-
-const size_t ExtensionIconSet::kNumIconSizes =
- arraysize(ExtensionIconSet::kIconSizes);
-
void ExtensionIconSet::Clear() {
map_.clear();
}
-void ExtensionIconSet::Add(Icons size, const std::string& path) {
+void ExtensionIconSet::Add(int size, const std::string& path) {
DCHECK(!path.empty() && path[0] != '/');
map_[size] = path;
}
@@ -36,7 +23,7 @@ std::string ExtensionIconSet::Get(int size, MatchType match_type) const {
// The searches for MATCH_BIGGER and MATCH_SMALLER below rely on the fact that
// std::map is sorted. This is per the spec, so it should be safe to rely on.
if (match_type == MATCH_EXACTLY) {
- IconMap::const_iterator result = map_.find(static_cast<Icons>(size));
+ IconMap::const_iterator result = map_.find(size);
return result == map_.end() ? std::string() : result->second;
} else if (match_type == MATCH_SMALLER) {
IconMap::const_reverse_iterator result = map_.rend();
@@ -63,13 +50,12 @@ std::string ExtensionIconSet::Get(int size, MatchType match_type) const {
}
bool ExtensionIconSet::ContainsPath(const std::string& path) const {
- return GetIconSizeFromPath(path) != EXTENSION_ICON_INVALID;
+ return GetIconSizeFromPath(path) != 0;
}
-ExtensionIconSet::Icons ExtensionIconSet::GetIconSizeFromPath(
- const std::string& path) const {
+int ExtensionIconSet::GetIconSizeFromPath(const std::string& path) const {
if (path.empty())
- return EXTENSION_ICON_INVALID;
+ return 0;
DCHECK(path[0] != '/') <<
"ExtensionIconSet stores icon paths without leading slash.";
@@ -80,5 +66,5 @@ ExtensionIconSet::Icons ExtensionIconSet::GetIconSizeFromPath(
return iter->first;
}
- return EXTENSION_ICON_INVALID;
+ return 0;
}
« no previous file with comments | « chrome/common/extensions/extension_icon_set.h ('k') | chrome/common/extensions/extension_icon_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698