summaryrefslogtreecommitdiffstats
path: root/extensions/common
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2015-12-04 12:10:03 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-04 20:11:15 +0000
commit39ea51bd9379fa9aaa974f8b91a559879175e681 (patch)
tree789faed502fbbca877688236cbf5b2780c254b51 /extensions/common
parent4e9a0f74389e0745855d939ac9ef900fbaa68fec (diff)
downloadchromium_src-39ea51bd9379fa9aaa974f8b91a559879175e681.zip
chromium_src-39ea51bd9379fa9aaa974f8b91a559879175e681.tar.gz
chromium_src-39ea51bd9379fa9aaa974f8b91a559879175e681.tar.bz2
Handle more scale factors for extension Browser Action icons
Also use 16x16 if provided in Material Design mode. Also, fix size of default icon (generated from extension's first letter) for MD. BUG=564926 Review URL: https://codereview.chromium.org/1492073003 Cr-Commit-Position: refs/heads/master@{#363278}
Diffstat (limited to 'extensions/common')
-rw-r--r--extensions/common/constants.cc9
-rw-r--r--extensions/common/constants.h14
-rw-r--r--extensions/common/manifest_handler_helpers.cc21
-rw-r--r--extensions/common/manifest_handler_helpers.h5
4 files changed, 26 insertions, 23 deletions
diff --git a/extensions/common/constants.cc b/extensions/common/constants.cc
index ff10df9..8d079b2 100644
--- a/extensions/common/constants.cc
+++ b/extensions/common/constants.cc
@@ -75,15 +75,6 @@ const int kExtensionIconSizes[] = {EXTENSION_ICON_GIGANTOR, // 512
const size_t kNumExtensionIconSizes = arraysize(kExtensionIconSizes);
-const IconRepresentationInfo kExtensionActionIconSizes[] = {
- { EXTENSION_ICON_ACTION, "19", ui::SCALE_FACTOR_100P },
- { 2 * EXTENSION_ICON_ACTION, "38", ui::SCALE_FACTOR_200P }
-};
-
-static_assert(kNumExtensionActionIconSizes ==
- arraysize(kExtensionActionIconSizes),
- "num action icon sizes must be in sync with action icon sizes");
-
const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai";
const char kQuickOfficeComponentExtensionId[] =
"bpmcpldpdmajfigpchkicefoigmkfalc";
diff --git a/extensions/common/constants.h b/extensions/common/constants.h
index 7af8701..8022896 100644
--- a/extensions/common/constants.h
+++ b/extensions/common/constants.h
@@ -194,20 +194,6 @@ enum ExtensionIcons {
extern const int kExtensionIconSizes[];
extern const size_t kNumExtensionIconSizes;
-struct IconRepresentationInfo {
- // Size in pixels.
- const int size;
- // Size as a string that will be used to retrieve representation value from
- // ExtensionAction SetIcon function arguments.
- const char* const size_string;
- // Scale factor for which the representation should be used.
- const ui::ScaleFactor scale;
-};
-
-// The icon representations for extension actions.
-extern const IconRepresentationInfo kExtensionActionIconSizes[];
-const size_t kNumExtensionActionIconSizes = 2u;
-
// 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 d3dfea6..7186321 100644
--- a/extensions/common/manifest_handler_helpers.cc
+++ b/extensions/common/manifest_handler_helpers.cc
@@ -59,6 +59,27 @@ bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value,
return true;
}
+bool LoadAllIconsFromDictionary(const base::DictionaryValue* icons_value,
+ ExtensionIconSet* icons,
+ base::string16* error) {
+ DCHECK(icons);
+ for (base::DictionaryValue::Iterator iterator(*icons_value);
+ !iterator.IsAtEnd(); iterator.Advance()) {
+ int size = 0;
+ std::string icon_path;
+ if (!base::StringToInt(iterator.key(), &size) ||
+ !iterator.value().GetAsString(&icon_path) ||
+ !NormalizeAndValidatePath(&icon_path)) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidIconPath,
+ iterator.key());
+ return false;
+ }
+
+ icons->Add(size, icon_path);
+ }
+ return true;
+}
+
} // namespace manifest_handler_helpers
} // namespace extensions
diff --git a/extensions/common/manifest_handler_helpers.h b/extensions/common/manifest_handler_helpers.h
index 01fe6cc..4f88174 100644
--- a/extensions/common/manifest_handler_helpers.h
+++ b/extensions/common/manifest_handler_helpers.h
@@ -33,6 +33,11 @@ bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value,
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