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 #include "extensions/common/extension_icon_set.h" | 5 #include "extensions/common/extension_icon_set.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 ++iter) { | 46 ++iter) { |
47 if (iter->first >= size) { | 47 if (iter->first >= size) { |
48 result = iter; | 48 result = iter; |
49 break; | 49 break; |
50 } | 50 } |
51 } | 51 } |
52 return result == map_.end() ? base::EmptyString() : result->second; | 52 return result == map_.end() ? base::EmptyString() : result->second; |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 bool ExtensionIconSet::ContainsPath(const std::string& path) const { | 56 bool ExtensionIconSet::ContainsPath(base::StringPiece path) const { |
57 return GetIconSizeFromPath(path) != 0; | 57 return GetIconSizeFromPath(path) != 0; |
58 } | 58 } |
59 | 59 |
60 int ExtensionIconSet::GetIconSizeFromPath(const std::string& path) const { | 60 int ExtensionIconSet::GetIconSizeFromPath(base::StringPiece path) const { |
61 if (path.empty()) | 61 if (path.empty()) |
62 return 0; | 62 return 0; |
63 | 63 |
64 DCHECK_NE(path[0], '/') << | 64 DCHECK_NE(path[0], '/') << |
65 "ExtensionIconSet stores icon paths without leading slash."; | 65 "ExtensionIconSet stores icon paths without leading slash."; |
66 | 66 |
67 for (IconMap::const_iterator iter = map_.begin(); iter != map_.end(); | 67 for (IconMap::const_iterator iter = map_.begin(); iter != map_.end(); |
68 ++iter) { | 68 ++iter) { |
69 if (iter->second == path) | 69 if (iter->second == path) |
70 return iter->first; | 70 return iter->first; |
71 } | 71 } |
72 | 72 |
73 return 0; | 73 return 0; |
74 } | 74 } |
75 | 75 |
76 void ExtensionIconSet::GetPaths(std::set<base::FilePath>* paths) const { | 76 void ExtensionIconSet::GetPaths(std::set<base::FilePath>* paths) const { |
77 CHECK(paths); | 77 CHECK(paths); |
78 for (auto iter : map()) | 78 for (auto iter : map()) |
79 paths->insert(base::FilePath::FromUTF8Unsafe(iter.second)); | 79 paths->insert(base::FilePath::FromUTF8Unsafe(iter.second)); |
80 } | 80 } |
OLD | NEW |