Bug 590390 - deCOM nsICharsetAlias. r=smontagu
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 05 Mar 2012 12:57:51 +0900
changeset 88249 2893c5e0be5de24947b35923078ee2ba3e6fbf3e
parent 88248 4dd463134071c9de38fc4f5b32e6a4d267ae4f1d
child 88250 e7c45d258c4e7c511d97c87d8dc8bcc0fff124e4
push idunknown
push userunknown
push dateunknown
reviewerssmontagu
bugs590390
milestone13.0a1
Bug 590390 - deCOM nsICharsetAlias. r=smontagu
content/base/src/nsCrossSiteListenerProxy.cpp
content/base/src/nsDOMFile.cpp
content/base/src/nsDOMFileReader.cpp
content/base/src/nsDocument.cpp
content/base/src/nsXMLHttpRequest.cpp
content/html/content/src/nsFormSubmission.cpp
content/html/document/src/nsHTMLDocument.cpp
content/xml/document/src/nsXMLDocument.cpp
content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
content/xslt/src/xslt/txMozillaTextOutput.cpp
content/xslt/src/xslt/txMozillaXMLOutput.cpp
dom/workers/FileReaderSyncPrivate.cpp
extensions/spellcheck/src/mozEnglishWordUtils.cpp
extensions/spellcheck/src/mozPersonalDictionary.cpp
extensions/universalchardet/src/xpcom/nsUniversalCharDetModule.cpp
intl/build/nsI18nModule.cpp
intl/chardet/src/nsCharDetConstructors.h
intl/locale/public/Makefile.in
intl/locale/public/nsCharsetAlias.h
intl/locale/public/nsICharsetAlias.h
intl/locale/src/Makefile.in
intl/locale/src/nsCharsetAlias.cpp
intl/locale/src/nsCharsetAlias.h
intl/locale/src/nsCharsetAliasImp.cpp
intl/locale/src/nsLocaleConstructors.h
intl/uconv/src/nsCharsetConverterManager.cpp
intl/uconv/tests/nsconv.cpp
layout/style/Loader.cpp
parser/html/nsHtml5MetaScannerCppSupplement.h
parser/html/nsHtml5Parser.cpp
parser/html/nsHtml5StreamParser.cpp
parser/html/nsHtml5StreamParser.h
parser/htmlparser/src/nsParser.cpp
parser/htmlparser/src/nsParser.h
parser/htmlparser/src/nsScanner.cpp
parser/xml/src/nsSAXXMLReader.cpp
--- a/content/base/src/nsCrossSiteListenerProxy.cpp
+++ b/content/base/src/nsCrossSiteListenerProxy.cpp
@@ -39,17 +39,16 @@
 #include "nsIChannel.h"
 #include "nsIHttpChannel.h"
 #include "nsDOMError.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNetUtil.h"
 #include "nsIParser.h"
 #include "nsParserCIID.h"
-#include "nsICharsetAlias.h"
 #include "nsMimeTypes.h"
 #include "nsIStreamConverterService.h"
 #include "nsStringStream.h"
 #include "nsGkAtoms.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsCharSeparatedTokenizer.h"
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -38,17 +38,16 @@
 
 #include "nsDOMFile.h"
 
 #include "nsCExternalHandlerService.h"
 #include "nsContentCID.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
 #include "nsDOMError.h"
-#include "nsICharsetAlias.h"
 #include "nsICharsetDetector.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIConverterInputStream.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIFileStreams.h"
 #include "nsIInputStream.h"
 #include "nsIIPCSerializable.h"
--- a/content/base/src/nsDOMFileReader.cpp
+++ b/content/base/src/nsDOMFileReader.cpp
@@ -37,17 +37,17 @@
 
 #include "nsDOMFileReader.h"
 
 #include "nsContentCID.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
 #include "nsDOMFile.h"
 #include "nsDOMError.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsICharsetDetector.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIConverterInputStream.h"
 #include "nsIFile.h"
 #include "nsIFileStreams.h"
 #include "nsIInputStream.h"
 #include "nsIMIMEService.h"
 #include "nsIPlatformCharset.h"
@@ -490,20 +490,17 @@ nsDOMFileReader::GetAsText(const nsACStr
   if (!aCharset.IsEmpty()) {
     charsetGuess = aCharset;
   } else {
     rv = GuessCharset(aFileData, aDataLen, charsetGuess);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCAutoString charset;
-  nsCOMPtr<nsICharsetAlias> alias = do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = alias->GetPreferred(charsetGuess, charset);
+  rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = ConvertStream(aFileData, aDataLen, charset.get(), aResult);
 
   return NS_OK;
 }
 
 nsresult
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -142,17 +142,17 @@
 #include "nsIScriptContext.h"
 #include "nsBindingManager.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIRequest.h"
 #include "nsILink.h"
 #include "nsBlobProtocolHandler.h"
 
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsIParser.h"
 #include "nsIContentSink.h"
 
 #include "nsDateTimeFormatCID.h"
 #include "nsIDateTimeFormat.h"
 #include "nsEventDispatcher.h"
 #include "nsMutationEvent.h"
 #include "nsIDOMXPathEvaluator.h"
@@ -3007,23 +3007,20 @@ nsDocument::GetBaseTarget(nsAString &aBa
 
 void
 nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
 {
   if (!mCharacterSet.Equals(aCharSetID)) {
     mCharacterSet = aCharSetID;
 
 #ifdef DEBUG
-    nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
-    if (calias) {
-      nsCAutoString canonicalName;
-      calias->GetPreferred(aCharSetID, canonicalName);
-      NS_ASSERTION(canonicalName.Equals(aCharSetID),
-                   "charset name must be canonical");
-    }
+    nsCAutoString canonicalName;
+    nsCharsetAlias::GetPreferred(aCharSetID, canonicalName);
+    NS_ASSERTION(canonicalName.Equals(aCharSetID),
+                 "charset name must be canonical");
 #endif
 
     PRInt32 n = mCharSetObservers.Length();
 
     for (PRInt32 i = 0; i < n; i++) {
       nsIObserver* observer = mCharSetObservers.ElementAt(i);
 
       observer->Observe(static_cast<nsIDocument *>(this), "charset",
@@ -3167,26 +3164,20 @@ nsDocument::TryChannelCharset(nsIChannel
   if(kCharsetFromChannel <= aCharsetSource) {
     return true;
   }
 
   if (aChannel) {
     nsCAutoString charsetVal;
     nsresult rv = aChannel->GetContentCharset(charsetVal);
     if (NS_SUCCEEDED(rv)) {
-      nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
-      if (calias) {
-        nsCAutoString preferred;
-        rv = calias->GetPreferred(charsetVal,
-                                  preferred);
-        if(NS_SUCCEEDED(rv)) {
-          aCharset = preferred;
-          aCharsetSource = kCharsetFromChannel;
-          return true;
-        }
+      rv = nsCharsetAlias::GetPreferred(charsetVal, aCharset);
+      if(NS_SUCCEEDED(rv)) {
+        aCharsetSource = kCharsetFromChannel;
+        return true;
       }
     }
   }
   return false;
 }
 
 nsresult
 nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager,
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -56,17 +56,17 @@
 #include "nsISupportsPrimitives.h"
 #include "nsGUIEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "prprf.h"
 #include "nsIDOMEventListener.h"
 #include "nsIJSContextStack.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsWeakPtr.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMWindow.h"
 #include "nsIMIMEService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIVariant.h"
 #include "nsVariant.h"
@@ -807,21 +807,17 @@ nsXMLHttpRequest::DetectCharset()
   if (!channel) {
     channel = mChannel;
   }
 
   nsCAutoString charsetVal;
   nsresult rv = channel ? channel->GetContentCharset(charsetVal) :
                 NS_ERROR_FAILURE;
   if (NS_SUCCEEDED(rv)) {
-    nsCOMPtr<nsICharsetAlias> calias =
-      do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
-    if (NS_SUCCEEDED(rv) && calias) {
-      rv = calias->GetPreferred(charsetVal, mResponseCharset);
-    }
+    rv = nsCharsetAlias::GetPreferred(charsetVal, mResponseCharset);
   }
 
   if (NS_FAILED(rv) || mResponseCharset.IsEmpty()) {
     // MS documentation states UTF-8 is default for responseText
     mResponseCharset.AssignLiteral("UTF-8");
   }
 
   if (mResponseType == XML_HTTP_RESPONSE_TYPE_JSON &&
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -55,17 +55,17 @@
 #include "nsIDOMFile.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsStringStream.h"
 #include "nsIURI.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsLinebreakConverter.h"
 #include "nsICharsetConverterManager.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsEscape.h"
 #include "nsUnicharUtils.h"
 #include "nsIMultiplexInputStream.h"
 #include "nsIMIMEInputStream.h"
 #include "nsIMIMEService.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
@@ -777,46 +777,38 @@ nsEncodingFormSubmission::EncodeVal(cons
 // --------------------------------------------------------------------------
 
 static void
 GetSubmitCharset(nsGenericHTMLElement* aForm,
                  nsACString& oCharset)
 {
   oCharset.AssignLiteral("UTF-8"); // default to utf-8
 
-  nsresult rv = NS_OK;
   nsAutoString acceptCharsetValue;
   aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset,
                  acceptCharsetValue);
 
   PRInt32 charsetLen = acceptCharsetValue.Length();
   if (charsetLen > 0) {
     PRInt32 offset=0;
     PRInt32 spPos=0;
     // get charset from charsets one by one
-    nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv));
-    if (NS_FAILED(rv)) {
-      return;
-    }
-    if (calias) {
-      do {
-        spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
-        PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
-        if (cnt > 0) {
-          nsAutoString uCharset;
-          acceptCharsetValue.Mid(uCharset, offset, cnt);
+    do {
+      spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
+      PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
+      if (cnt > 0) {
+        nsAutoString uCharset;
+        acceptCharsetValue.Mid(uCharset, offset, cnt);
 
-          if (NS_SUCCEEDED(calias->
-                           GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
-                                        oCharset)))
-            return;
-        }
-        offset = spPos + 1;
-      } while (spPos != -1);
-    }
+        if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
+                                                      oCharset)))
+          return;
+      }
+      offset = spPos + 1;
+    } while (spPos != -1);
   }
   // if there are no accept-charset or all the charset are not supported
   // Get the charset from document
   nsIDocument* doc = aForm->GetDocument();
   if (doc) {
     oCharset = doc->GetDocumentCharacterSet();
   }
 }
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -35,18 +35,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
-#include "nsICharsetAlias.h"
-
 #include "nsCOMPtr.h"
 #include "nsXPIDLString.h"
 #include "nsPrintfCString.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsHTMLDocument.h"
 #include "nsIHTMLContentSink.h"
 #include "nsIXMLContentSink.h"
@@ -97,17 +95,16 @@
 #include "nsGenericHTMLElement.h"
 #include "mozilla/css/Loader.h"
 #include "nsIHttpChannel.h"
 #include "nsIFile.h"
 #include "nsEventListenerManager.h"
 #include "nsFrameSelection.h"
 #include "nsISelectionPrivate.h"//for toStringwithformat code
 
-#include "nsICharsetAlias.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "nsIDocumentEncoder.h" //for outputting selection
 #include "nsICachingChannel.h"
 #include "nsIJSContextStack.h"
 #include "nsIContentViewer.h"
 #include "nsIWyciwygChannel.h"
 #include "nsIScriptElement.h"
--- a/content/xml/document/src/nsXMLDocument.cpp
+++ b/content/xml/document/src/nsXMLDocument.cpp
@@ -54,18 +54,16 @@
 #include "nsIDOMWindow.h"
 #include "nsIDOMDocumentType.h"
 #include "nsINameSpaceManager.h"
 #include "nsCOMPtr.h"
 #include "nsXPIDLString.h"
 #include "nsIHttpChannel.h"
 #include "nsIURI.h"
 #include "nsIServiceManager.h"
-#include "nsICharsetAlias.h"
-#include "nsICharsetAlias.h"
 #include "nsNetUtil.h"
 #include "nsDOMError.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIPrincipal.h"
 #include "nsLayoutCID.h"
 #include "nsDOMAttribute.h"
 #include "nsGUIEvent.h"
 #include "nsCExternalHandlerService.h"
--- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
@@ -34,17 +34,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCOMArray.h"
 #include "nsIAuthPrompt.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsIExpatSink.h"
 #include "nsIChannelEventSink.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsILoadGroup.h"
 #include "nsINameSpaceManager.h"
@@ -277,52 +277,47 @@ txStylesheetSink::OnDataAvailable(nsIReq
 
     return mListener->OnDataAvailable(aRequest, aContext, aInputStream,
                                       aOffset, aCount);
 }
 
 NS_IMETHODIMP
 txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
 {
-    nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8"));
     PRInt32 charsetSource = kCharsetFromDocTypeDefault;
 
     nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
 
     // check channel's charset...
     nsCAutoString charsetVal;
-    nsresult rv = channel->GetContentCharset(charsetVal);
-    if (NS_SUCCEEDED(rv)) {
-        nsCOMPtr<nsICharsetAlias> calias =
-            do_GetService(NS_CHARSETALIAS_CONTRACTID);
+    nsCAutoString charset;
+    if (NS_SUCCEEDED(channel->GetContentCharset(charsetVal))) {
+        if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charsetVal, charset))) {
+            charsetSource = kCharsetFromChannel;
+        }
+    }
 
-        if (calias) {
-            nsCAutoString preferred;
-            rv = calias->GetPreferred(charsetVal,
-                                      preferred);
-            if (NS_SUCCEEDED(rv)) {            
-                charset = preferred;
-                charsetSource = kCharsetFromChannel;
-             }
-        }
+    if (charset.IsEmpty()) {
+      charset.AssignLiteral("UTF-8");
     }
 
     nsCOMPtr<nsIParser> parser = do_QueryInterface(aContext);
     parser->SetDocumentCharset(charset, charsetSource);
 
     nsCAutoString contentType;
     channel->GetContentType(contentType);
 
     // Time to sniff! Note: this should go away once file channels do
     // sniffing themselves.
     nsCOMPtr<nsIURI> uri;
     channel->GetURI(getter_AddRefs(uri));
     bool sniff;
     if (NS_SUCCEEDED(uri->SchemeIs("file", &sniff)) && sniff &&
         contentType.Equals(UNKNOWN_CONTENT_TYPE)) {
+        nsresult rv;
         nsCOMPtr<nsIStreamConverterService> serv =
             do_GetService("@mozilla.org/streamConverters;1", &rv);
         if (NS_SUCCEEDED(rv)) {
             nsCOMPtr<nsIStreamListener> converter;
             rv = serv->AsyncConvertData(UNKNOWN_CONTENT_TYPE,
                                         "*/*",
                                         mListener,
                                         aContext,
--- a/content/xslt/src/xslt/txMozillaTextOutput.cpp
+++ b/content/xslt/src/xslt/txMozillaTextOutput.cpp
@@ -40,17 +40,17 @@
 #include "nsContentCID.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentFragment.h"
 #include "nsIDocumentTransformer.h"
 #include "nsNetUtil.h"
 #include "nsIParser.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsIPrincipal.h"
 #include "txURIUtils.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 #include "nsGkAtoms.h"
 
 using namespace mozilla::dom;
 
@@ -179,21 +179,19 @@ txMozillaTextOutput::createResultDocumen
 
     // Reset and set up document
     URIUtils::ResetWithSource(mDocument, aSourceDocument);
 
     // Set the charset
     if (!mOutputFormat.mEncoding.IsEmpty()) {
         NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
         nsCAutoString canonicalCharset;
-        nsCOMPtr<nsICharsetAlias> calias =
-            do_GetService("@mozilla.org/intl/charsetalias;1");
 
-        if (calias &&
-            NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
+        if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charset,
+                                                      canonicalCharset))) {
             mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
             mDocument->SetDocumentCharacterSet(canonicalCharset);
         }
     }
 
     // Notify the contentsink that the document is created
     nsCOMPtr<nsITransformObserver> observer = do_QueryReferent(mObserver);
     if (observer) {
--- a/content/xslt/src/xslt/txMozillaXMLOutput.cpp
+++ b/content/xslt/src/xslt/txMozillaXMLOutput.cpp
@@ -59,17 +59,17 @@
 #include "nsCSSStyleSheet.h"
 #include "txStringUtils.h"
 #include "txURIUtils.h"
 #include "nsIHTMLDocument.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIDocumentTransformer.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/Element.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsIHTMLContentSink.h"
 #include "nsContentUtils.h"
 #include "txXMLUtils.h"
 #include "nsContentSink.h"
 #include "nsINode.h"
 #include "nsContentCreatorFunctions.h"
 #include "txError.h"
 
@@ -852,21 +852,17 @@ txMozillaXMLOutput::createResultDocument
 
     // Reset and set up the document
     URIUtils::ResetWithSource(mDocument, aSourceDocument);
 
     // Set the charset
     if (!mOutputFormat.mEncoding.IsEmpty()) {
         NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
         nsCAutoString canonicalCharset;
-        nsCOMPtr<nsICharsetAlias> calias =
-            do_GetService("@mozilla.org/intl/charsetalias;1");
-
-        if (calias &&
-            NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
+        if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charset, canonicalCharset))) {
             mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
             mDocument->SetDocumentCharacterSet(canonicalCharset);
         }
     }
 
     // Set the mime-type
     if (!mOutputFormat.mMediaType.IsEmpty()) {
         mDocument->SetContentType(mOutputFormat.mMediaType);
--- a/dom/workers/FileReaderSyncPrivate.cpp
+++ b/dom/workers/FileReaderSyncPrivate.cpp
@@ -40,17 +40,17 @@
 #include "FileReaderSyncPrivate.h"
 
 #include "nsCExternalHandlerService.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsDOMClassInfoID.h"
 #include "nsDOMError.h"
 #include "nsIDOMFile.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsICharsetDetector.h"
 #include "nsIConverterInputStream.h"
 #include "nsIInputStream.h"
 #include "nsIPlatformCharset.h"
 #include "nsISeekableStream.h"
 #include "nsISupportsImpl.h"
 #include "nsISupportsImpl.h"
 #include "nsNetUtil.h"
@@ -130,22 +130,18 @@ FileReaderSyncPrivate::ReadAsText(nsIDOM
 
     // Seek to 0 because guessing the charset advances the stream.
     rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
     NS_ENSURE_SUCCESS(rv, rv);
   } else {
     CopyUTF16toUTF8(aEncoding, charsetGuess);
   }
 
-  nsCOMPtr<nsICharsetAlias> alias =
-    do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   nsCString charset;
-  rv = alias->GetPreferred(charsetGuess, charset);
+  rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return ConvertStream(stream, charset.get(), aResult);
 }
 
 nsresult
 FileReaderSyncPrivate::ReadAsDataURL(nsIDOMBlob* aBlob, nsAString& aResult)
 {
--- a/extensions/spellcheck/src/mozEnglishWordUtils.cpp
+++ b/extensions/spellcheck/src/mozEnglishWordUtils.cpp
@@ -31,17 +31,16 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozEnglishWordUtils.h"
-#include "nsICharsetAlias.h"
 #include "nsReadableUtils.h"
 #include "nsIServiceManager.h"
 #include "nsUnicharUtils.h"
 #include "nsUnicharUtilCIID.h"
 #include "nsUnicodeProperties.h"
 #include "nsCRT.h"
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(mozEnglishWordUtils)
--- a/extensions/spellcheck/src/mozPersonalDictionary.cpp
+++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp
@@ -36,17 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozPersonalDictionary.h"
 #include "nsIUnicharInputStream.h"
 #include "nsReadableUtils.h"
 #include "nsIFile.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsICharsetConverterManager.h"
-#include "nsICharsetAlias.h"
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIWeakReference.h"
 #include "nsCRT.h"
 #include "nsNetUtil.h"
 #include "nsStringEnumerator.h"
 #include "nsUnicharInputStream.h"
--- a/extensions/universalchardet/src/xpcom/nsUniversalCharDetModule.cpp
+++ b/extensions/universalchardet/src/xpcom/nsUniversalCharDetModule.cpp
@@ -32,17 +32,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/ModuleUtils.h"
 
-#include "nsICharsetAlias.h"
 #include "nsCOMPtr.h"
 
 #include "nspr.h"
 #include "nsString.h"
 #include "pratom.h"
 #include "nsUniversalCharDetDll.h"
 #include "nsISupports.h"
 #include "nsICategoryManager.h"
--- a/intl/build/nsI18nModule.cpp
+++ b/intl/build/nsI18nModule.cpp
@@ -84,17 +84,16 @@ NS_DEFINE_NAMED_CID(NS_ENTITYCONVERTER_C
 NS_DEFINE_NAMED_CID(NS_SAVEASCHARSET_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODE_NORMALIZER_CID);
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLETEXTOVERRIDE_CID);
 NS_DEFINE_NAMED_CID(NS_LOCALESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
 NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_CHARSETALIAS_CID);
 NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
 #ifdef XP_WIN
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
 NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
 #endif
 #ifdef USE_UNIX_LOCALE
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
 NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
@@ -119,17 +118,16 @@ static const mozilla::Module::CIDEntry k
     { &kNS_SAVEASCHARSET_CID, false, NULL, nsSaveAsCharsetConstructor },
     { &kNS_UNICODE_NORMALIZER_CID, false, NULL, nsUnicodeNormalizerConstructor },
     { &kNS_STRINGBUNDLESERVICE_CID, false, NULL, nsStringBundleServiceConstructor },
     { &kNS_STRINGBUNDLETEXTOVERRIDE_CID, false, NULL, nsStringBundleTextOverrideConstructor },
     { &kNS_LOCALESERVICE_CID, false, NULL, CreateLocaleService },
     { &kNS_COLLATIONFACTORY_CID, false, NULL, nsCollationFactoryConstructor },
     { &kNS_SCRIPTABLEDATEFORMAT_CID, false, NULL, NS_NewScriptableDateFormat },
     { &kNS_LANGUAGEATOMSERVICE_CID, false, NULL, nsLanguageAtomServiceConstructor },
-    { &kNS_CHARSETALIAS_CID, false, NULL, nsCharsetAlias2Constructor },
     { &kNS_PLATFORMCHARSET_CID, false, NULL, nsPlatformCharsetConstructor },
 #ifdef XP_WIN
     { &kNS_COLLATION_CID, false, NULL, nsCollationWinConstructor },
     { &kNS_DATETIMEFORMAT_CID, false, NULL, nsDateTimeFormatWinConstructor },
 #endif
 #ifdef USE_UNIX_LOCALE
     { &kNS_COLLATION_CID, false, NULL, nsCollationUnixConstructor },
     { &kNS_DATETIMEFORMAT_CID, false, NULL, nsDateTimeFormatUnixConstructor },
@@ -156,17 +154,16 @@ static const mozilla::Module::ContractID
     { NS_SAVEASCHARSET_CONTRACTID, &kNS_SAVEASCHARSET_CID },
     { NS_UNICODE_NORMALIZER_CONTRACTID, &kNS_UNICODE_NORMALIZER_CID },
     { NS_STRINGBUNDLE_CONTRACTID, &kNS_STRINGBUNDLESERVICE_CID },
     { NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID, &kNS_STRINGBUNDLETEXTOVERRIDE_CID },
     { NS_LOCALESERVICE_CONTRACTID, &kNS_LOCALESERVICE_CID },
     { NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
     { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
     { NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
-    { NS_CHARSETALIAS_CONTRACTID, &kNS_CHARSETALIAS_CID },
     { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
 #ifdef XP_WIN
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
     { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
 #endif
 #ifdef USE_UNIX_LOCALE
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
     { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
--- a/intl/chardet/src/nsCharDetConstructors.h
+++ b/intl/chardet/src/nsCharDetConstructors.h
@@ -42,17 +42,16 @@
  */
 
 #ifndef nsCharDetConstructors_h__
 #define nsCharDetConstructors_h__
 
 // chardet
 #include "nsISupports.h"
 #include "nsICharsetDetector.h"
-#include "nsICharsetAlias.h"
 #include "nsICharsetDetectionObserver.h"
 #include "nsIStringCharsetDetector.h"
 #include "nsCyrillicDetector.h"
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUProbDetector)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKProbDetector)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUStringProbDetector)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKStringProbDetector)
--- a/intl/locale/public/Makefile.in
+++ b/intl/locale/public/Makefile.in
@@ -47,15 +47,15 @@ MODULE		= locale
 EXPORTS		= \
 		nsCollationCID.h \
 		nsDateTimeFormatCID.h \
 		nsIDateTimeFormat.h \
 		nsILanguageAtomService.h \
 		nsPosixLocale.h \
 		nsIOS2Locale.h \
 		nsWin32Locale.h \
-		nsICharsetAlias.h \
+		nsCharsetAlias.h \
 		nsIPlatformCharset.h \
 		nsLocaleCID.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
rename from intl/locale/public/nsICharsetAlias.h
rename to intl/locale/public/nsCharsetAlias.h
--- a/intl/locale/public/nsICharsetAlias.h
+++ b/intl/locale/public/nsCharsetAlias.h
@@ -30,40 +30,22 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef nsICharsetAlias_h___
-#define nsICharsetAlias_h___
+#ifndef nsCharsetAlias_h___
+#define nsCharsetAlias_h___
 
 #include "nscore.h"
 #include "nsStringGlue.h"
-#include "nsISupports.h"
 
-/* 0b4028d6-7473-4958-9b3c-4dee46bf68cb */
-#define NS_ICHARSETALIAS_IID \
-{   0x0b4028d6, \
-    0x7473, \
-    0x4958, \
-    {0x9b, 0x3c, 0x4d, 0xee, 0x46, 0xbf, 0x68, 0xcb} }
-
-// {98D41C21-CCF3-11d2-B3B1-00805F8A6670}
-#define NS_CHARSETALIAS_CID \
-{ 0x98d41c21, 0xccf3, 0x11d2, { 0xb3, 0xb1, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 }}
-
-#define NS_CHARSETALIAS_CONTRACTID "@mozilla.org/intl/charsetalias;1"
-
-class nsICharsetAlias : public nsISupports
+class nsCharsetAlias
 {
 public:
-   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICHARSETALIAS_IID)
-
-   NS_IMETHOD GetPreferred(const nsACString& aAlias, nsACString& aResult) = 0;
-   NS_IMETHOD Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* aResult) = 0;
+   static nsresult GetPreferred(const nsACString& aAlias, nsACString& aResult);
+   static nsresult Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* aResult);
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(nsICharsetAlias, NS_ICHARSETALIAS_IID)
-
-#endif /* nsICharsetAlias_h___ */
+#endif /* nsCharsetAlias_h___ */
--- a/intl/locale/src/Makefile.in
+++ b/intl/locale/src/Makefile.in
@@ -62,17 +62,17 @@ OS_INCLUDES	+= $(MOZ_QT_CFLAGS)
 endif
 
 CPPSRCS		= \
 		nsCollation.cpp \
 		nsScriptableDateFormat.cpp \
 		nsLanguageAtomService.cpp \
 		nsLocale.cpp \
 		nsLocaleService.cpp \
-		nsCharsetAliasImp.cpp \
+		nsCharsetAlias.cpp \
 		nsUConvPropertySearch.cpp \
 		$(NULL)
 
 EXPORTS		= \
 		nsCollation.h \
 		$(NULL)
 
 EXPORT_RESOURCE = \
@@ -84,17 +84,17 @@ EXTRA_JS_MODULES = \
   PluralForm.jsm \
   $(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
-nsCharsetAliasImp.$(OBJ_SUFFIX): charsetalias.properties.h
+nsCharsetAlias.$(OBJ_SUFFIX): charsetalias.properties.h
 
 charsetalias.properties.h: props2arrays.py charsetalias.properties
 	$(PYTHON) $^ $@
 
 GARBAGE += \
 	charsetalias.properties.h \
 	$(NULL)
 
rename from intl/locale/src/nsCharsetAliasImp.cpp
rename to intl/locale/src/nsCharsetAlias.cpp
--- a/intl/locale/src/nsCharsetAliasImp.cpp
+++ b/intl/locale/src/nsCharsetAlias.cpp
@@ -32,84 +32,72 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "pratom.h"
 
 // for NS_IMPL_IDS only
 #include "nsIPlatformCharset.h"
 
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsUConvPropertySearch.h"
-#include "nsCharsetAlias.h"
 
 using namespace mozilla;
 
-//--------------------------------------------------------------
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsCharsetAlias2, nsICharsetAlias)
-
-//--------------------------------------------------------------
-nsCharsetAlias2::nsCharsetAlias2()
-{
-}
-//--------------------------------------------------------------
-nsCharsetAlias2::~nsCharsetAlias2()
-{
-}
-
 // 
 static const char* kAliases[][3] = {
 #include "charsetalias.properties.h"
 };
 
 //--------------------------------------------------------------
-NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias,
-                                            nsACString& oResult)
+// static
+nsresult
+nsCharsetAlias::GetPreferred(const nsACString& aAlias,
+                             nsACString& oResult)
 {
    if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
 
    nsCAutoString key(aAlias);
    ToLowerCase(key);
 
-   nsresult rv = nsUConvPropertySearch::SearchPropertyValue(kAliases,
+   return nsUConvPropertySearch::SearchPropertyValue(kAliases,
       ArrayLength(kAliases), key, oResult);
-
-  return rv;
 }
 
 //--------------------------------------------------------------
-NS_IMETHODIMP
-nsCharsetAlias2::Equals(const nsACString& aCharset1,
-                        const nsACString& aCharset2, bool* oResult)
+// static
+nsresult
+nsCharsetAlias::Equals(const nsACString& aCharset1,
+                       const nsACString& aCharset2, bool* oResult)
 {
    nsresult res = NS_OK;
 
    if(aCharset1.Equals(aCharset2, nsCaseInsensitiveCStringComparator())) {
       *oResult = true;
       return res;
    }
 
    if(aCharset1.IsEmpty() || aCharset2.IsEmpty()) {
       *oResult = false;
       return res;
    }
 
    *oResult = false;
    nsCAutoString name1;
+   res = GetPreferred(aCharset1, name1);
+   if (NS_FAILED(res))
+     return res;
+
    nsCAutoString name2;
-   res = this->GetPreferred(aCharset1, name1);
-   if(NS_SUCCEEDED(res)) {
-      res = this->GetPreferred(aCharset2, name2);
-      if(NS_SUCCEEDED(res)) {
-        *oResult = name1.Equals(name2);
-      }
-   }
-   
-   return res;
+   res = GetPreferred(aCharset2, name2);
+   if (NS_FAILED(res))
+     return res;
+
+   *oResult = name1.Equals(name2);
+   return NS_OK;
 }
-
deleted file mode 100644
--- a/intl/locale/src/nsCharsetAlias.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#ifndef nsCharsetAlias_h__
-#define nsCharsetAlias_h__
-
-#include "nsICharsetAlias.h"
-
-//==============================================================
-class nsCharsetAlias2 : public nsICharsetAlias
-{
-  NS_DECL_ISUPPORTS
-
-public:
-
-  nsCharsetAlias2();
-  virtual ~nsCharsetAlias2();
-
-  NS_IMETHOD GetPreferred(const nsACString& aAlias, nsACString& aResult);
-
-  NS_IMETHOD Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* oResult) ;
-  
-};
-
-#endif // nsCharsetAlias_h__
-
-
--- a/intl/locale/src/nsLocaleConstructors.h
+++ b/intl/locale/src/nsLocaleConstructors.h
@@ -41,17 +41,16 @@
 
 #include "nsCollationCID.h"
 #include "nsDateTimeFormatCID.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsILocaleService.h"
 #include "nsIScriptableDateFormat.h"
 #include "nsIServiceManager.h"
 #include "nsLanguageAtomService.h"
-#include "nsCharsetAlias.h"
 #include "nsPlatformCharset.h"
 #include "nsLocaleCID.h"
 
 #if defined(XP_MACOSX)
 #define USE_MAC_LOCALE
 #endif
 
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
@@ -95,17 +94,16 @@ ctor_(nsISupports* aOuter, REFNSIID aIID
   return rv;                                              \
 }
 
 
 NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetAlias2)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
 
 #ifdef XP_WIN
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin)
 #endif
 
 #ifdef USE_UNIX_LOCALE
--- a/intl/uconv/src/nsCharsetConverterManager.cpp
+++ b/intl/uconv/src/nsCharsetConverterManager.cpp
@@ -35,17 +35,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsICharsetConverterManager.h"
 #include "nsEncoderDecoderUtils.h"
 #include "nsIStringBundle.h"
 #include "prmem.h"
 #include "nsCRT.h"
 #include "nsTArray.h"
@@ -303,20 +303,18 @@ NS_IMETHODIMP
 nsCharsetConverterManager::GetCharsetAlias(const char * aCharset, 
                                            nsACString& aResult)
 {
   NS_ENSURE_ARG_POINTER(aCharset);
 
   // We try to obtain the preferred name for this charset from the charset 
   // aliases.
   nsresult rv;
-  nsCOMPtr<nsICharsetAlias> csAlias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = csAlias->GetPreferred(nsDependentCString(aCharset), aResult);
+  rv = nsCharsetAlias::GetPreferred(nsDependentCString(aCharset), aResult);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsCharsetConverterManager::GetCharsetTitle(const char * aCharset, 
--- a/intl/uconv/tests/nsconv.cpp
+++ b/intl/uconv/tests/nsconv.cpp
@@ -41,18 +41,16 @@
 
 #include "nscore.h"
 #include "nsString.h"
 #include "nsIServiceManager.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIUnicodeEncoder.h"
 #include "nsIUnicodeDecoder.h"
 
-#include "nsICharsetAlias.h"
-
 static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 void usage()
 {
   printf(
@@ -85,38 +83,29 @@ int main(int argc, const char** argv)
   nsCOMPtr<nsICharsetConverterManager> ccMain =
       do_GetService(kCharsetConverterManagerCID, &res);
   if(NS_FAILED(res))
   {
     fprintf(stderr, "Cannot get Character Converter Manager %x\n", res);
     return -1;
   }
 
-  // Get the charset alias manager
-  nsCOMPtr<nsICharsetAlias> aliasmgr =
-      do_GetService(NS_CHARSETALIAS_CONTRACTID, &res);
-  if (NS_FAILED(res))
-  {
-    fprintf(stderr, "Cannot get Charset Alias Manager %x\n", res);
-    return -1;
-  }
-
   int i;
   if(argc > 4)
   {
     for(i =0; i < argc; i++)
     {
       if(strcmp(argv[i], "-f") == 0)
       {
         // User has specified the charset to convert from
         nsCAutoString str;
 
         // First check if a charset alias was given, 
         // and convert to the canonical name
-        res = aliasmgr->GetPreferred(nsDependentCString(argv[i+1]), str);
+        res = ccMain->GetCharsetAlias(argv[i+1], str);
         if (NS_FAILED(res))
         {
           fprintf(stderr, "Cannot get charset alias for %s %x\n",
                   argv[i+1], res);
           goto error_exit;
         }
 
         // Finally create the decoder
@@ -131,17 +120,17 @@ int main(int argc, const char** argv)
 
       if(strcmp(argv[i], "-t") == 0)
       {
         // User has specified which charset to convert to
         nsCAutoString str;
 
         // First check if a charset alias was given, 
         // and convert to the canonical name
-        res = aliasmgr->GetPreferred(nsDependentCString(argv[i+1]), str);
+        res = ccMain->GetCharsetAlias(argv[i+1], str);
         if (NS_FAILED(res))
         {
           fprintf(stderr, "Cannot get charset alias for %s %x\n",
                   argv[i+1], res);
           goto error_exit;
         }
 
         // Finally create the encoder 
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -57,17 +57,16 @@
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsString.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
-#include "nsICharsetAlias.h"
 #include "nsHashtable.h"
 #include "nsIURI.h"
 #include "nsIServiceManager.h"
 #include "nsNetUtil.h"
 #include "nsContentUtils.h"
 #include "nsCRT.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsContentPolicyUtils.h"
--- a/parser/html/nsHtml5MetaScannerCppSupplement.h
+++ b/parser/html/nsHtml5MetaScannerCppSupplement.h
@@ -32,21 +32,20 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
  
 #include "nsICharsetConverterManager.h"
 #include "nsServiceManagerUtils.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsEncoderDecoderUtils.h"
 #include "nsTraceRefcnt.h"
 
-static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
 
 void
 nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsIUnicodeDecoder** decoder, nsACString& charset)
 {
   readable = bytes;
   stateLoop(stateSave);
   readable = nsnull;
   if (mUnicodeDecoder) {
@@ -77,22 +76,17 @@ nsHtml5MetaScanner::tryCharset(nsString*
     res = convManager->GetUnicodeDecoderRaw(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
     if (NS_FAILED(res)) {
       NS_ERROR("Could not get decoder for UTF-8.");
       return false;
     }
     return true;
   }
   nsCAutoString preferred;
-  nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &res));
-  if (NS_FAILED(res)) {
-    NS_ERROR("Could not get CharsetAlias service.");
-    return false;
-  }
-  res = calias->GetPreferred(encoding, preferred);
+  res = nsCharsetAlias::GetPreferred(encoding, preferred);
   if (NS_FAILED(res)) {
     return false;
   }
   if (preferred.LowerCaseEqualsLiteral("utf-16") ||
       preferred.LowerCaseEqualsLiteral("utf-16be") ||
       preferred.LowerCaseEqualsLiteral("utf-16le") ||
       preferred.LowerCaseEqualsLiteral("utf-7") ||
       preferred.LowerCaseEqualsLiteral("jis_x0212-1990") ||
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -37,17 +37,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCompatibility.h"
 #include "nsScriptLoader.h"
 #include "nsNetUtil.h"
 #include "nsIStyleSheetLinkingElement.h"
-#include "nsICharsetAlias.h"
 #include "nsIWebShellServices.h"
 #include "nsIDocShell.h"
 #include "nsEncoderDecoderUtils.h"
 #include "nsContentUtils.h"
 #include "nsICharsetDetector.h"
 #include "nsIScriptElement.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIDocShellTreeItem.h"
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -35,17 +35,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHtml5StreamParser.h"
 #include "nsICharsetConverterManager.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsServiceManagerUtils.h"
 #include "nsEncoderDecoderUtils.h"
 #include "nsContentUtils.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsIHttpChannel.h"
 #include "nsHtml5Parser.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5AtomTable.h"
@@ -55,17 +55,16 @@
 #include "mozilla/Preferences.h"
 #include "nsHtml5Highlighter.h"
 #include "expat_config.h"
 #include "expat.h"
 #include "nsINestedURI.h"
 
 using namespace mozilla;
 
-static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
 
 PRInt32 nsHtml5StreamParser::sTimerInitialDelay = 120;
 PRInt32 nsHtml5StreamParser::sTimerSubsequentDelay = 120;
 
 // static
 void
 nsHtml5StreamParser::InitializeStatics()
 {
@@ -1166,38 +1165,33 @@ nsHtml5StreamParser::PreferredForInterna
   newEncoding.Trim(" \t\r\n\f");
   if (newEncoding.LowerCaseEqualsLiteral("utf-16") ||
       newEncoding.LowerCaseEqualsLiteral("utf-16be") ||
       newEncoding.LowerCaseEqualsLiteral("utf-16le")) {
     newEncoding.Assign("UTF-8");
   }
 
   nsresult rv = NS_OK;
-  nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &rv));
-  if (NS_FAILED(rv)) {
-    NS_NOTREACHED("Charset alias service not available.");
-    return false;
-  }
   bool eq;
-  rv = calias->Equals(newEncoding, mCharset, &eq);
+  rv = nsCharsetAlias::Equals(newEncoding, mCharset, &eq);
   if (NS_FAILED(rv)) {
     NS_NOTREACHED("Charset name equality check failed.");
     return false;
   }
   if (eq) {
     mCharsetSource = kCharsetFromMetaTag; // become confident
     mFeedChardet = false; // don't feed chardet when confident
     return false;
   }
   
   // XXX check HTML5 non-IANA aliases here
   
   nsCAutoString preferred;
   
-  rv = calias->GetPreferred(newEncoding, preferred);
+  rv = nsCharsetAlias::GetPreferred(newEncoding, preferred);
   if (NS_FAILED(rv)) {
     // the encoding name is bogus
     return false;
   }
   
   if (preferred.LowerCaseEqualsLiteral("utf-16") ||
       preferred.LowerCaseEqualsLiteral("utf-16be") ||
       preferred.LowerCaseEqualsLiteral("utf-16le") ||
--- a/parser/html/nsHtml5StreamParser.h
+++ b/parser/html/nsHtml5StreamParser.h
@@ -43,17 +43,16 @@
 #include "nsCOMPtr.h"
 #include "nsIStreamListener.h"
 #include "nsICharsetDetectionObserver.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "nsHtml5OwningUTF16Buffer.h"
 #include "nsIInputStream.h"
-#include "nsICharsetAlias.h"
 #include "mozilla/Mutex.h"
 #include "nsHtml5AtomTable.h"
 #include "nsHtml5Speculation.h"
 #include "nsITimer.h"
 #include "nsICharsetDetector.h"
 
 class nsHtml5Parser;
 
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -42,17 +42,17 @@
 #include "nsString.h"
 #include "nsCRT.h"
 #include "nsScanner.h"
 #include "plstr.h"
 #include "nsIStringStream.h"
 #include "nsIChannel.h"
 #include "nsICachingChannel.h"
 #include "nsICacheEntryDescriptor.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIInputStream.h"
 #include "CNavDTD.h"
 #include "prenv.h"
 #include "prlock.h"
 #include "prcvar.h"
 #include "nsParserCIID.h"
 #include "nsReadableUtils.h"
@@ -156,50 +156,43 @@ public:
   {
     mParser->HandleParserContinueEvent(this);
     return NS_OK;
   }
 };
 
 //-------------- End ParseContinue Event Definition ------------------------
 
-nsICharsetAlias* nsParser::sCharsetAliasService = nsnull;
 nsICharsetConverterManager* nsParser::sCharsetConverterManager = nsnull;
 
 /**
  *  This gets called when the htmlparser module is initialized.
  */
 // static
 nsresult
 nsParser::Init()
 {
   nsresult rv;
 
-  nsCOMPtr<nsICharsetAlias> charsetAlias =
-    do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   nsCOMPtr<nsICharsetConverterManager> charsetConverter =
     do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  charsetAlias.swap(sCharsetAliasService);
   charsetConverter.swap(sCharsetConverterManager);
 
   return NS_OK;
 }
 
 
 /**
  *  This gets called when the htmlparser module is shutdown.
  */
 // static
 void nsParser::Shutdown()
 {
-  NS_IF_RELEASE(sCharsetAliasService);
   NS_IF_RELEASE(sCharsetConverterManager);
 }
 
 #ifdef DEBUG
 static bool gDumpContent=false;
 #endif
 
 /**
@@ -2059,18 +2052,17 @@ ParserWriteFunc(nsIInputStream* in,
     nsCAutoString guess;
     nsCAutoString preferred;
 
     pws->mNeedCharsetCheck = false;
     if (pws->mParser->DetectMetaTag(buf, theNumRead, guess, guessSource) ||
         ((count >= 4) &&
          DetectByteOrderMark((const unsigned char*)buf,
                              theNumRead, guess, guessSource))) {
-      nsCOMPtr<nsICharsetAlias> alias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
-      result = alias->GetPreferred(guess, preferred);
+      result = nsCharsetAlias::GetPreferred(guess, preferred);
       // Only continue if it's a recognized charset and not
       // one of a designated set that we ignore.
       if (NS_SUCCEEDED(result) &&
           ((kCharsetFromByteOrderMark == guessSource) ||
            (!preferred.EqualsLiteral("UTF-16") &&
             !preferred.EqualsLiteral("UTF-16BE") &&
             !preferred.EqualsLiteral("UTF-16LE")))) {
         guess = preferred;
--- a/parser/htmlparser/src/nsParser.h
+++ b/parser/htmlparser/src/nsParser.h
@@ -84,17 +84,16 @@
 #include "nsDTDUtils.h"
 #include "nsThreadUtils.h"
 #include "nsIContentSink.h"
 #include "nsCOMArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWeakReference.h"
 
 class nsICharsetConverterManager;
-class nsICharsetAlias;
 class nsIDTD;
 class nsScanner;
 class nsIThreadPool;
 
 #ifdef _MSC_VER
 #pragma warning( disable : 4275 )
 #endif
 
@@ -352,20 +351,16 @@ class nsParser : public nsIParser,
     nsresult PostContinueEvent();
 
     /**
      *  Fired when the continue parse event is triggered.
      *  @update  kmcclusk 5/18/98
      */
     void HandleParserContinueEvent(class nsParserContinueEvent *);
 
-    static nsICharsetAlias* GetCharsetAliasService() {
-      return sCharsetAliasService;
-    }
-
     static nsICharsetConverterManager* GetCharsetConverterManager() {
       return sCharsetConverterManager;
     }
 
     virtual void Reset() {
       Cleanup();
       Initialize();
     }
@@ -460,14 +455,13 @@ protected:
     PRUint16            mFlags;
 
     nsString            mUnusedInput;
     nsCString           mCharset;
     nsCString           mCommandStr;
 
     bool                mProcessingNetworkData;
 
-    static nsICharsetAlias*            sCharsetAliasService;
     static nsICharsetConverterManager* sCharsetConverterManager;
 };
 
 #endif 
 
--- a/parser/htmlparser/src/nsScanner.cpp
+++ b/parser/htmlparser/src/nsScanner.cpp
@@ -37,17 +37,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 //#define __INCREMENTAL 1
 
 #include "nsScanner.h"
 #include "nsDebug.h"
 #include "nsIServiceManager.h"
 #include "nsICharsetConverterManager.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsReadableUtils.h"
 #include "nsIInputStream.h"
 #include "nsILocalFile.h"
 #include "nsNetUtil.h"
 #include "nsUTF8Utils.h" // for LossyConvertEncoding
 #include "nsCRT.h"
 #include "nsParser.h"
 
@@ -149,33 +149,30 @@ nsScanner::nsScanner(nsString& aFilename
   SetDocumentCharset(aCharset, aSource);
 }
 
 nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , PRInt32 aSource)
 {
   if (aSource < mCharsetSource) // priority is lower the the current one , just
     return NS_OK;
 
-  nsICharsetAlias* calias = nsParser::GetCharsetAliasService();
-  NS_ASSERTION(calias, "Must have the charset alias service!");
-
   nsresult res = NS_OK;
   if (!mCharset.IsEmpty())
   {
     bool same;
-    res = calias->Equals(aCharset, mCharset, &same);
+    res = nsCharsetAlias::Equals(aCharset, mCharset, &same);
     if(NS_SUCCEEDED(res) && same)
     {
       return NS_OK; // no difference, don't change it
     }
   }
 
   // different, need to change it
   nsCString charsetName;
-  res = calias->GetPreferred(aCharset, charsetName);
+  res = nsCharsetAlias::GetPreferred(aCharset, charsetName);
 
   if(NS_FAILED(res) && (mCharsetSource == kCharsetUninitialized))
   {
      // failed - unknown alias , fallback to ISO-8859-1
     mCharset.AssignLiteral("ISO-8859-1");
   }
   else
   {
--- a/parser/xml/src/nsSAXXMLReader.cpp
+++ b/parser/xml/src/nsSAXXMLReader.cpp
@@ -34,17 +34,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIInputStream.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
-#include "nsICharsetAlias.h"
+#include "nsCharsetAlias.h"
 #include "nsParserCIID.h"
 #include "nsStreamUtils.h"
 #include "nsStringStream.h"
 #include "nsIScriptError.h"
 #include "nsSAXAttributes.h"
 #include "nsSAXLocator.h"
 #include "nsSAXXMLReader.h"
 
@@ -643,27 +643,21 @@ nsSAXXMLReader::TryChannelCharset(nsICha
 {
   if (aCharsetSource >= kCharsetFromChannel)
     return true;
   
   if (aChannel) {
     nsCAutoString charsetVal;
     nsresult rv = aChannel->GetContentCharset(charsetVal);
     if (NS_SUCCEEDED(rv)) {
-      nsCOMPtr<nsICharsetAlias>
-        calias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
-      if (calias) {
-        nsCAutoString preferred;
-        rv = calias->GetPreferred(charsetVal, preferred);
-        if (NS_SUCCEEDED(rv)) {
-          aCharset = preferred;
-          aCharsetSource = kCharsetFromChannel;
-          return true;
-        }
-      }
+      if (NS_FAILED(nsCharsetAlias::GetPreferred(charsetVal, aCharset)))
+        return false;
+
+      aCharsetSource = kCharsetFromChannel;
+      return true;
     }
   }
 
   return false;
 }
 
 nsresult
 nsSAXXMLReader::EnsureBaseURI()