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/manifest_handlers/icons_handler.h" | 5 #include "extensions/common/manifest_handlers/icons_handler.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 IconsInfo* info = static_cast<IconsInfo*>( | 30 IconsInfo* info = static_cast<IconsInfo*>( |
31 extension->GetManifestData(keys::kIcons)); | 31 extension->GetManifestData(keys::kIcons)); |
32 return info ? info->icons : g_empty_icon_set.Get(); | 32 return info ? info->icons : g_empty_icon_set.Get(); |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 ExtensionResource IconsInfo::GetIconResource( | 36 ExtensionResource IconsInfo::GetIconResource( |
37 const Extension* extension, | 37 const Extension* extension, |
38 int size, | 38 int size, |
39 ExtensionIconSet::MatchType match_type) { | 39 ExtensionIconSet::MatchType match_type) { |
40 std::string path = GetIcons(extension).Get(size, match_type); | 40 const std::string& path = GetIcons(extension).Get(size, match_type); |
41 return path.empty() ? ExtensionResource() : extension->GetResource(path); | 41 return path.empty() ? ExtensionResource() : extension->GetResource(path); |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 GURL IconsInfo::GetIconURL(const Extension* extension, | 45 GURL IconsInfo::GetIconURL(const Extension* extension, |
46 int size, | 46 int size, |
47 ExtensionIconSet::MatchType match_type) { | 47 ExtensionIconSet::MatchType match_type) { |
48 std::string path = GetIcons(extension).Get(size, match_type); | 48 const std::string& path = GetIcons(extension).Get(size, match_type); |
49 return path.empty() ? GURL() : extension->GetResourceURL(path); | 49 return path.empty() ? GURL() : extension->GetResourceURL(path); |
50 } | 50 } |
51 | 51 |
52 IconsHandler::IconsHandler() { | 52 IconsHandler::IconsHandler() { |
53 } | 53 } |
54 | 54 |
55 IconsHandler::~IconsHandler() { | 55 IconsHandler::~IconsHandler() { |
56 } | 56 } |
57 | 57 |
58 bool IconsHandler::Parse(Extension* extension, base::string16* error) { | 58 bool IconsHandler::Parse(Extension* extension, base::string16* error) { |
(...skipping 24 matching lines...) Expand all Loading... |
83 extension, | 83 extension, |
84 IDS_EXTENSION_LOAD_ICON_FAILED, | 84 IDS_EXTENSION_LOAD_ICON_FAILED, |
85 error); | 85 error); |
86 } | 86 } |
87 | 87 |
88 const std::vector<std::string> IconsHandler::Keys() const { | 88 const std::vector<std::string> IconsHandler::Keys() const { |
89 return SingleKey(keys::kIcons); | 89 return SingleKey(keys::kIcons); |
90 } | 90 } |
91 | 91 |
92 } // namespace extensions | 92 } // namespace extensions |
OLD | NEW |