Bug 699786 - Cancel pending favicon loads when location changes (r=blassey)

This commit is contained in:
Lucas Rocha 2011-11-17 21:35:19 +00:00
Родитель 80f9b81eed
Коммит 09f6db2b68
2 изменённых файлов: 32 добавлений и 2 удалений

Просмотреть файл

@ -550,9 +550,24 @@ abstract public class GeckoApp
GeckoAppShell.sendEventToGecko(event);
}
private void maybeCancelFaviconLoad(Tab tab) {
long faviconLoadId = tab.getFaviconLoadId();
if (faviconLoadId == Favicons.NOT_LOADING)
return;
// Cancel pending favicon load task
mFavicons.cancelFaviconLoad(faviconLoadId);
// Reset favicon load state
tab.setFaviconLoadId(Favicons.NOT_LOADING);
}
private void loadFavicon(final Tab tab) {
mFavicons.loadFavicon(tab.getURL(), tab.getFaviconURL(),
new Favicons.OnFaviconLoadedListener() {
maybeCancelFaviconLoad(tab);
long id = mFavicons.loadFavicon(tab.getURL(), tab.getFaviconURL(),
new Favicons.OnFaviconLoadedListener() {
public void onFaviconLoaded(String pageUrl, Drawable favicon) {
// Leave favicon UI untouched if we failed to load the image
@ -570,6 +585,7 @@ abstract public class GeckoApp
Log.i(LOGTAG, "Favicon is for current URL = " + pageUrl);
tab.updateFavicon(favicon);
tab.setFaviconLoadId(Favicons.NOT_LOADING);
if (Tabs.getInstance().isSelectedTab(tab))
mBrowserToolbar.setFavicon(tab.getFavicon());
@ -577,6 +593,8 @@ abstract public class GeckoApp
onTabsChanged(tab);
}
});
tab.setFaviconLoadId(id);
}
void handleLocationChange(final int tabId, final String uri) {
@ -602,6 +620,8 @@ abstract public class GeckoApp
tab.updateSecurityMode("unknown");
tab.removeTransientDoorHangers();
maybeCancelFaviconLoad(tab);
mMainHandler.post(new Runnable() {
public void run() {
if (Tabs.getInstance().isSelectedTab(tab)) {

Просмотреть файл

@ -71,6 +71,7 @@ public class Tab {
private boolean mLoading;
private boolean mBookmark;
private HashMap<String, DoorHanger> mDoorHangers;
private long mFaviconLoadId;
static class HistoryEntry {
public final String mUri;
@ -98,6 +99,7 @@ public class Tab {
mHistoryIndex = -1;
mBookmark = false;
mDoorHangers = new HashMap<String, DoorHanger>();
mFaviconLoadId = 0;
}
public int getId() {
@ -178,6 +180,14 @@ public class Tab {
mBookmark = bookmark;
}
public void setFaviconLoadId(long faviconLoadId) {
mFaviconLoadId = faviconLoadId;
}
public long getFaviconLoadId() {
return mFaviconLoadId;
}
public HistoryEntry getLastHistoryEntry() {
if (mHistory.isEmpty())
return null;