Bug 1686616 - make StringBundle use Components instead of Services. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D105531
This commit is contained in:
Alexis Beingessner 2021-02-18 13:26:32 +00:00
Родитель 3f1a425606
Коммит 07f2f659c6
29 изменённых файлов: 49 добавлений и 46 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "DocAccessibleWrap.h"
#include "SessionAccessibility.h"
#include "mozilla/a11y/ProxyAccessible.h"
#include "mozilla/Components.h"
#include "nsIAccessibleEvent.h"
#include "nsIAccessiblePivot.h"
#include "nsIStringBundle.h"
@ -220,7 +221,7 @@ bool a11y::LocalizeString(const char* aToken, nsAString& aLocalized,
MOZ_ASSERT(XRE_IsParentProcess());
nsresult rv = NS_OK;
if (!sStringBundle) {
nsCOMPtr<nsIStringBundleService> sbs = services::GetStringBundleService();
nsCOMPtr<nsIStringBundleService> sbs = components::StringBundle::Service();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to get string bundle service");
return false;

Просмотреть файл

@ -65,6 +65,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/Components.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/EventStates.h"
#include "mozilla/FloatingPoint.h"
@ -277,7 +278,7 @@ KeyBinding Accessible::KeyboardShortcut() const { return KeyBinding(); }
void Accessible::TranslateString(const nsString& aKey, nsAString& aStringOut) {
nsCOMPtr<nsIStringBundleService> stringBundleService =
services::GetStringBundleService();
components::StringBundle::Service();
if (!stringBundleService) return;
nsCOMPtr<nsIStringBundle> stringBundle;
@ -2759,7 +2760,7 @@ uint32_t KeyBinding::AccelModifier() {
void KeyBinding::ToPlatformFormat(nsAString& aValue) const {
nsCOMPtr<nsIStringBundle> keyStringBundle;
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (stringBundleService)
stringBundleService->CreateBundle(
"chrome://global-platform/locale/platformKeys.properties",

Просмотреть файл

@ -15,7 +15,7 @@
#include "nsServiceManagerUtils.h"
#include "mozilla/dom/Document.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "nsGlobalWindow.h"
#include "nsIStringBundle.h"
@ -35,7 +35,7 @@ ENameValueFlag ApplicationAccessible::Name(nsString& aName) const {
aName.Truncate();
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ASSERTION(bundleService, "String bundle service must be present!");
if (!bundleService) return eNameOK;

Просмотреть файл

@ -111,7 +111,7 @@ class BundleHelper {
nsIStringBundle* GetOrCreateInternal() {
if (!mBundle) {
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (NS_WARN_IF(!bundleService)) {
return nullptr;
}

Просмотреть файл

@ -36,7 +36,6 @@
#include "mozilla/SchedulerGroup.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/Components.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_docshell.h"
#include "mozilla/StaticPrefs_dom.h"
@ -12285,7 +12284,7 @@ nsresult nsDocShell::GetPromptAndStringBundle(nsIPrompt** aPrompt,
NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ENSURE_TRUE(stringBundleService, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozilla/dom/EventSource.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Components.h"
#include "mozilla/DataMutex.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/LoadInfo.h"
@ -1283,7 +1284,7 @@ nsresult EventSourceImpl::PrintErrorOnConsole(
AssertIsOnMainThread();
MOZ_ASSERT(!mIsShutDown);
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ENSURE_STATE(bundleService);
nsCOMPtr<nsIStringBundle> strBundle;

Просмотреть файл

@ -869,7 +869,7 @@ void nsContentUtils::GetModifierSeparatorText(nsAString& text) {
void nsContentUtils::InitializeModifierStrings() {
// load the display strings for the keyboard accelerators
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
nsCOMPtr<nsIStringBundle> bundle;
DebugOnly<nsresult> rv = NS_OK;
if (bundleService) {

Просмотреть файл

@ -11,6 +11,7 @@
#include "jsapi.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/BinarySearch.h"
#include "mozilla/Components.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
@ -938,7 +939,7 @@ nsresult HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL,
nsCOMPtr<nsIStringBundle> stringBundle;
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!stringBundleService) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Components.h"
#include "mozilla/dom/AutocompleteInfoBinding.h"
#include "mozilla/dom/BlobImpl.h"
#include "mozilla/dom/Directory.h"
@ -6734,7 +6735,7 @@ void HTMLInputElement::SetFilePickerFiltersFromAccept(
// Services to retrieve image/*, audio/*, video/* filters
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!stringService) {
return;
}

Просмотреть файл

@ -18,7 +18,7 @@
#include "nsDocElementCreatedNotificationRunner.h"
#include "mozilla/Encoding.h"
#include "mozilla/PresShell.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "nsServiceManagerUtils.h"
#include "nsIPrincipal.h"
#include "nsIMultiPartChannel.h"
@ -319,7 +319,7 @@ void MediaDocument::FormatStringFromName(const char* aName,
if (!spoofLocale) {
if (!mStringBundle) {
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (stringService) {
stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI,
getter_AddRefs(mStringBundle));
@ -331,7 +331,7 @@ void MediaDocument::FormatStringFromName(const char* aName,
} else {
if (!mStringBundleEnglish) {
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (stringService) {
stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI_en_US,
getter_AddRefs(mStringBundleEnglish));

Просмотреть файл

@ -2337,7 +2337,7 @@ mozilla::ipc::IPCResult ContentChild::RecvAsyncMessage(
mozilla::ipc::IPCResult ContentChild::RecvRegisterStringBundles(
nsTArray<mozilla::dom::StringBundleDescriptor>&& aDescriptors) {
nsCOMPtr<nsIStringBundleService> stringBundleService =
services::GetStringBundleService();
components::StringBundle::Service();
for (auto& descriptor : aDescriptors) {
stringBundleService->RegisterContentBundle(

Просмотреть файл

@ -45,13 +45,11 @@
#include "gfxPlatform.h"
#include "gfxPlatformFontList.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/Components.h"
#include "mozilla/ContentBlocking.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/BenchmarkStorageParent.h"
#include "mozilla/ContentBlockingUserInteraction.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Components.h"
#include "mozilla/DataStorage.h"
#ifdef MOZ_GLEAN
# include "mozilla/FOGIPC.h"
@ -2997,7 +2995,7 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
chromeRegistry->SendRegisteredChrome(this);
nsCOMPtr<nsIStringBundleService> stringBundleService =
services::GetStringBundleService();
components::StringBundle::Service();
stringBundleService->SendContentBundles(this);
if (gAppData) {

Просмотреть файл

@ -14,7 +14,7 @@
#include "mozilla/ipc/FileDescriptor.h"
#include "mozilla/Logging.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
@ -365,7 +365,7 @@ void InitBrandName() {
}
nsAutoString brandName;
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (stringBundleService) {
nsCOMPtr<nsIStringBundle> brandBundle;
nsresult rv = stringBundleService->CreateBundle(

Просмотреть файл

@ -22,6 +22,7 @@
#include "nsSandboxFlags.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/Components.h"
#include "mozilla/dom/CSPDictionariesBinding.h"
#include "mozilla/dom/Document.h"
#include "mozilla/StaticPrefs_security.h"
@ -158,7 +159,7 @@ void CSP_GetLocalizedStr(const char* aName, const nsTArray<nsString>& aParams,
nsAString& outResult) {
nsCOMPtr<nsIStringBundle> keyStringBundle;
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ASSERTION(stringBundleService, "String bundle service must be present!");
stringBundleService->CreateBundle(

Просмотреть файл

@ -8,6 +8,7 @@
#include "nsContentSecurityUtils.h"
#include "mozilla/Components.h"
#include "mozilla/dom/nsMixedContentBlocker.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsComponentManagerUtils.h"
@ -636,7 +637,7 @@ void nsContentSecurityUtils::NotifyEvalUsage(bool aIsSystemPrincipal,
}
nsCOMPtr<nsIStringBundle> bundle;
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!stringService) {
return;
}

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsIXPConnect.h"
#include "nsVariant.h"
#include "nsTextNode.h"
#include "mozilla/Components.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/XSLTProcessorBinding.h"
@ -932,7 +933,7 @@ void txMozillaXSLTProcessor::reportError(nsresult aResult,
mErrorText.Assign(aErrorText);
} else {
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (sbs) {
nsString errorText;
sbs->FormatStatusMessage(aResult, u"", errorText);

Просмотреть файл

@ -988,7 +988,7 @@ void nsPrintJob::GetDisplayTitleAndURL(Document& aDoc,
} else {
nsCOMPtr<nsIStringBundle> brandBundle;
nsCOMPtr<nsIStringBundleService> svc =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (svc) {
svc->CreateBundle("chrome://branding/locale/brand.properties",
getter_AddRefs(brandBundle));

Просмотреть файл

@ -13,7 +13,7 @@
#include "mozilla/css/Loader.h"
#include "mozilla/Preferences.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "nsIConsoleService.h"
#include "mozilla/dom/Document.h"
#include "nsComponentManagerUtils.h"
@ -91,7 +91,7 @@ void ErrorReporter::InitGlobals() {
return;
}
nsCOMPtr<nsIStringBundleService> sbs = services::GetStringBundleService();
nsCOMPtr<nsIStringBundleService> sbs = components::StringBundle::Service();
if (!sbs) {
return;
}

Просмотреть файл

@ -32,7 +32,6 @@
#include "mozilla/ResultExtensions.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/SpinEventLoopUntil.h"
#include "mozilla/StaticMutex.h"
@ -2744,7 +2743,7 @@ nsresult nsPrefBranch::GetDefaultFromPropertiesFile(const char* aPrefName,
}
nsCOMPtr<nsIStringBundleService> bundleService =
services::GetStringBundleService();
components::StringBundle::Service();
if (!bundleService) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -7,7 +7,7 @@
#include "nsString.h"
#include "nsParserMsgUtils.h"
#include "nsNetCID.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
static nsresult GetBundle(const char* aPropFileName,
nsIStringBundle** aBundle) {
@ -17,7 +17,7 @@ static nsresult GetBundle(const char* aPropFileName,
// Create a bundle for the localization
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!stringService) return NS_ERROR_FAILURE;
return stringService->CreateBundle(aPropFileName, aBundle);

Просмотреть файл

@ -6,6 +6,7 @@
#include <stdio.h>
#include "mozilla/Components.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/IntegerPrintfMacros.h"
@ -3295,7 +3296,7 @@ nsICollation* nsNavHistory::GetCollation() {
nsIStringBundle* nsNavHistory::GetBundle() {
if (!mBundle) {
nsCOMPtr<nsIStringBundleService> bundleService =
services::GetStringBundleService();
components::StringBundle::Service();
NS_ENSURE_TRUE(bundleService, nullptr);
nsresult rv = bundleService->CreateBundle(
"chrome://places/locale/places.properties", getter_AddRefs(mBundle));

Просмотреть файл

@ -346,7 +346,7 @@ class CSPValidator final : public nsCSPSrcVisitor {
already_AddRefed<nsIStringBundle> GetStringBundle() {
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ENSURE_TRUE(sbs, nullptr);
nsCOMPtr<nsIStringBundle> stringBundle;

Просмотреть файл

@ -19,7 +19,6 @@
#include "mozilla/Components.h"
#include "mozilla/XREAppData.h"
#include "mozilla/Services.h"
#include "mozilla/SpinEventLoopUntil.h"
#include "mozilla/Unused.h"
#include "prtime.h"
@ -49,7 +48,7 @@ nsresult ProfileResetCleanup(nsToolkitProfileService* aService,
// Get the friendly name for the backup directory.
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!sbs) return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> sb;

Просмотреть файл

@ -23,7 +23,6 @@
#include "mozilla/Printf.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Utf8.h"
@ -2305,7 +2304,7 @@ static nsresult ProfileMissingDialog(nsINativeAppSupport* aNative) {
{ // extra scoping is needed so we release these components before xpcom
// shutdown
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> sb;
@ -2359,7 +2358,7 @@ static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir,
{ // extra scoping is needed so we release these components before xpcom
// shutdown
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> sb;

Просмотреть файл

@ -1179,7 +1179,7 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsresult aStatus,
}
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!sbs) return NS_ERROR_FAILURE;
nsAutoString msg;
nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, msg);

Просмотреть файл

@ -2000,7 +2000,7 @@ void nsExternalAppHandler::SendStatusChange(ErrorType type, nsresult rv,
// Get properties file bundle and extract status string.
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (stringService) {
nsCOMPtr<nsIStringBundle> bundle;
if (NS_SUCCEEDED(stringService->CreateBundle(

Просмотреть файл

@ -7,7 +7,7 @@
#include "mozilla/WidgetUtils.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "mozilla/Unused.h"
#include "nsContentUtils.h"
#include "nsIBidiKeyboard.h"
@ -132,7 +132,7 @@ void WidgetUtils::GetBrandShortName(nsAString& aBrandName) {
aBrandName.Truncate();
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
nsCOMPtr<nsIStringBundle> bundle;
if (bundleService) {

Просмотреть файл

@ -16,7 +16,7 @@
#include "nsEnumeratorUtils.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/File.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "WidgetUtils.h"
#include "nsSimpleEnumerator.h"
#include "nsThreadUtils.h"
@ -173,7 +173,7 @@ nsBaseFilePicker::Open(nsIFilePickerShownCallback* aCallback) {
NS_IMETHODIMP
nsBaseFilePicker::AppendFilters(int32_t aFilterMask) {
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!stringService) return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> titleBundle, filterBundle;

Просмотреть файл

@ -25,7 +25,7 @@
#include "nsEscape.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "mozilla/Services.h"
#include "mozilla/Components.h"
#include "mozilla/SpinEventLoopUntil.h"
#include "mozilla/Unused.h"
#include "nsIOutputStream.h"
@ -1145,7 +1145,7 @@ static bool CreateFilenameFromTextW(nsString& aText, const wchar_t* aExtension,
static bool GetLocalizedString(const char* aName, nsAString& aString) {
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
mozilla::components::StringBundle::Service();
if (!stringService) return false;
nsCOMPtr<nsIStringBundle> stringBundle;