Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java |
| index 2cca3fb1a2b7b646c8b8d4206c1151b78f16b7a5..26e179a8057f1385cd6c5ce87e3e6f9a6cc53e47 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java |
| @@ -8,6 +8,7 @@ import android.annotation.SuppressLint; |
| import android.content.Context; |
| import android.content.res.Resources; |
| import android.graphics.Bitmap; |
| +import android.graphics.BitmapFactory; |
| import android.graphics.Canvas; |
| import android.graphics.Rect; |
| import android.graphics.drawable.BitmapDrawable; |
| @@ -767,7 +768,8 @@ public class NewTabPageView extends FrameLayout |
| // MostVisitedURLsObserver implementation |
| @Override |
| - public void onMostVisitedURLsAvailable(String[] titles, String[] urls) { |
| + public void onMostVisitedURLsAvailable( |
| + String[] titles, String[] urls, String[] localIconPaths) { |
| mMostVisitedLayout.removeAllViews(); |
| MostVisitedItem[] oldItems = mMostVisitedItems; |
| @@ -781,6 +783,7 @@ public class NewTabPageView extends FrameLayout |
| for (int i = 0; i < titles.length; i++) { |
| final String url = urls[i]; |
| final String title = titles[i]; |
| + final String localIconPath = localIconPaths[i]; |
| boolean offlineAvailable = mManager.isOfflineAvailable(url); |
| // Look for an existing item to reuse. |
| @@ -799,7 +802,8 @@ public class NewTabPageView extends FrameLayout |
| // If nothing can be reused, create a new item. |
| if (item == null) { |
| - item = new MostVisitedItem(mManager, title, url, offlineAvailable, i); |
| + item = new MostVisitedItem( |
| + mManager, title, url, localIconPath, offlineAvailable, i); |
| View view = |
| mMostVisitedDesign.createMostVisitedItemView(inflater, item, isInitialLoad); |
| item.initView(view); |
| @@ -939,6 +943,11 @@ public class NewTabPageView extends FrameLayout |
| @Override |
| public void onLargeIconAvailable(Bitmap icon, int fallbackColor) { |
| MostVisitedItemView view = (MostVisitedItemView) mItem.getView(); |
| + // Try to use the locally stored icon |
| + if (!mItem.getLocalIconPath().isEmpty()) { |
| + Bitmap bitmap = BitmapFactory.decodeFile(mItem.getLocalIconPath()); |
| + icon = bitmap != null ? bitmap : icon; |
|
Marc Treib
2016/03/08 14:27:12
Regular "if" please, rather than assigning icon to
atanasova
2016/03/08 15:53:58
Done.
|
| + } |
| if (icon == null) { |
| mIconGenerator.setBackgroundColor(fallbackColor); |
| icon = mIconGenerator.generateIconForUrl(mItem.getUrl()); |