Bug 744479 - Only attempt to load favicons for HTTP/HTTPS. r=mfinkle

This commit is contained in:
Brian Nicholson 2012-06-07 17:20:38 -07:00
parent 8fc6d81900
commit e58699720e

View File

@ -21,6 +21,8 @@ import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -254,6 +256,19 @@ public class Favicons {
return GeckoJarReader.getBitmapDrawable(mFaviconUrl); return GeckoJarReader.getBitmapDrawable(mFaviconUrl);
} }
URI uri;
try {
uri = faviconUrl.toURI();
} catch (URISyntaxException e) {
Log.d(LOGTAG, "Could not get URI for favicon URL: " + mFaviconUrl);
return null;
}
// only get favicons for HTTP/HTTPS
String scheme = uri.getScheme();
if (!"http".equals(scheme) && !"https".equals(scheme))
return null;
// skia decoder sometimes returns null; workaround is to use BufferedHttpEntity // skia decoder sometimes returns null; workaround is to use BufferedHttpEntity
// http://groups.google.com/group/android-developers/browse_thread/thread/171b8bf35dbbed96/c3ec5f45436ceec8?lnk=raot // http://groups.google.com/group/android-developers/browse_thread/thread/171b8bf35dbbed96/c3ec5f45436ceec8?lnk=raot
BitmapDrawable image = null; BitmapDrawable image = null;
@ -264,8 +279,6 @@ public class Favicons {
BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity); BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity);
contentStream = bufferedEntity.getContent(); contentStream = bufferedEntity.getContent();
image = (BitmapDrawable) Drawable.createFromStream(contentStream, "src"); image = (BitmapDrawable) Drawable.createFromStream(contentStream, "src");
} catch (IOException e) {
// just close up and return null
} catch (Exception e) { } catch (Exception e) {
Log.e(LOGTAG, "Error reading favicon", e); Log.e(LOGTAG, "Error reading favicon", e);
} finally { } finally {