Bug 1238656 - Bypass cache for touchIcons to avoid needless downscaling. r=mcomella

This commit is contained in:
Andrzej Hunt 2016-01-11 11:54:46 -08:00
parent 8f4c28cc22
commit 9ef0aac857
2 changed files with 11 additions and 10 deletions

View File

@ -844,14 +844,13 @@ public class GeckoAppShell
}
};
if (touchIconURL != null) {
// We have the favicon data (base64) decoded on the background thread, callback here, then
// call the other createShortcut method with the decoded favicon.
// This is slightly contrived, but makes the images available to the favicon cache.
Favicons.getSizedFavicon(getApplicationContext(), aURI, touchIconURL, Integer.MAX_VALUE, 0, listener);
} else {
Favicons.getPreferredSizeFaviconForPage(getApplicationContext(), aURI, listener);
}
// Retrieve the icon while bypassing the cache. Homescreen icon creation is a one-off event, hence it isn't
// useful to cache these icons. (Android takes care of storing homescreen icons after a shortcut
// has been created.)
// The cache is also (currently) limited to 32dp, hence we explicitly need to avoid accessing those icons.
// If touchIconURL is null, then Favicons falls back to finding the best possible favicon for
// the site URI, hence we can use this call even when there is no touchIcon defined.
Favicons.getPreferredSizeFaviconForPage(getApplicationContext(), aURI, touchIconURL, listener);
}
private static void createShortcutWithBitmap(final String aTitle, final String aURI, final Bitmap aBitmap) {

View File

@ -572,13 +572,15 @@ public class Favicons {
* Useful for creating homescreen shortcuts without being limited
* by possibly low-resolution values in the cache.
*
* The icon will be scaled to the preferred Android launcher icon size.
*
* Deduces the favicon URL from the browser database, guessing if necessary.
*
* @param url page URL to get a large favicon image for.
* @param onFaviconLoadedListener listener to call back with the result.
*/
public static void getPreferredSizeFaviconForPage(Context context, String url, OnFaviconLoadedListener onFaviconLoadedListener) {
public static void getPreferredSizeFaviconForPage(Context context, String url, String iconURL, OnFaviconLoadedListener onFaviconLoadedListener) {
int preferredSize = GeckoAppShell.getPreferredIconSize();
loadUncachedFavicon(context, url, null, 0, preferredSize, onFaviconLoadedListener);
loadUncachedFavicon(context, url, iconURL, 0, preferredSize, onFaviconLoadedListener);
}
}