Bug 1346616 - Migrate callsites that are retrieving requested locale from pref, to use LocaleService::GetRequestedLocales. r=jfkthame,Pike

I'm adding a helper function mozILocaleService::GetRequestedLocale to simplify
most of the callsites that are looking for the first of the requested locales.

In most cases, I'm just matching the behavior of the code with reusing
LocaleService API instead of direct manipulation on the prefs.
That includes how I handle error case scenarios.

In case of sdk/l10n/locale.js I am reusing LocaleService heuristics over
the custom one from the file since the ones in LocaleService are just
more correct and unified accross the whole platform.

In case of FallbackEncoding I have to turn it into a nsIObserver to listen
to intl:requested-locales-changed.

MozReview-Commit-ID: 7rOr2CovLK
This commit is contained in:
Zibi Braniecki
2017-03-11 18:43:11 -08:00
parent ca9c34b280
commit 8c433fc56a
22 changed files with 114 additions and 342 deletions

View File

@@ -875,12 +875,7 @@ function getDir(aKey, aIFace) {
* exists in nsHttpHandler.cpp when building the UA string.
*/
function getLocale() {
let locale = getLocalizedPref(LOCALE_PREF);
if (locale)
return locale;
// Not localized.
return Services.prefs.getCharPref(LOCALE_PREF);
return Services.locale.getRequestedLocale();
}
/**