Bug 1058352 - Correctly specify "other" instead of "null" for non-built-in search engines. r=mfinkle
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 26 Aug 2014 16:24:08 -0700
changeset 201694 0f0b691f66dd3a4c0f0217aba94146e8b0c2666f
parent 201693 512b16337fa9435e73e2895b15ce375c043191ed
child 201695 aca5bff5dce50402fdd1af78f33d00f7ac1f716d
push id8381
push usermleibovic@mozilla.com
push dateTue, 26 Aug 2014 23:24:16 +0000
treeherderfx-team@0f0b691f66dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1058352
milestone34.0a1
Bug 1058352 - Correctly specify "other" instead of "null" for non-built-in search engines. r=mfinkle
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 {