Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: chrome/browser/extensions/extension_action.cc

Issue 1580983002: Fix the dynamic browser action setIcon path to work with any size icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twiddle constant Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_action.cc
diff --git a/chrome/browser/extensions/extension_action.cc b/chrome/browser/extensions/extension_action.cc
index 106ed3a054f125fca3d2f8041c9e3fb307040446..d0b284c5370b9a78cb6f111d254de7ea01a412eb 100644
--- a/chrome/browser/extensions/extension_action.cc
+++ b/chrome/browser/extensions/extension_action.cc
@@ -130,8 +130,12 @@ bool ExtensionAction::ParseIconFromCanvasDictionary(
for (base::DictionaryValue::Iterator iter(dict); !iter.IsAtEnd();
iter.Advance()) {
int icon_size = 0;
- if (!base::StringToInt(iter.key(), &icon_size))
+ // Chrome helpfully scales the provided icon(s), but let's not go overboard.
+ const int kActionIconMaxSize = 10 * extension_misc::EXTENSION_ICON_ACTION;
+ if (!base::StringToInt(iter.key(), &icon_size) || icon_size <= 0 ||
+ icon_size > kActionIconMaxSize) {
continue;
+ }
const base::BinaryValue* image_data;
std::string binary_string64;

Powered by Google App Engine
This is Rietveld 408576698