Bug 1397925 - Refresh OSPreferences mSystemLocales when intl.locale.os changes. r?rnewman
MozReview-Commit-ID: oJdWUXwhZw
--- a/intl/locale/LocaleService.cpp
+++ b/intl/locale/LocaleService.cpp
@@ -525,19 +525,24 @@ LocaleService::IsAppLocaleRTL()
}
NS_IMETHODIMP
LocaleService::Observe(nsISupports *aSubject, const char *aTopic,
const char16_t *aData)
{
MOZ_ASSERT(mIsServer, "This should only be called in the server mode.");
+ NS_ConvertUTF16toUTF8 pref(aData);
+
+ // This is a temporary solution until we get bug 1337078 landed.
+ if (pref.EqualsLiteral(ANDROID_OS_LOCALE_PREF)) {
+ OSPreferences::GetInstance()->Refresh();
+ }
// At the moment the only thing we're observing are settings indicating
// user requested locales.
- NS_ConvertUTF16toUTF8 pref(aData);
if (pref.EqualsLiteral(MATCH_OS_LOCALE_PREF) ||
pref.EqualsLiteral(SELECTED_LOCALE_PREF) ||
pref.EqualsLiteral(ANDROID_OS_LOCALE_PREF)) {
OnRequestedLocalesChanged();
}
return NS_OK;
}
--- a/intl/locale/OSPreferences.h
+++ b/intl/locale/OSPreferences.h
@@ -123,16 +123,29 @@ public:
*
* (See mozIOSPreferences.idl for a JS-callable version of this.)
*/
bool GetRegionalPrefsLocales(nsTArray<nsCString>& aRetVal);
static bool GetDateTimeConnectorPattern(const nsACString& aLocale,
nsAString& aRetVal);
+ /**
+ * Triggers a refresh of retrieving data from host environment.
+ *
+ * If the result differs from the previous list, it will additionally
+ * trigger global events for changed values:
+ *
+ * * SystemLocales: "intl:system-locales-changed"
+ *
+ * This method should not be called from anywhere except of per-platform
+ * hooks into OS events.
+ */
+ void Refresh();
+
protected:
nsTArray<nsCString> mSystemLocales;
nsTArray<nsCString> mRegionalPrefsLocales;
private:
virtual ~OSPreferences() {};
static StaticRefPtr<OSPreferences> sInstance;
@@ -182,27 +195,14 @@ private:
* Callers should always be prepared to handle that scenario.
*
* The heuristic may depend on the OS API and HIG guidelines.
*/
bool ReadDateTimePattern(DateTimeFormatStyle aDateFormatStyle,
DateTimeFormatStyle aTimeFormatStyle,
const nsACString& aLocale,
nsAString& aRetVal);
-
- /**
- * Triggers a refresh of retrieving data from host environment.
- *
- * If the result differs from the previous list, it will additionally
- * trigger global events for changed values:
- *
- * * SystemLocales: "intl:system-locales-changed"
- *
- * This method should not be called from anywhere except of per-platform
- * hooks into OS events.
- */
- void Refresh();
};
} // intl
} // namespace mozilla
#endif /* mozilla_intl_IntlOSPreferences_h__ */