Bug 1265708 - Strip ref from URL when adding homescreen icons r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 02 Jun 2016 14:14:39 -0700
changeset 374829 3e65b6718e4170eadbeb15c9c0b0d0e194e6ed84
parent 374828 f5faffdd89ee3a116b63d8d5b30ac53a7bc9be8e
child 374830 d26a94e376b258382254d5dad8bb9fb07bf3dc54
push id20091
push userahunt@mozilla.com
push dateThu, 02 Jun 2016 21:42:56 +0000
reviewerssebastian
bugs1265708
milestone49.0a1
Bug 1265708 - Strip ref from URL when adding homescreen icons r?sebastian We add URL metadata based on the base URL, we should retrieve it this way too. MozReview-Commit-ID: ICP54V5vRgv
mobile/android/base/java/org/mozilla/gecko/favicons/Favicons.java
--- a/mobile/android/base/java/org/mozilla/gecko/favicons/Favicons.java
+++ b/mobile/android/base/java/org/mozilla/gecko/favicons/Favicons.java
@@ -13,16 +13,17 @@ import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.URLMetadataTable;
 import org.mozilla.gecko.favicons.cache.FaviconCache;
 import org.mozilla.gecko.util.GeckoJarReader;
 import org.mozilla.gecko.util.NonEvictingLruCache;
 import org.mozilla.gecko.util.ThreadUtils;
+import org.mozilla.gecko.util.URLUtils;
 
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
@@ -614,23 +615,25 @@ public class Favicons {
      * This implementation sidesteps the cache and will load the icon from the database or the
      * internet. See getPreferredSizeFaviconForPage().
      */
     public static void getPreferredIconForHomeScreenShortcut(Context context, String url, OnFaviconLoadedListener onFaviconLoadedListener) {
         ThreadUtils.assertOnBackgroundThread();
 
         final BrowserDB db = GeckoProfile.get(context).getDB();
 
+        final String metadataQueryURL = URLUtils.stripRefFromURL(url);
+
         final ContentResolver cr = context.getContentResolver();
         final Map<String, Map<String, Object>> metadata = db.getURLMetadata().getForURLs(cr,
-                Collections.singletonList(url),
+                Collections.singletonList(metadataQueryURL),
                 Collections.singletonList(URLMetadataTable.TOUCH_ICON_COLUMN)
         );
 
-        final Map<String, Object> row = metadata.get(url);
+        final Map<String, Object> row = metadata.get(metadataQueryURL);
 
         String touchIconURL = null;
 
         if (row != null) {
             touchIconURL = (String) row.get(URLMetadataTable.TOUCH_ICON_COLUMN);
         }
 
         if (touchIconURL != null &&