Bug 1407915 - Ignore loading favicon without url. r?nechen draft
authorJing-wei Wu <topwu.tw@gmail.com>
Thu, 12 Oct 2017 15:00:46 +0800
changeset 678987 ad009f6891fbf99c11577793d5ac80112426642e
parent 678977 e050f0cc4cc0c67901abbe74bf69fb9dbb4a590d
child 678990 806b77a78713fb93d51dd010fda5c8cd2aeabf18
child 679013 d5e2e4968dbed9044673acfeca1528e756a82c20
push id84100
push userbmo:topwu.tw@gmail.com
push dateThu, 12 Oct 2017 07:15:01 +0000
reviewersnechen
bugs1407915
milestone58.0a1
Bug 1407915 - Ignore loading favicon without url. r?nechen MozReview-Commit-ID: IaOXzInWogr
mobile/android/base/java/org/mozilla/gecko/tabs/TabsLayoutItemView.java
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsLayoutItemView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsLayoutItemView.java
@@ -15,16 +15,17 @@ import org.mozilla.gecko.widget.TabThumb
 import org.mozilla.gecko.widget.TouchDelegateWithReset;
 import org.mozilla.gecko.widget.themed.ThemedRelativeLayout;
 
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.support.v7.widget.ViewUtils;
+import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.TypedValue;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.Checkable;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -178,26 +179,33 @@ public class TabsLayoutItemView extends 
         mCloseButton.setTag(this);
 
         if (tab.isAudioPlaying()) {
             mFaviconView.setImageResource(R.drawable.tab_audio_playing);
             final String tabTitleWithAudio =
                     getResources().getString(R.string.tab_title_prefix_is_playing_audio, tabTitle);
             mTitle.setContentDescription(tabTitleWithAudio);
         } else {
+            final String url = tab.getURL();
+            if (TextUtils.isEmpty(url)) {
+                // Ignore loading favicon without url.
+                return;
+            }
+
             if (mOngoingIconLoad != null) {
                 mOngoingIconLoad.cancel(true);
             }
 
             final Resources resources = getResources();
             final int iconSize = resources.getDimensionPixelSize(R.dimen.tab_favicon_size);
             final float textSize = resources.getDimensionPixelSize(R.dimen.tab_favicon_text_size);
 
-            mOngoingIconLoad = Icons.with(getContext())
-                                       .pageUrl(tab.getURL())
+            final Context appContext = getContext().getApplicationContext();
+            mOngoingIconLoad = Icons.with(appContext)
+                                       .pageUrl(url)
                                        .skipNetwork()
                                        .targetSize(iconSize)
                                        .textSize(textSize)
                                        .build()
                                        .execute(mFaviconView.createIconCallback());
 
             mTitle.setContentDescription(tabTitle);
         }