diff options
author | estade <estade@chromium.org> | 2015-12-07 17:14:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-08 01:15:32 +0000 |
commit | fd2986d06d57ad04fc6f8db79ddb7a42d6445e03 (patch) | |
tree | 9966f25630ef76d2c3db1579b7838a276c4abd54 /extensions/common | |
parent | 15b58d72a18f0a59cac142cfb81245d0bf3ae077 (diff) | |
download | chromium_src-fd2986d06d57ad04fc6f8db79ddb7a42d6445e03.zip chromium_src-fd2986d06d57ad04fc6f8db79ddb7a42d6445e03.tar.gz chromium_src-fd2986d06d57ad04fc6f8db79ddb7a42d6445e03.tar.bz2 |
Allow arbitrary sizes for extension icons (and bookmark app icons)
BUG=564926
Review URL: https://codereview.chromium.org/1504453002
Cr-Commit-Position: refs/heads/master@{#363669}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/constants.cc | 14 | ||||
-rw-r--r-- | extensions/common/constants.h | 4 | ||||
-rw-r--r-- | extensions/common/manifest_handler_helpers.cc | 29 | ||||
-rw-r--r-- | extensions/common/manifest_handler_helpers.h | 10 | ||||
-rw-r--r-- | extensions/common/manifest_handlers/icons_handler.cc | 6 |
5 files changed, 3 insertions, 60 deletions
diff --git a/extensions/common/constants.cc b/extensions/common/constants.cc index 8d079b2..cfd00c1 100644 --- a/extensions/common/constants.cc +++ b/extensions/common/constants.cc @@ -61,20 +61,6 @@ const char kMimeTypePng[] = "image/png"; namespace extension_misc { -const int kExtensionIconSizes[] = {EXTENSION_ICON_GIGANTOR, // 512 - EXTENSION_ICON_EXTRA_LARGE, // 256 - EXTENSION_ICON_LARGE, // 128 - EXTENSION_ICON_MEDIUM, // 48 - EXTENSION_ICON_SMALL, // 32 - EXTENSION_ICON_SMALLISH, // 24 - EXTENSION_ICON_BITTY, // 16 - // Additional 2x resources to load. - 2 * EXTENSION_ICON_MEDIUM, // 96 - 2 * EXTENSION_ICON_SMALL // 64 -}; - -const size_t kNumExtensionIconSizes = arraysize(kExtensionIconSizes); - const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai"; const char kQuickOfficeComponentExtensionId[] = "bpmcpldpdmajfigpchkicefoigmkfalc"; diff --git a/extensions/common/constants.h b/extensions/common/constants.h index 8022896..a59d337 100644 --- a/extensions/common/constants.h +++ b/extensions/common/constants.h @@ -190,10 +190,6 @@ enum ExtensionIcons { EXTENSION_ICON_INVALID = 0, }; -// List of sizes for extension icons that can be defined in the manifest. -extern const int kExtensionIconSizes[]; -extern const size_t kNumExtensionIconSizes; - // The extension id of the PDF extension. extern const char kPdfExtensionId[]; diff --git a/extensions/common/manifest_handler_helpers.cc b/extensions/common/manifest_handler_helpers.cc index 7186321..4dc2f6b 100644 --- a/extensions/common/manifest_handler_helpers.cc +++ b/extensions/common/manifest_handler_helpers.cc @@ -32,37 +32,10 @@ bool NormalizeAndValidatePath(std::string* path) { } bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, - const int* icon_sizes, - size_t num_icon_sizes, ExtensionIconSet* icons, base::string16* error) { DCHECK(icons); - for (size_t i = 0; i < num_icon_sizes; ++i) { - std::string key = base::IntToString(icon_sizes[i]); - if (icons_value->HasKey(key)) { - std::string icon_path; - if (!icons_value->GetString(key, &icon_path)) { - *error = ErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidIconPath, key); - return false; - } - - if (!NormalizeAndValidatePath(&icon_path)) { - *error = ErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidIconPath, key); - return false; - } - - icons->Add(icon_sizes[i], icon_path); - } - } - return true; -} - -bool LoadAllIconsFromDictionary(const base::DictionaryValue* icons_value, - ExtensionIconSet* icons, - base::string16* error) { - DCHECK(icons); + DCHECK(error); for (base::DictionaryValue::Iterator iterator(*icons_value); !iterator.IsAtEnd(); iterator.Advance()) { int size = 0; diff --git a/extensions/common/manifest_handler_helpers.h b/extensions/common/manifest_handler_helpers.h index 4f88174..b0249c3 100644 --- a/extensions/common/manifest_handler_helpers.h +++ b/extensions/common/manifest_handler_helpers.h @@ -24,20 +24,12 @@ namespace manifest_handler_helpers { bool NormalizeAndValidatePath(std::string* path); // Loads icon paths defined in dictionary |icons_value| into ExtensionIconSet -// |icons|. |icons_value| is a dictionary value {icon size -> icon path}. Icons -// in |icons_value| whose size is not in |icon_sizes| will be ignored. +// |icons|. |icons_value| is a dictionary value {icon size -> icon path}. // Returns success. If load fails, |error| will be set. bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, - const int* icon_sizes, - size_t num_icon_sizes, ExtensionIconSet* icons, base::string16* error); -// As above, but loads all icons in |icons_value|. -bool LoadAllIconsFromDictionary(const base::DictionaryValue* icons_value, - ExtensionIconSet* icons, - base::string16* error); - } // namespace manifest_handler_helpers } // namespace extensions diff --git a/extensions/common/manifest_handlers/icons_handler.cc b/extensions/common/manifest_handlers/icons_handler.cc index 8535d9b..20ad025 100644 --- a/extensions/common/manifest_handlers/icons_handler.cc +++ b/extensions/common/manifest_handlers/icons_handler.cc @@ -64,11 +64,7 @@ bool IconsHandler::Parse(Extension* extension, base::string16* error) { } if (!manifest_handler_helpers::LoadIconsFromDictionary( - icons_dict, - extension_misc::kExtensionIconSizes, - extension_misc::kNumExtensionIconSizes, - &icons_info->icons, - error)) { + icons_dict, &icons_info->icons, error)) { return false; } |