Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 namespace keys = manifest_keys; | 24 namespace keys = manifest_keys; |
| 25 | 25 |
| 26 static base::LazyInstance<ExtensionIconSet>::DestructorAtExit g_empty_icon_set = | 26 static base::LazyInstance<ExtensionIconSet>::DestructorAtExit g_empty_icon_set = |
| 27 LAZY_INSTANCE_INITIALIZER; | 27 LAZY_INSTANCE_INITIALIZER; |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 const ExtensionIconSet& IconsInfo::GetIcons(const Extension* extension) { | 30 const ExtensionIconSet& IconsInfo::GetIcons(const Extension* extension) { |
| 31 IconsInfo* info = static_cast<IconsInfo*>( | 31 IconsInfo* info = |
| 32 extension->GetManifestData(keys::kIcons)); | 32 extension |
|
Devlin
2017/05/31 22:00:01
I think I'd rather put the onus of checking |exten
khmel
2017/06/01 16:56:52
Done.
| |
| 33 ? static_cast<IconsInfo*>(extension->GetManifestData(keys::kIcons)) | |
| 34 : nullptr; | |
| 33 return info ? info->icons : g_empty_icon_set.Get(); | 35 return info ? info->icons : g_empty_icon_set.Get(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 // static | 38 // static |
| 37 ExtensionResource IconsInfo::GetIconResource( | 39 ExtensionResource IconsInfo::GetIconResource( |
| 38 const Extension* extension, | 40 const Extension* extension, |
| 39 int size, | 41 int size, |
| 40 ExtensionIconSet::MatchType match_type) { | 42 ExtensionIconSet::MatchType match_type) { |
| 41 const std::string& path = GetIcons(extension).Get(size, match_type); | 43 const std::string& path = GetIcons(extension).Get(size, match_type); |
| 42 return path.empty() ? ExtensionResource() : extension->GetResource(path); | 44 return path.empty() ? ExtensionResource() : extension->GetResource(path); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 extension, | 82 extension, |
| 81 IDS_EXTENSION_LOAD_ICON_FAILED, | 83 IDS_EXTENSION_LOAD_ICON_FAILED, |
| 82 error); | 84 error); |
| 83 } | 85 } |
| 84 | 86 |
| 85 const std::vector<std::string> IconsHandler::Keys() const { | 87 const std::vector<std::string> IconsHandler::Keys() const { |
| 86 return SingleKey(keys::kIcons); | 88 return SingleKey(keys::kIcons); |
| 87 } | 89 } |
| 88 | 90 |
| 89 } // namespace extensions | 91 } // namespace extensions |
| OLD | NEW |