diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 25dc7c7d9523..03269dc26de6 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -365,6 +365,7 @@ #include "nsStreamUtils.h" #include "nsString.h" #include "nsStringBuffer.h" +#include "nsStringBundle.h" #include "nsStringFlags.h" #include "nsStringFwd.h" #include "nsStringIterator.h" @@ -4084,6 +4085,16 @@ static const char* gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT] = { "resource://gre/res/locale/layout/HtmlForm.properties", "resource://gre/res/locale/dom/dom.properties"}; +/* static */ +nsresult nsContentUtils::EnsureAndLoadStringBundle(PropertiesFile aFile) { + MOZ_ASSERT(NS_IsMainThread(), "Should be called on main thread."); + nsresult rv = EnsureStringBundle(aFile); + if (NS_FAILED(rv)) { + return rv; + } + return nsStringBundleBase::Cast(sStringBundles[aFile])->LoadProperties(); +} + /* static */ nsresult nsContentUtils::EnsureStringBundle(PropertiesFile aFile) { if (!sStringBundles[aFile]) { diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 4a7bc62fe746..32e94c16437b 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3358,6 +3358,13 @@ class nsContentUtils { */ static uint32_t ResolveObjectType(uint32_t aType); + /** + * Create and load the string bundle for the 'aFile'. + * This API is used to preload the string bundle on the main thread so later + * other thread could access it. + */ + static nsresult EnsureAndLoadStringBundle(PropertiesFile aFile); + private: static bool InitializeEventTable(); diff --git a/intl/strres/moz.build b/intl/strres/moz.build index 564d3d690ea8..0146366cdeb8 100644 --- a/intl/strres/moz.build +++ b/intl/strres/moz.build @@ -20,6 +20,10 @@ LOCAL_INCLUDES += [ "/xpcom/ds", ] +EXPORTS += [ + "nsStringBundle.h", +] + include("/ipc/chromium/chromium-config.mozbuild") FINAL_LIBRARY = "xul"