Index: chrome/browser/manifest/manifest_icon_downloader.cc |
diff --git a/chrome/browser/manifest/manifest_icon_downloader.cc b/chrome/browser/manifest/manifest_icon_downloader.cc |
index 34ff954d39e64fe15fe901ff85c973b2b19ba0da..64f689f9f4c6b8d8b1f619f12b306eef1c54d888 100644 |
--- a/chrome/browser/manifest/manifest_icon_downloader.cc |
+++ b/chrome/browser/manifest/manifest_icon_downloader.cc |
@@ -126,5 +126,26 @@ int ManifestIconDownloader::FindClosestBitmapIndex( |
best_delta = delta; |
} |
} |
+ |
+ if (best_index != -1) |
+ return best_index; |
+ |
+ // There was no square icon of a correct size found. Try to find the most |
+ // square possible icon which has both dimensions greater than the minimum |
+ // size. |
mlamouri (slow - plz ping)
2015/09/18 13:41:59
Very quick comment: maybe you could use a ratio in
Lalit Maganti
2015/09/18 14:06:46
Problem with using a ratio is that the code become
gone
2015/09/18 18:46:41
I agree with Mounir about relying on ratios; the d
Lalit Maganti
2015/09/21 09:52:34
Done.
|
+ int best_dimension_difference = std::numeric_limits<int>::max(); |
+ for (size_t i = 0; i < bitmaps.size(); ++i) { |
+ if (bitmaps[i].height() < minimum_icon_size_in_px || |
+ bitmaps[i].width() < minimum_icon_size_in_px) { |
+ continue; |
+ } |
+ |
+ int dimension_difference = abs(bitmaps[i].height() - bitmaps[i].width()); |
+ if (dimension_difference < best_dimension_difference) { |
+ best_index = i; |
+ best_dimension_difference = dimension_difference; |
+ } |
+ } |
+ |
return best_index; |
} |