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

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

Issue 225043002: Move extension_icon_set.{h,cc} to //extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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
deleted file mode 100644
index bb8c763df38469d923a295e6b04e27d47f80abff..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/extension_icon_set.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/extensions/extension_icon_set.h"
-
-#include "base/logging.h"
-
-ExtensionIconSet::ExtensionIconSet() {}
-
-ExtensionIconSet::~ExtensionIconSet() {}
-
-void ExtensionIconSet::Clear() {
- map_.clear();
-}
-
-void ExtensionIconSet::Add(int size, const std::string& path) {
- DCHECK(!path.empty() && path[0] != '/');
- map_[size] = path;
-}
-
-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(size);
- return result == map_.end() ? std::string() : result->second;
- } else if (match_type == MATCH_SMALLER) {
- IconMap::const_reverse_iterator result = map_.rend();
- for (IconMap::const_reverse_iterator iter = map_.rbegin();
- iter != map_.rend(); ++iter) {
- if (iter->first <= size) {
- result = iter;
- break;
- }
- }
- return result == map_.rend() ? std::string() : result->second;
- } else {
- DCHECK(match_type == MATCH_BIGGER);
- IconMap::const_iterator result = map_.end();
- for (IconMap::const_iterator iter = map_.begin(); iter != map_.end();
- ++iter) {
- if (iter->first >= size) {
- result = iter;
- break;
- }
- }
- return result == map_.end() ? std::string() : result->second;
- }
-}
-
-bool ExtensionIconSet::ContainsPath(const std::string& path) const {
- return GetIconSizeFromPath(path) != 0;
-}
-
-int ExtensionIconSet::GetIconSizeFromPath(const std::string& path) const {
- if (path.empty())
- return 0;
-
- DCHECK(path[0] != '/') <<
- "ExtensionIconSet stores icon paths without leading slash.";
-
- for (IconMap::const_iterator iter = map_.begin(); iter != map_.end();
- ++iter) {
- if (iter->second == path)
- return iter->first;
- }
-
- 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