Bug 923218: Don't show the default favicon until a failure to load a favicon has happened. r=rnewman

This commit is contained in:
Chris Kitching 2013-10-11 15:56:11 -07:00
Родитель f3e72cf12c
Коммит 6bd2c30402
4 изменённых файлов: 11 добавлений и 8 удалений

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

@ -1333,13 +1333,12 @@ abstract public class BrowserApp extends GeckoApp
int flags = LoadFaviconTask.FLAG_SCALE | ( (tab.isPrivate() || tab.getErrorType() != Tab.ErrorType.NONE) ? 0 : LoadFaviconTask.FLAG_PERSIST);
int id = Favicons.loadFavicon(tab.getURL(), tab.getFaviconURL(), flags,
new OnFaviconLoadedListener() {
@Override
public void onFaviconLoaded(String pageUrl, Bitmap favicon) {
// Leave favicon UI untouched if we failed to load the image
// for some reason.
if (favicon == null)
return;
// If we failed to load a favicon, we use the default favicon instead.
if (favicon == null) {
favicon = Favicons.sDefaultFavicon;
}
// The tab might be pointing to another URL by the time the
// favicon is finally loaded, in which case we simply ignore it.

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

@ -1121,7 +1121,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
image = Bitmap.createScaledBitmap(image, mFaviconSize, mFaviconSize, false);
mFavicon.setImageBitmap(image);
} else {
mFavicon.setImageResource(R.drawable.favicon);
mFavicon.setImageBitmap(null);
}
}

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

@ -42,6 +42,8 @@ public class Favicons {
}
};
public static Bitmap sDefaultFavicon;
// A cache of the Favicon which have recently failed to download - prevents us from repeatedly
// trying to download a Favicon when doing so is currently impossible.
private static final LruCache<String, Long> sFailedCache = new LruCache<String, Long>(64);
@ -200,6 +202,9 @@ public class Favicons {
if (sFaviconLargeSize < 0) {
sFaviconLargeSize = Math.round(sContext.getResources().getDimension(R.dimen.favicon_size_large));
}
// Load the default favicon.
sDefaultFavicon = BitmapUtils.decodeResource(sContext, R.drawable.favicon);
}
public static void removeLoadTask(long taskId) {
sLoadTasks.remove(taskId);

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

@ -141,8 +141,7 @@
android:layout_marginLeft="8dip"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:layout_gravity="center_vertical"
android:src="@drawable/favicon"/>
android:layout_gravity="center_vertical"/>
<ImageButton android:id="@+id/site_security"
style="@style/UrlBar.ImageButton"