mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 943515 - Refactor favicon accessors for naming and usage consistency. r=mcomella
This commit is contained in:
parent
3289daea25
commit
d826b1c700
@ -786,11 +786,11 @@ abstract public class BrowserApp extends GeckoApp
|
||||
}
|
||||
|
||||
final OnFaviconLoadedListener listener = new GeckoAppShell.CreateShortcutFaviconLoadedListener(url, title);
|
||||
Favicons.getFaviconForSize(url,
|
||||
tab.getFaviconURL(),
|
||||
Integer.MAX_VALUE,
|
||||
LoadFaviconTask.FLAG_PERSIST,
|
||||
listener);
|
||||
Favicons.getSizedFavicon(url,
|
||||
tab.getFaviconURL(),
|
||||
Integer.MAX_VALUE,
|
||||
LoadFaviconTask.FLAG_PERSIST,
|
||||
listener);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1413,7 +1413,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
final int tabFaviconSize = getResources().getDimensionPixelSize(R.dimen.browser_toolbar_favicon_size);
|
||||
|
||||
int flags = (tab.isPrivate() || tab.getErrorType() != Tab.ErrorType.NONE) ? 0 : LoadFaviconTask.FLAG_PERSIST;
|
||||
int id = Favicons.getFaviconForSize(tab.getURL(), tab.getFaviconURL(), tabFaviconSize, flags, sFaviconLoadedListener);
|
||||
int id = Favicons.getSizedFavicon(tab.getURL(), tab.getFaviconURL(), tabFaviconSize, flags, sFaviconLoadedListener);
|
||||
|
||||
tab.setFaviconLoadId(id);
|
||||
|
||||
|
@ -766,7 +766,7 @@ public class Tabs implements GeckoEventListener {
|
||||
*/
|
||||
private Bitmap getAboutPageFavicon(final String url) {
|
||||
int faviconSize = Math.round(mAppContext.getResources().getDimension(R.dimen.browser_toolbar_favicon_size));
|
||||
return Favicons.getCachedFaviconForSize(url, faviconSize);
|
||||
return Favicons.getSizedFaviconForPageFromCache(url, faviconSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2974,7 +2974,7 @@ public class BrowserProvider extends ContentProvider {
|
||||
|
||||
// If no URL is provided, insert using the default one.
|
||||
if (TextUtils.isEmpty(faviconUrl) && !TextUtils.isEmpty(pageUrl)) {
|
||||
values.put(Favicons.URL, org.mozilla.gecko.favicons.Favicons.guessDefaultFaviconURL(pageUrl));
|
||||
values.put(Favicons.URL, org.mozilla.gecko.favicons.Favicons.guessDefaultFaviconUrl(pageUrl));
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -65,7 +65,7 @@ public class Favicons {
|
||||
// doing so is not necessary.
|
||||
private static final NonEvictingLruCache<String, String> sPageURLMappings = new NonEvictingLruCache<String, String>(NUM_PAGE_URL_MAPPINGS_TO_STORE);
|
||||
|
||||
public static String getFaviconURLForPageURLFromCache(String pageURL) {
|
||||
public static String getFaviconUrlForPageUrlFromCache(String pageURL) {
|
||||
return sPageURLMappings.get(pageURL);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class Favicons {
|
||||
* Insert the given pageUrl->faviconUrl mapping into the memory cache of such mappings.
|
||||
* Useful for short-circuiting local database access.
|
||||
*/
|
||||
public static void putFaviconURLForPageURLInCache(String pageURL, String faviconURL) {
|
||||
public static void putFaviconUrlForPageUrlInCache(String pageURL, String faviconURL) {
|
||||
sPageURLMappings.put(pageURL, faviconURL);
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class Favicons {
|
||||
*
|
||||
* Returns null otherwise.
|
||||
*/
|
||||
public static Bitmap getCachedFaviconForSize(final String pageURL, int targetSize) {
|
||||
public static Bitmap getSizedFaviconForPageFromCache(final String pageURL, int targetSize) {
|
||||
final String faviconURL = sPageURLMappings.get(pageURL);
|
||||
if (faviconURL == null) {
|
||||
return null;
|
||||
@ -134,7 +134,7 @@ public class Favicons {
|
||||
* @return The id of the asynchronous task created, NOT_LOADING if none is created, or
|
||||
* LOADED if the value could be dispatched on the current thread.
|
||||
*/
|
||||
public static int getFaviconForSize(String pageURL, String faviconURL, int targetSize, int flags, OnFaviconLoadedListener listener) {
|
||||
public static int getSizedFavicon(String pageURL, String faviconURL, int targetSize, int flags, OnFaviconLoadedListener listener) {
|
||||
// Do we know the favicon URL for this page already?
|
||||
String cacheURL = faviconURL;
|
||||
if (cacheURL == null) {
|
||||
@ -143,7 +143,7 @@ public class Favicons {
|
||||
|
||||
// If there's no favicon URL given, try and hit the cache with the default one.
|
||||
if (cacheURL == null) {
|
||||
cacheURL = guessDefaultFaviconURL(pageURL);
|
||||
cacheURL = guessDefaultFaviconUrl(pageURL);
|
||||
}
|
||||
|
||||
// If it's something we can't even figure out a default URL for, just give up.
|
||||
@ -222,6 +222,7 @@ public class Favicons {
|
||||
public static int getSizedFaviconForPageFromLocal(final String pageURL, final OnFaviconLoadedListener callback) {
|
||||
return getSizedFaviconForPageFromLocal(pageURL, sDefaultFaviconSize, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to determine the URL of the Favicon image for a given page URL by querying the
|
||||
* history database. Should only be called from the background thread - does database access.
|
||||
@ -245,7 +246,7 @@ public class Favicons {
|
||||
targetURL = BrowserDB.getFaviconUrlForHistoryUrl(sContext.getContentResolver(), pageURL);
|
||||
if (targetURL == null) {
|
||||
// Nothing in the history database. Fall back to the default URL and hope for the best.
|
||||
targetURL = guessDefaultFaviconURL(pageURL);
|
||||
targetURL = guessDefaultFaviconUrl(pageURL);
|
||||
}
|
||||
return targetURL;
|
||||
}
|
||||
@ -406,7 +407,7 @@ public class Favicons {
|
||||
* @param pageURL Page URL for which a default Favicon URL is requested
|
||||
* @return The default Favicon URL.
|
||||
*/
|
||||
public static String guessDefaultFaviconURL(String pageURL) {
|
||||
public static String guessDefaultFaviconUrl(String pageURL) {
|
||||
// Special-casing for about: pages. The favicon for about:pages which don't provide a link tag
|
||||
// is bundled in the database, keyed only by page URL, hence the need to return the page URL
|
||||
// here. If the database ever migrates to stop being silly in this way, this can plausibly
|
||||
|
@ -240,14 +240,14 @@ public class LoadFaviconTask extends UiAsyncTask<Void, Void, Bitmap> {
|
||||
// If favicon is empty, fall back to the stored one.
|
||||
if (TextUtils.isEmpty(mFaviconUrl)) {
|
||||
// Try to get the favicon URL from the memory cache.
|
||||
storedFaviconUrl = Favicons.getFaviconURLForPageURLFromCache(mPageUrl);
|
||||
storedFaviconUrl = Favicons.getFaviconUrlForPageUrlFromCache(mPageUrl);
|
||||
|
||||
// If that failed, try to get the URL from the database.
|
||||
if (storedFaviconUrl == null) {
|
||||
storedFaviconUrl = Favicons.getFaviconUrlForPageUrl(mPageUrl);
|
||||
if (storedFaviconUrl != null) {
|
||||
// If that succeeded, cache the URL loaded from the database in memory.
|
||||
Favicons.putFaviconURLForPageURLInCache(mPageUrl, storedFaviconUrl);
|
||||
Favicons.putFaviconUrlForPageUrlInCache(mPageUrl, storedFaviconUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ public class LoadFaviconTask extends UiAsyncTask<Void, Void, Bitmap> {
|
||||
mFaviconUrl = storedFaviconUrl;
|
||||
} else {
|
||||
// If we don't have a stored one, fall back to the default.
|
||||
mFaviconUrl = Favicons.guessDefaultFaviconURL(mPageUrl);
|
||||
mFaviconUrl = Favicons.guessDefaultFaviconUrl(mPageUrl);
|
||||
|
||||
if (TextUtils.isEmpty(mFaviconUrl)) {
|
||||
return null;
|
||||
@ -335,7 +335,7 @@ public class LoadFaviconTask extends UiAsyncTask<Void, Void, Bitmap> {
|
||||
}
|
||||
|
||||
// If we're not already trying the default URL, try it now.
|
||||
final String guessed = Favicons.guessDefaultFaviconURL(mPageUrl);
|
||||
final String guessed = Favicons.guessDefaultFaviconUrl(mPageUrl);
|
||||
if (guessed == null) {
|
||||
Favicons.putFaviconInFailedCache(mFaviconUrl);
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user