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

Side by Side Diff: chrome/common/extensions/extension_icon_set.cc

Issue 6609008: Change other usages of .size() to .empty() when applicable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter nits Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/update_manifest.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 (c) 2010 The Chromium Authors. All rights reserved. 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 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 #include "chrome/common/extensions/extension_icon_set.h" 5 #include "chrome/common/extensions/extension_icon_set.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 ExtensionIconSet::ExtensionIconSet() {} 9 ExtensionIconSet::ExtensionIconSet() {}
10 10
11 ExtensionIconSet::~ExtensionIconSet() {} 11 ExtensionIconSet::~ExtensionIconSet() {}
12 12
13 void ExtensionIconSet::Clear() { 13 void ExtensionIconSet::Clear() {
14 map_.clear(); 14 map_.clear();
15 } 15 }
16 16
17 void ExtensionIconSet::Add(int size, const std::string& path) { 17 void ExtensionIconSet::Add(int size, const std::string& path) {
18 CHECK(path.size() > 0 && path[0] != '/'); 18 CHECK(!path.empty() && path[0] != '/');
19 map_[size] = path; 19 map_[size] = path;
20 } 20 }
21 21
22 std::string ExtensionIconSet::Get(int size, MatchType match_type) const { 22 std::string ExtensionIconSet::Get(int size, MatchType match_type) const {
23 // The searches for MATCH_BIGGER and MATCH_SMALLER below rely on the fact that 23 // The searches for MATCH_BIGGER and MATCH_SMALLER below rely on the fact that
24 // std::map is sorted. This is per the spec, so it should be safe to rely on. 24 // std::map is sorted. This is per the spec, so it should be safe to rely on.
25 if (match_type == MATCH_EXACTLY) { 25 if (match_type == MATCH_EXACTLY) {
26 IconMap::const_iterator result = map_.find(size); 26 IconMap::const_iterator result = map_.find(size);
27 return result == map_.end() ? std::string() : result->second; 27 return result == map_.end() ? std::string() : result->second;
28 } else if (match_type == MATCH_SMALLER) { 28 } else if (match_type == MATCH_SMALLER) {
(...skipping 28 matching lines...) Expand all
57 "ExtensionIconSet stores icon paths without leading slash."; 57 "ExtensionIconSet stores icon paths without leading slash.";
58 58
59 for (IconMap::const_iterator iter = map_.begin(); iter != map_.end(); 59 for (IconMap::const_iterator iter = map_.begin(); iter != map_.end();
60 ++iter) { 60 ++iter) {
61 if (iter->second == path) 61 if (iter->second == path)
62 return true; 62 return true;
63 } 63 }
64 64
65 return false; 65 return false;
66 } 66 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/update_manifest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698