mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1356066 - JS_SetDefaultLocale should be updated on intl:app-locales-changed. r=shu,smaug
MozReview-Commit-ID: wDftiQLfax --HG-- extra : rebase_source : 6080b5aa72bac7712e0a62275c260731aee7db00
This commit is contained in:
parent
5e3cdb7bf1
commit
abdb6cbf08
@ -11,18 +11,58 @@
|
|||||||
#include "nsCollationCID.h"
|
#include "nsCollationCID.h"
|
||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
#include "nsICollation.h"
|
#include "nsICollation.h"
|
||||||
|
#include "nsIObserver.h"
|
||||||
#include "nsNativeCharsetUtils.h"
|
#include "nsNativeCharsetUtils.h"
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "mozilla/CycleCollectedJSContext.h"
|
||||||
#include "mozilla/intl/LocaleService.h"
|
#include "mozilla/intl/LocaleService.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
#include "xpcpublic.h"
|
#include "xpcpublic.h"
|
||||||
|
|
||||||
using namespace JS;
|
using namespace JS;
|
||||||
|
using namespace mozilla;
|
||||||
using mozilla::intl::LocaleService;
|
using mozilla::intl::LocaleService;
|
||||||
|
|
||||||
|
class XPCLocaleObserver : public nsIObserver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIOBSERVER
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~XPCLocaleObserver() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS(XPCLocaleObserver, nsIObserver);
|
||||||
|
|
||||||
|
void
|
||||||
|
XPCLocaleObserver::Init()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIObserverService> observerService =
|
||||||
|
mozilla::services::GetObserverService();
|
||||||
|
|
||||||
|
observerService->AddObserver(this, "intl:app-locales-changed", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
XPCLocaleObserver::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
|
||||||
|
{
|
||||||
|
if (!strcmp(aTopic, "intl:app-locales-changed")) {
|
||||||
|
JSContext* cx = CycleCollectedJSContext::Get()->Context();
|
||||||
|
if (!xpc_LocalizeContext(cx)) {
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JS locale callbacks implemented by XPCOM modules. These are theoretically
|
* JS locale callbacks implemented by XPCOM modules. These are theoretically
|
||||||
* safe for use on multiple threads. Unfortunately, the intl code underlying
|
* safe for use on multiple threads. Unfortunately, the intl code underlying
|
||||||
@ -42,6 +82,10 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks
|
|||||||
localeToLowerCase = LocaleToLowerCase;
|
localeToLowerCase = LocaleToLowerCase;
|
||||||
localeCompare = LocaleCompare;
|
localeCompare = LocaleCompare;
|
||||||
localeToUnicode = LocaleToUnicode;
|
localeToUnicode = LocaleToUnicode;
|
||||||
|
|
||||||
|
// It's going to be retained by the ObserverService.
|
||||||
|
RefPtr<XPCLocaleObserver> locObs = new XPCLocaleObserver();
|
||||||
|
locObs->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
~XPCLocaleCallbacks()
|
~XPCLocaleCallbacks()
|
||||||
|
Loading…
Reference in New Issue
Block a user