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

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: . 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
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/icon_with_badge_image_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..05b7d86857f5a9d6821800280505677c66bf798a 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) {
- continue;
- }
-
const base::BinaryValue* image_data;
std::string binary_string64;
IPC::Message pickle;
@@ -155,8 +147,16 @@ bool ExtensionAction::ParseIconFromCanvasDictionary(
if (!IPC::ReadParam(&pickle, &pickle_iter, &bitmap))
return false;
CHECK(!bitmap.isNull());
+
+ // Chrome helpfully scales the provided icon(s), but let's not go overboard.
+ const int kActionIconMaxSize = 10 * extension_misc::EXTENSION_ICON_ACTION;
+ if (bitmap.drawsNothing() || bitmap.width() != bitmap.height() ||
+ bitmap.width() > kActionIconMaxSize) {
+ 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;
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/icon_with_badge_image_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698