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 243710 581876946dcf
parent 243709 222d4a9f7ed3
child 243711 6f3775d5c839
push id4448
push usermfinkle@mozilla.com
push date2015-02-09 15:31 +0000
treeherdermozilla-beta@581876946dcf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, sylvestre
bugs1130246
milestone36.0
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);
   },