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

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

Issue 2374753002: Track when fallback icon color is the default. (Closed)
Patch Set: Merge branch 'refs/heads/master' into default-color Created 4 years, 2 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
Index: chrome/android/java/src/org/chromium/chrome/browser/favicon/LargeIconBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/favicon/LargeIconBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/favicon/LargeIconBridge.java
index e1017c99497c4bf50a0f82f0ac141deb3b551de8..c03118ccbbe36f005c03c0019e227cbd1099afb8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/favicon/LargeIconBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/favicon/LargeIconBridge.java
@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.favicon;
import android.graphics.Bitmap;
import android.util.LruCache;
-import android.util.Pair;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.profiles.Profile;
@@ -21,7 +20,19 @@ public class LargeIconBridge {
private static final int CACHE_ENTRY_MIN_SIZE_BYTES = 1024;
private long mNativeLargeIconBridge;
private Profile mProfile;
- private LruCache<String, Pair<Bitmap, Integer>> mFaviconCache;
+ private LruCache<String, CachedFavicon> mFaviconCache;
+
+ private static class CachedFavicon {
+ public Bitmap icon;
+ public int fallbackColor;
+ public boolean isFallbackColorDefault;
+
+ CachedFavicon(Bitmap newIcon, int newFallbackColor, boolean newIsFallbackColorDefault) {
+ icon = newIcon;
+ fallbackColor = newFallbackColor;
+ isFallbackColorDefault = newIsFallbackColorDefault;
+ }
+ }
/**
* Callback for use with GetLargeIconForUrl().
@@ -34,7 +45,7 @@ public class LargeIconBridge {
* @param fallbackColor The fallback color to use if icon is null.
*/
@CalledByNative("LargeIconCallback")
- void onLargeIconAvailable(Bitmap icon, int fallbackColor);
+ void onLargeIconAvailable(Bitmap icon, int fallbackColor, boolean isFallbackColorDefault);
}
/**
@@ -55,10 +66,10 @@ public class LargeIconBridge {
public void createCache(int cacheSizeBytes) {
assert cacheSizeBytes > 0;
- mFaviconCache = new LruCache<String, Pair<Bitmap, Integer>>(cacheSizeBytes) {
+ mFaviconCache = new LruCache<String, CachedFavicon>(cacheSizeBytes) {
@Override
- protected int sizeOf(String key, Pair<Bitmap, Integer> icon) {
- int iconBitmapSize = icon.first == null ? 0 : icon.first.getByteCount();
+ protected int sizeOf(String key, CachedFavicon favicon) {
+ int iconBitmapSize = favicon.icon == null ? 0 : favicon.icon.getByteCount();
return Math.max(CACHE_ENTRY_MIN_SIZE_BYTES, iconBitmapSize);
}
};
@@ -95,17 +106,20 @@ public class LargeIconBridge {
return nativeGetLargeIconForURL(mNativeLargeIconBridge, mProfile, pageUrl,
desiredSizePx, callback);
} else {
- Pair<Bitmap, Integer> cached = mFaviconCache.get(pageUrl);
+ CachedFavicon cached = mFaviconCache.get(pageUrl);
if (cached != null) {
- callback.onLargeIconAvailable(cached.first, cached.second);
+ callback.onLargeIconAvailable(
+ cached.icon, cached.fallbackColor, cached.isFallbackColorDefault);
return true;
}
LargeIconCallback callbackWrapper = new LargeIconCallback() {
@Override
- public void onLargeIconAvailable(Bitmap icon, int fallbackColor) {
- mFaviconCache.put(pageUrl, new Pair<Bitmap, Integer>(icon, fallbackColor));
- callback.onLargeIconAvailable(icon, fallbackColor);
+ public void onLargeIconAvailable(
+ Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) {
+ mFaviconCache.put(pageUrl,
+ new CachedFavicon(icon, fallbackColor, isFallbackColorDefault));
+ callback.onLargeIconAvailable(icon, fallbackColor, isFallbackColorDefault);
}
};
return nativeGetLargeIconForURL(mNativeLargeIconBridge, mProfile, pageUrl,

Powered by Google App Engine
This is Rietveld 408576698