Bug 1054268 - Show search icon in about:home (r=margaret)
☠☠ backed out by d18d3e14ac3e ☠ ☠
authorLucas Rocha <lucasr@mozilla.com>
Fri, 15 Aug 2014 18:23:20 +0100
changeset 199781 31d4832196f66c6e59a2529090553102d0144c1f
parent 199780 9e0e63359e7755558a7c91063352d92b33bd6c6f
child 199782 e99b11f8b3f6e55e8e2daf574686ef9c6b18973f
push id8231
push userlrocha@mozilla.com
push dateFri, 15 Aug 2014 17:23:48 +0000
treeherderfx-team@31d4832196f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1054268
milestone34.0a1
Bug 1054268 - Show search icon in about:home (r=margaret)
mobile/android/base/AboutPages.java
mobile/android/base/Tabs.java
mobile/android/base/favicons/Favicons.java
--- a/mobile/android/base/AboutPages.java
+++ b/mobile/android/base/AboutPages.java
@@ -50,39 +50,42 @@ public class AboutPages {
     public static final boolean isAboutReader(final String url) {
         if (url == null) {
             return false;
         }
         return url.startsWith(READER);
     }
 
     private static final String[] DEFAULT_ICON_PAGES = new String[] {
-        HOME,
-
         ADDONS,
         CONFIG,
         DOWNLOADS,
         FIREFOX,
         HEALTHREPORT,
         UPDATER
     };
 
     /**
      * Callers must not modify the returned array.
      */
     public static String[] getDefaultIconPages() {
         return DEFAULT_ICON_PAGES;
     }
 
-    public static boolean isDefaultIconPage(final String url) {
+    public static boolean isBuiltinIconPage(final String url) {
         if (url == null ||
             !url.startsWith("about:")) {
             return false;
         }
 
+        // about:home uses a separate search built-in icon.
+        if (isAboutHome(url)) {
+            return true;
+        }
+
         // TODO: it'd be quicker to not compare the "about:" part every time.
         for (int i = 0; i < DEFAULT_ICON_PAGES.length; ++i) {
             if (DEFAULT_ICON_PAGES[i].equals(url)) {
                 return true;
             }
         }
         return false;
     }
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -826,17 +826,17 @@ public class Tabs implements GeckoEventL
             return null;
         }
 
         if (!delayLoad && !background) {
             selectTab(added.getId());
         }
 
         // TODO: surely we could just fetch *any* cached icon?
-        if (AboutPages.isDefaultIconPage(url)) {
+        if (AboutPages.isBuiltinIconPage(url)) {
             Log.d(LOGTAG, "Setting about: tab favicon inline.");
             added.updateFavicon(getAboutPageFavicon(url));
         }
 
         return added;
     }
 
     /**
--- a/mobile/android/base/favicons/Favicons.java
+++ b/mobile/android/base/favicons/Favicons.java
@@ -35,16 +35,19 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.Executors;
 
 public class Favicons {
     private static final String LOGTAG = "GeckoFavicons";
 
     // A magic URL representing the app's own favicon, used for about: pages.
     private static final String BUILT_IN_FAVICON_URL = "about:favicon";
 
+    // A magic URL representing the app's search favicon, used for about:home.
+    private static final String BUILT_IN_SEARCH_URL = "about:search";
+
     // Size of the favicon bitmap cache, in bytes (Counting payload only).
     public static final int FAVICON_CACHE_SIZE_BYTES = 512 * 1024;
 
     // Number of URL mappings from page URL to Favicon URL to cache in memory.
     public static final int NUM_PAGE_URL_MAPPINGS_TO_STORE = 128;
 
     public static final int NOT_LOADING  = 0;
     public static final int LOADED       = 1;
@@ -402,16 +405,20 @@ public class Favicons {
         }
 
         // Load and cache the built-in favicon in each of its sizes.
         // TODO: don't open the zip twice!
         List<Bitmap> toInsert = Arrays.asList(loadBrandingBitmap(context, "favicon64.png"),
                                               loadBrandingBitmap(context, "favicon32.png"));
 
         putFaviconsInMemCache(BUILT_IN_FAVICON_URL, toInsert.iterator(), true);
+
+        pageURLMappings.putWithoutEviction(AboutPages.HOME, BUILT_IN_SEARCH_URL);
+        List<Bitmap> searchIcons = Arrays.asList(BitmapFactory.decodeResource(res, R.drawable.ab_search));
+        putFaviconsInMemCache(BUILT_IN_SEARCH_URL, searchIcons.iterator(), true);
     }
 
     /**
      * Compute a string like:
      * "jar:jar:file:///data/app/org.mozilla.firefox-1.apk!/assets/omni.ja!/chrome/chrome/content/branding/favicon64.png"
      */
     private static String getBrandingBitmapPath(Context context, String name) {
         final String apkPath = context.getPackageResourcePath();