Bug 837373 - Check for valid favicon before scaling it. r=mfinkle

This commit is contained in:
Brian Nicholson 2013-02-04 11:08:10 -08:00
parent 58c421702e
commit 4bf7afcf81
3 changed files with 8 additions and 7 deletions

View File

@ -309,7 +309,7 @@ public class Favicons {
String storedFaviconUrl = getFaviconUrlForPageUrl(mPageUrl);
if (storedFaviconUrl != null && storedFaviconUrl.equals(mFaviconUrl)) {
image = loadFaviconFromDb();
if (image != null)
if (image != null && image.getWidth() > 0 && image.getHeight() > 0)
return scaleImage(image);
}

View File

@ -804,7 +804,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
continue;
Bitmap favicon = BitmapFactory.decodeByteArray(b, 0, b.length);
if (favicon == null)
if (favicon == null || favicon.getWidth() <= 0 || favicon.getHeight() <= 0)
continue;
favicon = Favicons.getInstance().scaleImage(favicon);

View File

@ -89,13 +89,14 @@ abstract public class AwesomeBarTab {
protected void updateFavicon(ImageView faviconView, Cursor cursor) {
byte[] b = cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
if (b == null) {
faviconView.setImageDrawable(null);
} else {
Bitmap favicon = null;
if (b != null) {
Bitmap bitmap = BitmapFactory.decodeByteArray(b, 0, b.length);
bitmap = Favicons.getInstance().scaleImage(bitmap);
updateFavicon(faviconView, bitmap);
if (bitmap != null && bitmap.getWidth() > 0 && bitmap.getHeight() > 0) {
favicon = Favicons.getInstance().scaleImage(bitmap);
}
}
updateFavicon(faviconView, favicon);
}
protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {