Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| index c76ebc33a63ec2f08fce0714594af2de75fc46b3..42485558e02bfcef0196eff74149f663958cafa8 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| @@ -891,13 +891,29 @@ public class Tab implements NavigationClient { |
| * is specified or it requires the default favicon. |
| */ |
| public Bitmap getFavicon() { |
| - if (mContentViewCore != null) { |
| - if (mFavicon == null || !mContentViewCore.getUrl().equals(mFaviconUrl)) { |
| - if (mNativeTabAndroid == 0) return null; |
| - mFavicon = nativeGetFavicon(mNativeTabAndroid); |
| - mFaviconUrl = mContentViewCore.getUrl(); |
| + String url = getUrl(); |
| + // Invalidate our cached values if necessary. |
| + if (url == null || !url.equals(mFaviconUrl)) { |
| + mFavicon = null; |
| + mFaviconUrl = null; |
| + } |
| + |
| + if (mFavicon == null) { |
| + // If we have no content return null. |
| + if (getNativePage() == null && getContentViewCore() == null) return null; |
| + |
| + Bitmap favicon = nativeGetFavicon(mNativeTabAndroid); |
| + |
| + // If the favicon is not yet valid (i.e. it's either blank or a placeholder), then do |
| + // not cache the results. We still return this though so we have something to show. |
| + if (favicon != null && nativeIsFaviconValid(mNativeTabAndroid)) { |
|
Yaron
2014/08/25 19:19:29
Can you add a getter around nativeIsFaviconValid s
David Trainor- moved to gerrit
2014/08/25 22:15:37
I forgot to erase that method downstream. It'll b
|
| + mFavicon = favicon; |
| + mFaviconUrl = url; |
| } |
| + |
| + return favicon; |
| } |
| + |
| return mFavicon; |
| } |
| @@ -1169,4 +1185,5 @@ public class Tab implements NavigationClient { |
| String title); |
| private native boolean nativePrint(long nativeTabAndroid); |
| private native Bitmap nativeGetFavicon(long nativeTabAndroid); |
| + private native boolean nativeIsFaviconValid(long nativeTabAndroid); |
| } |