Bug 1058352 - Correctly specify "other" instead of "null" for non-built-in search engines. r=mfinkle, a=sledru
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 26 Aug 2014 16:24:08 -0700
changeset 209575 e6ee35fe846e6d2e04842be3273c9cb71ac692af
parent 209574 8f4fa4abf4a7136b2441b869ae3072136436a7b0
child 209576 55c9365701e5a074c490b7a10bc947de1b5e200c
push id6711
push userryanvm@gmail.com
push dateThu, 28 Aug 2014 15:24:35 +0000
treeherdermozilla-aurora@55c9365701e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, sledru
bugs1058352
milestone33.0a2
Bug 1058352 - Correctly specify "other" instead of "null" for non-built-in search engines. r=mfinkle, a=sledru
mobile/android/base/preferences/SearchEnginePreference.java
--- a/mobile/android/base/preferences/SearchEnginePreference.java
+++ b/mobile/android/base/preferences/SearchEnginePreference.java
@@ -32,17 +32,17 @@ public class SearchEnginePreference exte
     // The icon to display in the prompt when clicked.
     private BitmapDrawable mPromptIcon;
 
     // The bitmap backing the drawable above - needed separately for the FaviconView.
     private Bitmap mIconBitmap;
 
     private FaviconView mFaviconView;
 
-    // Search engine identifier specified by the gecko search service. This will be null
+    // Search engine identifier specified by the gecko search service. This will be "other"
     // for engines that are not shipped with the app.
     private String mIdentifier;
 
     public SearchEnginePreference(Context context, SearchPreferenceCategory parentCategory) {
         super(context, parentCategory);
     }
 
     /**
@@ -118,27 +118,32 @@ public class SearchEnginePreference exte
                 break;
         }
     }
 
     /**
      * @return Identifier of built-in search engine, or "other" if engine is not built-in.
      */
     public String getIdentifier() {
-        return (mIdentifier == null) ? "other" : mIdentifier;
+        return mIdentifier;
     }
 
     /**
      * Configure this Preference object from the Gecko search engine JSON object.
      * @param geckoEngineJSON The Gecko-formatted JSON object representing the search engine.
      * @throws JSONException If the JSONObject is invalid.
      */
     public void setSearchEngineFromJSON(JSONObject geckoEngineJSON) throws JSONException {
         mIdentifier = geckoEngineJSON.getString("identifier");
 
+        // A null JS value gets converted into a string.
+        if (mIdentifier.equals("null")) {
+            mIdentifier = "other";
+        }
+
         final String engineName = geckoEngineJSON.getString("name");
         final SpannableString titleSpannable = new SpannableString(engineName);
 
         setTitle(titleSpannable);
 
         final String iconURI = geckoEngineJSON.getString("iconURI");
         // Keep a reference to the bitmap - we'll need it later in onBindView.
         try {