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

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

Issue 1637763002: Fix bug in browser action icon scaling for non-1x scale factors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dbg code 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 d0b284c5370b9a78cb6f111d254de7ea01a412eb..1c8f76f050923ccbdbb85fd409e4df42c6c10fd6 100644
--- a/chrome/browser/extensions/extension_action.cc
+++ b/chrome/browser/extensions/extension_action.cc
@@ -129,14 +129,6 @@ bool ExtensionAction::ParseIconFromCanvasDictionary(
gfx::ImageSkia* icon) {
for (base::DictionaryValue::Iterator iter(dict); !iter.IsAtEnd();
iter.Advance()) {
- int icon_size = 0;
- // 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) {
Devlin 2016/01/26 19:08:48 Do we not want any checks for ridiculous scaling?
Evan Stade 2016/01/26 19:50:07 righto, baby rescued from bathwater
- continue;
- }
-
const base::BinaryValue* image_data;
std::string binary_string64;
IPC::Message pickle;
@@ -155,8 +147,10 @@ bool ExtensionAction::ParseIconFromCanvasDictionary(
if (!IPC::ReadParam(&pickle, &pickle_iter, &bitmap))
return false;
CHECK(!bitmap.isNull());
+ if (bitmap.width() != bitmap.height())
Devlin 2016/01/26 19:08:48 I wonder if we really *need* this to be a square.
Evan Stade 2016/01/26 19:50:07 Why would we want to let developers do that? Is th
Devlin 2016/01/26 19:58:25 Well, we can scale it to be proportionate and main
Evan Stade 2016/01/26 22:33:50 IMO, better not to save them that step. It adds co
+ continue;
float scale =
- static_cast<float>(icon_size) / ExtensionAction::ActionIconSize();
+ static_cast<float>(bitmap.width()) / ExtensionAction::ActionIconSize();
icon->AddRepresentation(gfx::ImageSkiaRep(bitmap, scale));
}
return true;

Powered by Google App Engine
This is Rietveld 408576698