Bug 564950 - Make more use of mozilla::services, r=surkov, jst, neil, smontagu, roc, joshmoz, gavin, shaver

This commit is contained in:
Mitchell Field 2010-05-14 18:24:41 +09:00
parent 56d9175ecd
commit 0fd15d94da
37 changed files with 152 additions and 115 deletions

View File

@ -254,7 +254,7 @@ nsAccessNode::GetApplicationAccessible()
void nsAccessNode::InitXPAccessibility()
{
nsCOMPtr<nsIStringBundleService> stringBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
mozilla::services::GetStringBundleService();
if (stringBundleService) {
// Static variables are released in ShutdownAllXPAccessibility();
stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL,

View File

@ -50,6 +50,7 @@
#include "nsIDOMWindow.h"
#include "nsIWindowMediator.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/Services.h"
nsApplicationAccessible::nsApplicationAccessible() :
nsAccessibleWrap(nsnull, nsnull)
@ -83,7 +84,7 @@ nsApplicationAccessible::GetName(nsAString& aName)
aName.Truncate();
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
mozilla::services::GetStringBundleService();
NS_ASSERTION(bundleService, "String bundle service must be present!");
NS_ENSURE_STATE(bundleService);

View File

@ -3388,8 +3388,10 @@ nsresult nsScriptSecurityManager::Init()
nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
if (!bundleService)
return NS_ERROR_FAILURE;
rv = bundleService->CreateBundle("chrome://global/locale/security/caps.properties", &sStrBundle);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -183,7 +183,8 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
if (!nsChromeRegistry::gChromeRegistry) {
// We don't actually want this ref, we just want the service to
// initialize if it hasn't already.
nsCOMPtr<nsIChromeRegistry> reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
nsCOMPtr<nsIChromeRegistry> reg =
mozilla::services::GetChromeRegistryService();
NS_ENSURE_TRUE(nsChromeRegistry::gChromeRegistry, NS_ERROR_FAILURE);
}

View File

@ -2980,7 +2980,7 @@ nsContentUtils::GetWrapperSafeScriptFilename(nsIDocument *aDocument,
if (IsChromeDoc(aDocument)) {
nsCOMPtr<nsIChromeRegistry> chromeReg =
do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
mozilla::services::GetChromeRegistryService();
if (!chromeReg) {
// If we're running w/o a chrome registry we won't modify any

View File

@ -141,8 +141,8 @@ nsMediaDocument::Init()
NS_ENSURE_SUCCESS(rv, rv);
// Create a bundle for the localization
nsCOMPtr<nsIStringBundleService> stringService(
do_GetService(NS_STRINGBUNDLE_CONTRACTID));
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (stringService) {
stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI,
getter_AddRefs(mStringBundle));

View File

@ -54,6 +54,7 @@
#include "nsIScriptSecurityManager.h"
#include "nsContentUtils.h"
#include "nsDOMJSUtils.h"
#include "mozilla/Services.h"
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
@ -506,7 +507,8 @@ nsXBLDocumentInfo::nsXBLDocumentInfo(nsIDocument* aDocument)
nsIURI* uri = aDocument->GetDocumentURI();
if (IsChromeURI(uri)) {
// Cache whether or not this chrome XBL can execute scripts.
nsCOMPtr<nsIXULChromeRegistry> reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
nsCOMPtr<nsIXULChromeRegistry> reg =
mozilla::services::GetXULChromeRegistryService();
if (reg) {
PRBool allow = PR_TRUE;
reg->AllowScriptsForPackage(uri, &allow);

View File

@ -1080,7 +1080,7 @@ txMozillaXSLTProcessor::reportError(nsresult aResult,
}
else {
nsCOMPtr<nsIStringBundleService> sbs =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
mozilla::services::GetStringBundleService();
if (sbs) {
nsXPIDLString errorText;
sbs->FormatStatusMessage(aResult, EmptyString().get(),

View File

@ -580,7 +580,7 @@ nsXULDocument::EndLoad()
if (isChrome) {
nsCOMPtr<nsIXULOverlayProvider> reg =
do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
mozilla::services::GetXULOverlayProviderService();
if (reg) {
nsCOMPtr<nsISimpleEnumerator> overlays;
@ -2626,7 +2626,8 @@ nsXULDocument::AddChromeOverlays()
/* overlays only apply to chrome, skip all content URIs */
if (!IsChromeURI(docUri)) return NS_OK;
nsCOMPtr<nsIXULOverlayProvider> chromeReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
nsCOMPtr<nsIXULOverlayProvider> chromeReg =
mozilla::services::GetXULOverlayProviderService();
// In embedding situations, the chrome registry may not provide overlays,
// or even exist at all; that's OK.
NS_ENSURE_TRUE(chromeReg, NS_OK);
@ -4636,7 +4637,7 @@ nsXULDocument::IsDocumentRightToLeft()
// otherwise, get the locale from the chrome registry and
// look up the intl.uidirection.<locale> preference
nsCOMPtr<nsIXULChromeRegistry> reg =
do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
mozilla::services::GetXULChromeRegistryService();
if (!reg)
return PR_FALSE;

View File

@ -752,9 +752,10 @@ nsXULPrototypeCache::StartFastLoad(nsIURI* aURI)
return NS_ERROR_OUT_OF_MEMORY;
fastLoadService->SetFileIO(io);
nsCOMPtr<nsIXULChromeRegistry> chromeReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIXULChromeRegistry> chromeReg =
mozilla::services::GetXULChromeRegistryService();
if (!chromeReg)
return NS_ERROR_FAILURE;
// XXXbe we assume the first package's locale is the same as the locale of
// all subsequent packages of FastLoaded chrome URIs....

View File

@ -10177,17 +10177,17 @@ nsDocShell::GetLoadType(PRUint32 * aLoadType)
nsresult
nsDocShell::ConfirmRepost(PRBool * aRepost)
{
nsresult rv;
nsCOMPtr<nsIPrompt> prompter;
CallGetInterface(this, static_cast<nsIPrompt**>(getter_AddRefs(prompter)));
nsCOMPtr<nsIStringBundleService>
stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
if (!stringBundleService)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> appBundle;
rv = stringBundleService->CreateBundle(kAppstringsBundleURL,
getter_AddRefs(appBundle));
nsresult rv = stringBundleService->CreateBundle(kAppstringsBundleURL,
getter_AddRefs(appBundle));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> brandBundle;
@ -10240,8 +10240,8 @@ nsDocShell::GetPromptAndStringBundle(nsIPrompt ** aPrompt,
NS_ENSURE_SUCCESS(GetInterface(NS_GET_IID(nsIPrompt), (void **) aPrompt),
NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundleService>
stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
NS_ENSURE_TRUE(stringBundleService, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(stringBundleService->

View File

@ -1541,8 +1541,8 @@ FindObjectClass(JSObject* aGlobalObject)
static void
PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
{
nsCOMPtr<nsIStringBundleService>
stringService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (!stringService) {
return;
}

View File

@ -58,6 +58,7 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsITextServicesFilter.h"
#include "mozilla/Services.h"
NS_IMPL_ISUPPORTS1(nsEditorSpellCheck,
nsIEditorSpellCheck)
@ -197,9 +198,9 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, PRBool aEnableSelection
// locale and use that as the default dictionary name!
nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
mozilla::services::GetXULChromeRegistryService();
if (NS_SUCCEEDED(rv) && packageRegistry) {
if (packageRegistry) {
nsCAutoString utf8DictName;
rv = packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"),
utf8DictName);

View File

@ -43,6 +43,7 @@
#include "nsUnicharUtils.h"
#include "nsIServiceManager.h"
#include "nsIAtom.h"
#include "mozilla/Services.h"
NS_IMPL_ISUPPORTS1(nsLanguageAtomService, nsILanguageAtomService)
@ -54,16 +55,16 @@ nsLanguageAtomService::nsLanguageAtomService()
nsresult
nsLanguageAtomService::InitLangGroupTable()
{
if (mLangGroups) return NS_OK;
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
if (mLangGroups)
return NS_OK;
rv = bundleService->CreateBundle("resource://gre/res/langGroups.properties",
getter_AddRefs(mLangGroups));
return rv;
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
if (!bundleService)
return NS_ERROR_FAILURE;
return bundleService->CreateBundle("resource://gre/res/langGroups.properties",
getter_AddRefs(mLangGroups));
}
nsIAtom*

View File

@ -52,6 +52,7 @@
#include "nsTArray.h"
#include "nsStringEnumerator.h"
#include "nsThreadUtils.h"
#include "mozilla/Services.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
@ -111,12 +112,10 @@ nsresult nsCharsetConverterManager::LoadExtensibleBundle(
const char* aCategory,
nsIStringBundle ** aResult)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIStringBundleService> sbServ =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIStringBundleService> sbServ =
mozilla::services::GetStringBundleService();
if (!sbServ)
return NS_ERROR_FAILURE;
return sbServ->CreateExtensibleBundle(aCategory, aResult);
}

View File

@ -45,6 +45,7 @@
#include "nsXPIDLString.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "mozilla/Services.h"
//
// implementation methods
@ -64,14 +65,14 @@ NS_IMETHODIMP
nsEntityConverter::LoadVersionPropertyFile()
{
NS_NAMED_LITERAL_CSTRING(url, "resource://gre/res/entityTables/htmlEntityVersions.properties");
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
if (!bundleService)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> entities;
rv = bundleService->CreateBundle(url.get(), getter_AddRefs(entities));
nsresult rv = bundleService->CreateBundle(url.get(), getter_AddRefs(entities));
if (NS_FAILED(rv)) return rv;
PRInt32 result;

View File

@ -151,7 +151,8 @@ CheckFontExistence(nsPresContext* aPresContext, const nsString& aFontName)
static void
AlertMissingFonts(nsString& aMissingFonts)
{
nsCOMPtr<nsIStringBundleService> sbs(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
if (!sbs)
return;

View File

@ -42,6 +42,7 @@
#include "nsPrintObject.h"
#include "nsPrintPreviewListener.h"
#include "nsIWebProgressListener.h"
#include "mozilla/Services.h"
//-----------------------------------------------------
// PR LOGGING
@ -75,7 +76,8 @@ nsPrintData::nsPrintData(ePrintDataType aType) :
{
nsCOMPtr<nsIStringBundle> brandBundle;
nsCOMPtr<nsIStringBundleService> svc( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) );
nsCOMPtr<nsIStringBundleService> svc =
mozilla::services::GetStringBundleService();
if (svc) {
svc->CreateBundle( "chrome://branding/locale/brand.properties", getter_AddRefs( brandBundle ) );
if (brandBundle) {

View File

@ -57,6 +57,7 @@
#include "nsIScriptError.h"
#include "nsIStringBundle.h"
#include "nsContentUtils.h"
#include "mozilla/Services.h"
#ifdef CSS_REPORT_PARSE_ERRORS
static PRBool gReportErrors = PR_TRUE;
@ -447,7 +448,7 @@ InitStringBundle()
return PR_TRUE;
nsCOMPtr<nsIStringBundleService> sbs =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
mozilla::services::GetStringBundleService();
if (!sbs)
return PR_FALSE;

View File

@ -82,6 +82,7 @@
#include "nsISound.h"
#include "nsEventStateManager.h"
#include "nsIDOMXULMenuListElement.h"
#include "mozilla/Services.h"
#define NS_MENU_POPUP_LIST_INDEX 0
@ -271,13 +272,13 @@ nsMenuFrame::Init(nsIContent* aContent,
//load the display strings for the keyboard accelerators, but only once
if (gRefCnt++ == 0) {
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
nsCOMPtr<nsIStringBundle> bundle;
if (NS_SUCCEEDED(rv) && bundleService) {
if (bundleService) {
rv = bundleService->CreateBundle( "chrome://global-platform/locale/platformKeys.properties",
getter_AddRefs(bundle));
}
}
NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/platformKeys.properties could not be loaded");
nsXPIDLString shiftModifier;
@ -1055,8 +1056,9 @@ nsMenuFrame::BuildAcceleratorText()
ToUpperCase(keyCode);
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && bundleService) {
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
if (bundleService) {
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle("chrome://global/locale/keys.properties",
getter_AddRefs(bundle));

View File

@ -753,11 +753,11 @@ nsresult nsPrefBranch::GetDefaultFromPropertiesFile(const char *aPrefName, PRUni
rv = PREF_CopyCharPref(aPrefName, getter_Copies(propertyFileURL), PR_TRUE);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
mozilla::services::GetStringBundleService();
if (!bundleService)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(propertyFileURL,

View File

@ -4590,9 +4590,10 @@ nsPluginHost::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginInstance *aInstance)
nsCOMPtr<nsIPrompt> prompt;
GetPrompt(owner, getter_AddRefs(prompt));
if (prompt) {
nsCOMPtr<nsIStringBundleService> strings(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIStringBundleService> strings =
mozilla::services::GetStringBundleService();
if (!strings)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> bundle;
rv = strings->CreateBundle(BRAND_PROPERTIES_URL, getter_AddRefs(bundle));

View File

@ -40,6 +40,7 @@
#include "nsXPIDLString.h"
#include "nsParserMsgUtils.h"
#include "nsNetCID.h"
#include "mozilla/Services.h"
static nsresult GetBundle(const char * aPropFileName, nsIStringBundle **aBundle)
{
@ -47,14 +48,13 @@ static nsresult GetBundle(const char * aPropFileName, nsIStringBundle **aBundle)
NS_ENSURE_ARG_POINTER(aBundle);
// Create a bundle for the localization
nsresult rv;
nsCOMPtr<nsIStringBundleService> stringService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
rv = stringService->CreateBundle(aPropFileName, aBundle);
return rv;
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (!stringService)
return NS_ERROR_FAILURE;
return stringService->CreateBundle(aPropFileName, aBundle);
}
nsresult

View File

@ -846,13 +846,12 @@ nsDownloadManager::Init()
if (!mObserverService)
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetStringBundleService();
if (!bundleService)
return NS_ERROR_FAILURE;
rv = InitDB();
nsresult rv = InitDB();
NS_ENSURE_SUCCESS(rv, rv);
rv = bundleService->CreateBundle(DOWNLOAD_MANAGER_BUNDLE,

View File

@ -8087,7 +8087,7 @@ nsNavHistory::GetBundle()
{
if (!mBundle) {
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
mozilla::services::GetStringBundleService();
NS_ENSURE_TRUE(bundleService, nsnull);
nsresult rv = bundleService->CreateBundle(
"chrome://places/locale/places.properties",
@ -8102,7 +8102,7 @@ nsNavHistory::GetDateFormatBundle()
{
if (!mDateFormatBundle) {
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
mozilla::services::GetStringBundleService();
NS_ENSURE_TRUE(bundleService, nsnull);
nsresult rv = bundleService->CreateBundle(
"chrome://global/locale/dateFormat.properties",

View File

@ -1244,7 +1244,8 @@ ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native)
NS_ENSURE_SUCCESS(rv, rv);
// Inform the chrome registry about OS accessibility
nsCOMPtr<nsIToolkitChromeRegistry> cr (do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
nsCOMPtr<nsIToolkitChromeRegistry> cr =
mozilla::services::GetToolkitChromeRegistryService();
if (cr)
cr->CheckForOSAccessibility();
@ -1803,8 +1804,8 @@ ProfileLockedDialog(nsILocalFile* aProfileDir, nsILocalFile* aProfileLocalDir,
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
{ //extra scoping is needed so we release these components before xpcom shutdown
nsCOMPtr<nsIStringBundleService> sbs
(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> sb;
@ -1877,8 +1878,8 @@ ProfileMissingDialog(nsINativeAppSupport* aNative)
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
{ //extra scoping is needed so we release these components before xpcom shutdown
nsCOMPtr<nsIStringBundleService> sbs
(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> sb;
@ -3076,8 +3077,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_ENSURE_SUCCESS(rv, 1);
{
nsCOMPtr<nsIChromeRegistry> chromeReg
(do_GetService("@mozilla.org/chrome/chrome-registry;1"));
nsCOMPtr<nsIChromeRegistry> chromeReg =
mozilla::services::GetChromeRegistryService();
NS_ENSURE_TRUE(chromeReg, 1);
chromeReg->CheckForNewChrome();

View File

@ -1155,13 +1155,16 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt,
info->mMaxProgress = LL_ZERO;
}
}
nsresult rv;
nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
if (!sbs)
return NS_ERROR_FAILURE;
nsXPIDLString msg;
rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg));
if (NS_FAILED(rv)) return rv;
nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg,
getter_Copies(msg));
if (NS_FAILED(rv))
return rv;
// Keep around the message. In case a request finishes, we need to make sure
// to send the status message of another request to our user to that we

View File

@ -1738,11 +1738,12 @@ void nsExternalAppHandler::SendStatusChange(ErrorType type, nsresult rv, nsIRequ
(" path='%s'\n", NS_ConvertUTF16toUTF8(path).get()));
// Get properties file bundle and extract status string.
nsCOMPtr<nsIStringBundleService> s = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
if (s)
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (stringService)
{
nsCOMPtr<nsIStringBundle> bundle;
if (NS_SUCCEEDED(s->CreateBundle("chrome://global/locale/nsWebBrowserPersist.properties", getter_AddRefs(bundle))))
if (NS_SUCCEEDED(stringService->CreateBundle("chrome://global/locale/nsWebBrowserPersist.properties", getter_AddRefs(bundle))))
{
nsXPIDLString msgText;
const PRUnichar *strings[] = { path.get() };

View File

@ -62,6 +62,7 @@
#include "nsIRwsService.h"
#include "nsIStringBundle.h"
#include "nsLocalHandlerApp.h"
#include "mozilla/Services.h"
#include <stdlib.h> // for system()
//------------------------------------------------------------------------
@ -1363,14 +1364,13 @@ nsOSHelperAppService::GetFromType(const nsCString& aMIMEType) {
static nsresult
GetNLSString(const PRUnichar *aKey, nsAString& result)
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleSvc =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetStringBundleService();
if (!bundleSvc)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleSvc->CreateBundle(
nsresult rv = bundleSvc->CreateBundle(
"chrome://mozapps/locale/downloads/unknownContentType.properties",
getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -765,8 +765,8 @@ static void AssignNLSString(const PRUnichar *aKey, nsAString& result)
do {
nsCOMPtr<nsIStringBundleService> bundleSvc =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv))
mozilla::services::GetStringBundleService();
if (!bundleSvc)
break;
nsCOMPtr<nsIStringBundle> bundle;

View File

@ -79,6 +79,7 @@
#include "nsIMenuRollup.h"
#include "nsWidgetsCID.h"
#include "nsQtKeyUtils.h"
#include "mozilla/Services.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
@ -1651,8 +1652,8 @@ nsWindow::OnDragEnter(QGraphicsSceneDragDropEvent *aDragEvent)
static void
GetBrandName(nsXPIDLString& brandName)
{
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
nsCOMPtr<nsIStringBundle> bundle;
if (bundleService)

View File

@ -999,13 +999,14 @@ CreateFilenameFromTextW(nsString & aText, const wchar_t * aExtension,
static PRBool
GetLocalizedString(const PRUnichar * aName, nsXPIDLString & aString)
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv))
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (!stringService)
return PR_FALSE;
nsCOMPtr<nsIStringBundle> stringBundle;
rv = stringService->CreateBundle(PAGEINFO_PROPERTIES, getter_AddRefs(stringBundle));
nsresult rv = stringService->CreateBundle(PAGEINFO_PROPERTIES,
getter_AddRefs(stringBundle));
if (NS_FAILED(rv))
return PR_FALSE;

View File

@ -62,6 +62,7 @@
#include "nsIFileStreams.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindow.h"
#include "mozilla/Services.h"
// For NS_CopyNativeToUnicode
#include "nsNativeCharsetUtils.h"
@ -289,8 +290,10 @@ GetFileNameForPrintSettings(nsIPrintSettings* aPS)
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
if (!bundleService)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -54,6 +54,7 @@
#include "nsCOMArray.h"
#include "nsILocalFile.h"
#include "nsEnumeratorUtils.h"
#include "mozilla/Services.h"
#include "nsBaseFilePicker.h"
@ -124,13 +125,15 @@ NS_IMETHODIMP nsBaseFilePicker::Init(nsIDOMWindow *aParent,
NS_IMETHODIMP
nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask)
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (!stringService)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> titleBundle, filterBundle;
rv = stringService->CreateBundle(FILEPICKER_TITLES, getter_AddRefs(titleBundle));
nsresult rv = stringService->CreateBundle(FILEPICKER_TITLES,
getter_AddRefs(titleBundle));
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;

View File

@ -1,2 +1,7 @@
MOZ_SERVICE(ChromeRegistryService, nsIChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
MOZ_SERVICE(ToolkitChromeRegistryService, nsIToolkitChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
MOZ_SERVICE(XULChromeRegistryService, nsIXULChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
MOZ_SERVICE(XULOverlayProviderService, nsIXULOverlayProvider, "@mozilla.org/chrome/chrome-registry;1")
MOZ_SERVICE(IOService, nsIIOService, "@mozilla.org/network/io-service;1")
MOZ_SERVICE(ObserverService, nsIObserverService, "@mozilla.org/observer-service;1")
MOZ_SERVICE(StringBundleService, nsIStringBundleService, "@mozilla.org/intl/stringbundle;1")

View File

@ -45,6 +45,9 @@
#include "nsNetCID.h"
#include "nsObserverService.h"
#include "nsXPCOMPrivate.h"
#include "nsIStringBundle.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsIXULOverlayProvider.h"
using namespace mozilla::services;

View File

@ -376,7 +376,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
PRBool center = aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN;
nsCOMPtr<nsIXULChromeRegistry> reg =
do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
mozilla::services::GetXULChromeRegistryService();
if (reg) {
nsCAutoString package;
package.AssignLiteral("global");