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..b77fa29bb47997a76cb1b1f61f4cc878e83208bf 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; |
| @@ -34,6 +35,7 @@ import android.widget.FrameLayout; |
| import android.widget.ImageView; |
| import android.widget.TextView; |
| +import org.chromium.base.Log; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.metrics.RecordHistogram; |
| import org.chromium.base.metrics.RecordUserAction; |
| @@ -68,6 +70,7 @@ public class NewTabPageView extends FrameLayout |
| private static final int SHADOW_COLOR = 0x11000000; |
| private static final long SNAP_SCROLL_DELAY_MS = 30; |
| + private static final String TAG = "NewTabPageView"; |
| private ViewGroup mContentView; |
| private NewTabScrollView mScrollView; |
| @@ -767,7 +770,8 @@ public class NewTabPageView extends FrameLayout |
| // MostVisitedURLsObserver implementation |
| @Override |
| - public void onMostVisitedURLsAvailable(String[] titles, String[] urls) { |
| + public void onMostVisitedURLsAvailable( |
| + String[] titles, String[] urls, String[] largeIconPaths) { |
| mMostVisitedLayout.removeAllViews(); |
| MostVisitedItem[] oldItems = mMostVisitedItems; |
| @@ -781,6 +785,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 largeIconPath = largeIconPaths[i]; |
| boolean offlineAvailable = mManager.isOfflineAvailable(url); |
| // Look for an existing item to reuse. |
| @@ -799,7 +804,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, largeIconPath, offlineAvailable, i); |
| View view = |
| mMostVisitedDesign.createMostVisitedItemView(inflater, item, isInitialLoad); |
| item.initView(view); |
| @@ -939,6 +945,16 @@ 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.getLargeIconPath().isEmpty()) { |
|
newt (away)
2016/03/08 22:09:04
Where are these icons stored and how did they get
atanasova
2016/03/09 11:40:55
These icons come from the whitelist extension inst
Marc Treib
2016/03/09 12:01:46
I think we can be reasonably sure that the path it
newt (away)
2016/03/09 21:09:58
Ok, is there a design doc somewhere describing how
|
| + Bitmap bitmap = BitmapFactory.decodeFile(mItem.getLargeIconPath()); |
| + if (bitmap != null) { |
| + icon = bitmap; |
| + } else { |
| + Log.w(TAG, "Icon path did not result in an image: " |
|
newt (away)
2016/03/08 22:09:03
Is this really a condition worth logging? Avoid lo
atanasova
2016/03/09 11:40:55
This situation is not supposed to happen, because
|
| + + mItem.getLargeIconPath()); |
| + } |
| + } |
| if (icon == null) { |
| mIconGenerator.setBackgroundColor(fallbackColor); |
| icon = mIconGenerator.generateIconForUrl(mItem.getUrl()); |