summaryrefslogtreecommitdiffstats
path: root/intl/strres
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2018-08-25 17:50:02 +0300
committerJustOff <Off.Just.Off@gmail.com>2018-08-25 17:50:02 +0300
commit02211f8448876cd7c72784380b9e9229959392bb (patch)
treeef6162073c537639db302ba777f0d62d5fffcabe /intl/strres
parent74c6c585ab519e3314bdf6b0fa23d8aa757b78a5 (diff)
downloadUXP-02211f8448876cd7c72784380b9e9229959392bb.tar
UXP-02211f8448876cd7c72784380b9e9229959392bb.tar.gz
UXP-02211f8448876cd7c72784380b9e9229959392bb.tar.lz
UXP-02211f8448876cd7c72784380b9e9229959392bb.tar.xz
UXP-02211f8448876cd7c72784380b9e9229959392bb.zip
Refresh nsStringBundleService and nsHttpHandler when the browser locale is changed
Diffstat (limited to 'intl/strres')
-rw-r--r--intl/strres/nsStringBundle.cpp27
-rw-r--r--intl/strres/nsStringBundleService.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp
index ab840a469..717e368e2 100644
--- a/intl/strres/nsStringBundle.cpp
+++ b/intl/strres/nsStringBundle.cpp
@@ -25,6 +25,7 @@
#include "nsIErrorService.h"
#include "nsICategoryManager.h"
#include "nsContentUtils.h"
+#include "mozilla/Preferences.h"
// for async loading
#ifdef ASYNC_LOADING
@@ -32,6 +33,9 @@
#include "nsIStringStream.h"
#endif
+#define STR_HELPER(x) #x
+#define STR(x) STR_HELPER(x)
+
using namespace mozilla;
static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID);
@@ -529,6 +533,8 @@ nsStringBundleService::Init()
os->AddObserver(this, "profile-do-change", true);
os->AddObserver(this, "chrome-flush-caches", true);
os->AddObserver(this, "xpcom-category-entry-added", true);
+ os->AddObserver(this, "selected-locale-has-changed", true);
+ os->AddObserver(this, "final-ui-startup", true);
}
// instantiate the override service, if there is any.
@@ -550,6 +556,19 @@ nsStringBundleService::Observe(nsISupports* aSubject,
{
flushBundleCache();
}
+ else if (strcmp("selected-locale-has-changed", aTopic) == 0)
+ {
+ flushBundleCache();
+ notifyBundlesFlushed();
+ }
+ else if (strcmp("final-ui-startup", aTopic) == 0)
+ {
+ nsAdoptingCString ualocale = Preferences::GetCString("general.useragent.locale");
+ if (!ualocale.EqualsLiteral(STR(MOZ_UI_LOCALE))) {
+ flushBundleCache();
+ notifyBundlesFlushed();
+ }
+ }
else if (strcmp("xpcom-category-entry-added", aTopic) == 0 &&
NS_LITERAL_STRING("xpcom-autoregistration").Equals(aSomeData))
{
@@ -560,6 +579,14 @@ nsStringBundleService::Observe(nsISupports* aSubject,
}
void
+nsStringBundleService::notifyBundlesFlushed()
+{
+ nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
+ NS_ASSERTION(obsSvc, "Couldn't get observer service.");
+ obsSvc->NotifyObservers(nullptr, "string-bundles-have-flushed", nullptr);
+}
+
+void
nsStringBundleService::flushBundleCache()
{
// release all bundles in the cache
diff --git a/intl/strres/nsStringBundleService.h b/intl/strres/nsStringBundleService.h
index a192cdff8..e65c61f12 100644
--- a/intl/strres/nsStringBundleService.h
+++ b/intl/strres/nsStringBundleService.h
@@ -43,6 +43,8 @@ private:
void flushBundleCache();
+ void notifyBundlesFlushed();
+
bundleCacheEntry_t *insertIntoCache(already_AddRefed<nsIStringBundle> aBundle,
nsCString &aHashKey);