Bug 914027: Do not attempt to decode Favicons of unsupported types. Fallback on Favicon failure. r=margaret
This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -29,7 +30,6 @@ import android.accounts.OnAccountsUpdateListener;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
@@ -505,8 +505,20 @@ public class Tabs implements GeckoEventListener {
|
||||
} else if (event.equals("DOMTitleChanged")) {
|
||||
tab.updateTitle(message.getString("title"));
|
||||
} else if (event.equals("Link:Favicon")) {
|
||||
tab.updateFaviconURL(message.getString("href"), message.getInt("size"));
|
||||
notifyListeners(tab, TabEvents.LINK_FAVICON);
|
||||
// Don't bother if the type isn't one we can decode.
|
||||
if (!Favicons.canDecodeType(message.getString("mime"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the favicon to the set of available icons for this tab.
|
||||
tab.addFavicon(message.getString("href"), message.getInt("size"), message.getString("mime"));
|
||||
|
||||
// Load the favicon. If the tab is still loading, we actually do the load once the
|
||||
// page has loaded, in an attempt to prevent the favicon load from having a
|
||||
// detrimental effect on page load time.
|
||||
if (tab.getState() != Tab.STATE_LOADING) {
|
||||
tab.loadFavicon();
|
||||
}
|
||||
} else if (event.equals("Link:Feed")) {
|
||||
tab.setHasFeeds(true);
|
||||
notifyListeners(tab, TabEvents.LINK_FEED);
|
||||
@@ -535,24 +547,6 @@ public class Tabs implements GeckoEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the favicon for any tabs loaded with this page URL.
|
||||
*/
|
||||
public void updateFaviconForURL(String pageURL, Bitmap favicon) {
|
||||
// The tab might be pointing to another URL by the time the
|
||||
// favicon is finally loaded, in which case we won't find the tab.
|
||||
// See also: Bug 920331.
|
||||
for (Tab tab : mOrder) {
|
||||
String tabURL = tab.getURL();
|
||||
if (pageURL.equals(tabURL)) {
|
||||
tab.setFaviconLoadId(Favicons.NOT_LOADING);
|
||||
if (tab.updateFavicon(favicon)) {
|
||||
notifyListeners(tab, TabEvents.FAVICON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshThumbnails() {
|
||||
final ThumbnailHelper helper = ThumbnailHelper.getInstance();
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@@ -595,7 +589,6 @@ public class Tabs implements GeckoEventListener {
|
||||
LOCATION_CHANGE,
|
||||
MENU_UPDATED,
|
||||
PAGE_SHOW,
|
||||
LINK_FAVICON,
|
||||
LINK_FEED,
|
||||
SECURITY_CHANGE,
|
||||
READER_ENABLED,
|
||||
@@ -839,7 +832,8 @@ public class Tabs implements GeckoEventListener {
|
||||
// TODO: surely we could just fetch *any* cached icon?
|
||||
if (AboutPages.isBuiltinIconPage(url)) {
|
||||
Log.d(LOGTAG, "Setting about: tab favicon inline.");
|
||||
added.updateFavicon(getAboutPageFavicon(url));
|
||||
added.addFavicon(url, Favicons.browserToolbarFaviconSize, "");
|
||||
added.loadFavicon();
|
||||
}
|
||||
|
||||
return added;
|
||||
@@ -853,17 +847,6 @@ public class Tabs implements GeckoEventListener {
|
||||
return loadUrl(AboutPages.PRIVATEBROWSING, Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_PRIVATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* These favicons are only used for the URL bar, so
|
||||
* we fetch with that size.
|
||||
*
|
||||
* This method completes on the calling thread.
|
||||
*/
|
||||
private Bitmap getAboutPageFavicon(final String url) {
|
||||
int faviconSize = Math.round(mAppContext.getResources().getDimension(R.dimen.browser_toolbar_favicon_size));
|
||||
return Favicons.getSizedFaviconForPageFromCache(url, faviconSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the url as a new tab, and mark the selected tab as its "parent".
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user