diff --git a/extensions/wallet/editor/nsWalletEditor.cpp b/extensions/wallet/editor/nsWalletEditor.cpp index 602013c7e4ad..a54cf6468526 100644 --- a/extensions/wallet/editor/nsWalletEditor.cpp +++ b/extensions/wallet/editor/nsWalletEditor.cpp @@ -83,18 +83,13 @@ WalletEditorImpl::GetValue(char** aValue) if (!aValue) { return NS_ERROR_NULL_POINTER; } - - nsIWalletService *walletservice; nsresult res; - res = nsServiceManager::GetService(kWalletServiceCID, - kIWalletServiceIID, - (nsISupports **)&walletservice); - if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) { - nsAutoString walletList; - res = walletservice->WALLET_PreEdit(walletList); - if (NS_SUCCEEDED(res)) { - *aValue = walletList.ToNewCString(); - } + NS_WITH_SERVICE(nsIWalletService, walletservice, kWalletServiceCID, &res); + if (NS_FAILED(res)) return res; + nsAutoString walletList; + res = walletservice->WALLET_PreEdit(walletList); + if (NS_SUCCEEDED(res)) { + *aValue = walletList.ToNewCString(); } return res; } @@ -145,14 +140,10 @@ WalletEditorImpl::SetValue(const char* aValue, nsIDOMWindow* win) if (! aValue) { return NS_ERROR_NULL_POINTER; } - nsIWalletService *walletservice; nsresult res; - res = nsServiceManager::GetService(kWalletServiceCID, - kIWalletServiceIID, - (nsISupports **)&walletservice); - if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) { - nsAutoString walletList = aValue; - res = walletservice->WALLET_PostEdit(walletList); - } + NS_WITH_SERVICE(nsIWalletService, walletservice, kWalletServiceCID, &res); + if (NS_FAILED(res)) return res; + nsAutoString walletList = aValue; + res = walletservice->WALLET_PostEdit(walletList); return res; } diff --git a/extensions/wallet/walletpreview/nsWalletPreview.cpp b/extensions/wallet/walletpreview/nsWalletPreview.cpp index 8157c7e66e24..c79ba3074ef0 100644 --- a/extensions/wallet/walletpreview/nsWalletPreview.cpp +++ b/extensions/wallet/walletpreview/nsWalletPreview.cpp @@ -83,18 +83,13 @@ WalletPreviewImpl::GetPrefillValue(char** aValue) if (!aValue) { return NS_ERROR_NULL_POINTER; } - - nsIWalletService *walletservice; nsresult res; - res = nsServiceManager::GetService(kWalletServiceCID, - kIWalletServiceIID, - (nsISupports **)&walletservice); - if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) { - nsAutoString walletList; - res = walletservice->WALLET_GetPrefillListForViewer(walletList); - if (NS_SUCCEEDED(res)) { - *aValue = walletList.ToNewCString(); - } + NS_WITH_SERVICE(nsIWalletService, walletservice, kWalletServiceCID, &res); + if (NS_FAILED(res)) return res; + nsAutoString walletList; + res = walletservice->WALLET_GetPrefillListForViewer(walletList); + if (NS_SUCCEEDED(res)) { + *aValue = walletList.ToNewCString(); } return res; } @@ -145,14 +140,10 @@ WalletPreviewImpl::SetValue(const char* aValue, nsIDOMWindow* win) if (! aValue) { return NS_ERROR_NULL_POINTER; } - nsIWalletService *walletservice; nsresult res; - res = nsServiceManager::GetService(kWalletServiceCID, - kIWalletServiceIID, - (nsISupports **)&walletservice); - if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) { - nsAutoString walletList = aValue; - res = walletservice->WALLET_PrefillReturn(walletList); - } + NS_WITH_SERVICE(nsIWalletService, walletservice, kWalletServiceCID, &res); + if (NS_FAILED(res)) return res; + nsAutoString walletList = aValue; + res = walletservice->WALLET_PrefillReturn(walletList); return res; }