| 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/files/file_util.h" | 7 #include "base/files/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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 bool IconsHandler::Parse(Extension* extension, base::string16* error) { | 58 bool IconsHandler::Parse(Extension* extension, base::string16* error) { |
| 59 scoped_ptr<IconsInfo> icons_info(new IconsInfo); | 59 scoped_ptr<IconsInfo> icons_info(new IconsInfo); |
| 60 const base::DictionaryValue* icons_dict = NULL; | 60 const base::DictionaryValue* icons_dict = NULL; |
| 61 if (!extension->manifest()->GetDictionary(keys::kIcons, &icons_dict)) { | 61 if (!extension->manifest()->GetDictionary(keys::kIcons, &icons_dict)) { |
| 62 *error = base::ASCIIToUTF16(manifest_errors::kInvalidIcons); | 62 *error = base::ASCIIToUTF16(manifest_errors::kInvalidIcons); |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 if (!manifest_handler_helpers::LoadIconsFromDictionary( | 66 if (!manifest_handler_helpers::LoadIconsFromDictionary( |
| 67 icons_dict, | 67 icons_dict, &icons_info->icons, error)) { |
| 68 extension_misc::kExtensionIconSizes, | |
| 69 extension_misc::kNumExtensionIconSizes, | |
| 70 &icons_info->icons, | |
| 71 error)) { | |
| 72 return false; | 68 return false; |
| 73 } | 69 } |
| 74 | 70 |
| 75 extension->SetManifestData(keys::kIcons, icons_info.release()); | 71 extension->SetManifestData(keys::kIcons, icons_info.release()); |
| 76 return true; | 72 return true; |
| 77 } | 73 } |
| 78 | 74 |
| 79 bool IconsHandler::Validate(const Extension* extension, | 75 bool IconsHandler::Validate(const Extension* extension, |
| 80 std::string* error, | 76 std::string* error, |
| 81 std::vector<InstallWarning>* warnings) const { | 77 std::vector<InstallWarning>* warnings) const { |
| 82 return file_util::ValidateExtensionIconSet(IconsInfo::GetIcons(extension), | 78 return file_util::ValidateExtensionIconSet(IconsInfo::GetIcons(extension), |
| 83 extension, | 79 extension, |
| 84 IDS_EXTENSION_LOAD_ICON_FAILED, | 80 IDS_EXTENSION_LOAD_ICON_FAILED, |
| 85 error); | 81 error); |
| 86 } | 82 } |
| 87 | 83 |
| 88 const std::vector<std::string> IconsHandler::Keys() const { | 84 const std::vector<std::string> IconsHandler::Keys() const { |
| 89 return SingleKey(keys::kIcons); | 85 return SingleKey(keys::kIcons); |
| 90 } | 86 } |
| 91 | 87 |
| 92 } // namespace extensions | 88 } // namespace extensions |
| OLD | NEW |