Bug 1130246 - Treat general.useragent.locale as a localized pref in DirectoryProvider. r=rnewman a=sylvestre
authorMike Connor <mconnor@mozilla.com>
Thu, 05 Feb 2015 20:46:01 -0800
changeset 249629 643a55c66fbc3fa47e9c2d03cb6f3dd52fde57a3
parent 249628 f0a33db91743a113c89361e85bd2366bc3540768
child 249630 5e50ea349b4730e368c4804a085e827ec541dec0
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, sylvestre
bugs1130246
milestone37.0a2
Bug 1130246 - Treat general.useragent.locale as a localized pref in DirectoryProvider. r=rnewman a=sylvestre
mobile/android/components/DirectoryProvider.js
--- a/mobile/android/components/DirectoryProvider.js
+++ b/mobile/android/components/DirectoryProvider.js
@@ -116,22 +116,33 @@ DirectoryProvider.prototype = {
     if (commonPlugins.exists())
       array.push(commonPlugins);
 
     let localePlugins = searchPlugins.clone();
     localePlugins.append("locale");
     if (!localePlugins.exists())
       return;
 
-    let curLocale = Services.prefs.getCharPref("general.useragent.locale");
-    let curLocalePlugins = localePlugins.clone();
-    curLocalePlugins.append(curLocale);
-    if (curLocalePlugins.exists()) {
-      array.push(curLocalePlugins);
-      return;
+    let curLocale = "";
+    try {
+      curLocale = Services.prefs.getComplexValue("general.useragent.locale", Ci.nsIPrefLocalizedString).data;
+    } catch (e) {
+      try {
+        curLocale = Services.prefs.getCharPref("general.useragent.locale");
+      } catch (ee) {
+      }
+    }
+
+    if (curLocale) {
+      let curLocalePlugins = localePlugins.clone();
+      curLocalePlugins.append(curLocale);
+      if (curLocalePlugins.exists()) {
+        array.push(curLocalePlugins);
+        return;
+      }
     }
 
     // We didn't append the locale dir - try the default one.
     let defLocale = Services.prefs.getCharPref("distribution.searchplugins.defaultLocale");
     let defLocalePlugins = localePlugins.clone();
     if (defLocalePlugins.exists())
       array.push(defLocalePlugins);
   },