Bug 1407915 - Ignore loading favicon without url. r=nechen
authorJing-wei Wu <topwu.tw@gmail.com>
Thu, 12 Oct 2017 15:00:46 +0800
changeset 385779 0a322a6a0b075b13a7749e0f81e04a87f8b04ac4
parent 385778 d9e77bd1f30671cfa1d59db5aff372ce8c44c531
child 385804 0131dafb015b817ac0b2ae064f5a09e659b4d20e
push id53139
push usertopwu.tw@gmail.com
push dateThu, 12 Oct 2017 09:39:51 +0000
treeherderautoland@0a322a6a0b07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen
bugs1407915
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);
         }