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

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

Issue 364793005: Implementation of GetFavicon for current tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed as per suggested 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 cca0ac6dc0fbd114bef15cd4a72ebf978e0122b0..c76ebc33a63ec2f08fce0714594af2de75fc46b3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
@@ -139,6 +139,10 @@ public class Tab implements NavigationClient {
private boolean mIsClosing = false;
+ private Bitmap mFavicon = null;
+
+ private String mFaviconUrl = null;
+
/**
* A default {@link ChromeContextMenuItemDelegate} that supports some of the context menu
* functionality.
@@ -885,10 +889,16 @@ public class Tab implements NavigationClient {
/**
* @return The bitmap of the favicon scaled to 16x16dp. null if no favicon
* is specified or it requires the default favicon.
- * TODO(bauerb): Upstream implementation.
*/
public Bitmap getFavicon() {
- return null;
+ if (mContentViewCore != null) {
+ if (mFavicon == null || !mContentViewCore.getUrl().equals(mFaviconUrl)) {
+ if (mNativeTabAndroid == 0) return null;
+ mFavicon = nativeGetFavicon(mNativeTabAndroid);
+ mFaviconUrl = mContentViewCore.getUrl();
+ }
+ }
+ return mFavicon;
}
/**
@@ -1014,6 +1024,8 @@ public class Tab implements NavigationClient {
*/
@CalledByNative
protected void onFaviconUpdated() {
+ mFavicon = null;
+ mFaviconUrl = null;
for (TabObserver observer : mObservers) observer.onFaviconUpdated(this);
}
@@ -1156,4 +1168,5 @@ public class Tab implements NavigationClient {
private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTabAndroid, String url,
String title);
private native boolean nativePrint(long nativeTabAndroid);
+ private native Bitmap nativeGetFavicon(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