Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/Tab.java

Issue 496733005: Some favicon cleanup/upstreaming (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/android/tab_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | chrome/browser/android/tab_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698