Bug 917480 - Part 0: refactor checking of isGeckoPref inside GeckoPreferences. r=liuche
authorRichard Newman <rnewman@mozilla.com>
Tue, 13 May 2014 20:50:26 -0700
changeset 183065 7cc9eb361a9d
parent 183064 8e90d6525389
child 183066 b0819a1afd15
push id26779
push usercbook@mozilla.com
push date2014-05-14 11:02 +0000
treeherdermozilla-central@5754fc307237 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs917480
milestone32.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 917480 - Part 0: refactor checking of isGeckoPref inside GeckoPreferences. r=liuche
mobile/android/base/preferences/GeckoPreferences.java
--- a/mobile/android/base/preferences/GeckoPreferences.java
+++ b/mobile/android/base/preferences/GeckoPreferences.java
@@ -434,23 +434,35 @@ public class GeckoPreferences
                 }
 
                 // Some Preference UI elements are not actually preferences,
                 // but they require a key to work correctly. For example,
                 // "Clear private data" requires a key for its state to be
                 // saved when the orientation changes. It uses the
                 // "android.not_a_preference.privacy.clear" key - which doesn't
                 // exist in Gecko - to satisfy this requirement.
-                if (key != null && !key.startsWith(NON_PREF_PREFIX)) {
+                if (isGeckoPref(key)) {
                     prefs.add(key);
                 }
             }
         }
     }
 
+    private boolean isGeckoPref(String key) {
+        if (TextUtils.isEmpty(key)) {
+            return false;
+        }
+
+        if (key.startsWith(NON_PREF_PREFIX)) {
+            return false;
+        }
+
+        return true;
+    }
+
     /**
      * Restore default search engines in Gecko and retrigger a search engine refresh.
      */
     protected void restoreDefaultSearchEngines() {
         GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:RestoreDefaults", null));
 
         // Send message to Gecko to get engines. SearchPreferenceCategory listens for the response.
         GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
@@ -607,17 +619,17 @@ public class GeckoPreferences
             // repeated background upload attempts.
             broadcastHealthReportUploadPref(GeckoAppShell.getContext(), ((Boolean) newValue).booleanValue());
         } else if (PREFS_GEO_REPORTING.equals(prefName)) {
             // Translate boolean value to int for geo reporting pref.
             newValue = ((Boolean) newValue) ? 1 : 0;
         }
 
         // Send Gecko-side pref changes to Gecko
-        if (!TextUtils.isEmpty(prefName) && !prefName.startsWith(NON_PREF_PREFIX)) {
+        if (isGeckoPref(prefName)) {
             PrefsHelper.setPref(prefName, newValue);
         }
 
         if (preference instanceof ListPreference) {
             // We need to find the entry for the new value
             int newIndex = ((ListPreference) preference).findIndexOfValue((String) newValue);
             CharSequence newEntry = ((ListPreference) preference).getEntries()[newIndex];
             ((ListPreference) preference).setSummary(newEntry);