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..de587fd82922765603e051dcb830e389c27fb1c9 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 eitehr blank or a placeholder), then do |
Yaron
2014/08/22 22:11:12
either
David Trainor- moved to gerrit
2014/08/25 17:49:31
Done.
|
+ // not cache the results. We still return this though so we have something to show. |
+ if (favicon != null && nativeIsFaviconValid(mNativeTabAndroid)) { |
Yaron
2014/08/22 22:11:12
Instead of the extra JNI call, move this isfavicon
David Trainor- moved to gerrit
2014/08/25 17:49:31
Need to pull it out :(. We still want to grab the
|
+ 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); |
} |