Bug 1381762 - Replace nsIPlatfromCharset in mailnews. r=m_kato
authorJorg K <jorgk@jorgk.com>
Mon, 23 Oct 2017 18:24:51 +0200
changeset 22410 0b0cba8d70bd35997965afe4c02010c49e402980
parent 22409 2ae6e4e072d564323bdff269b3ac37a5cfc1873f
child 22411 97ec98c4dd5399c4a5d17a2f71bbfa43013c9d57
push id13662
push usermozilla@jorgk.com
push dateMon, 23 Oct 2017 16:33:51 +0000
treeherdercomm-central@0b0cba8d70bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1381762
Bug 1381762 - Replace nsIPlatfromCharset in mailnews. r=m_kato
mailnews/base/util/nsMsgI18N.cpp
--- a/mailnews/base/util/nsMsgI18N.cpp
+++ b/mailnews/base/util/nsMsgI18N.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // as does this
 #include "nsICharsetConverterManager.h"
-#include "nsIPlatformCharset.h"
+#include "mozilla/dom/FallbackEncoding.h"
 #include "nsIServiceManager.h"
 
 #include "nsISupports.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsIMimeConverter.h"
 #include "nsMsgUtils.h"
 #include "nsMsgI18N.h"
@@ -126,43 +126,25 @@ nsresult CopyMUTF7toUTF16(const nsCStrin
 
 // Charset used by the file system.
 const char * nsMsgI18NFileSystemCharset()
 {
   /* Get a charset used for the file. */
   static nsAutoCString fileSystemCharset;
 
   if (fileSystemCharset.IsEmpty())
-  {
-    nsresult rv;
-    nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
-        if (NS_SUCCEEDED(rv)) {
-          rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName,
-                                           fileSystemCharset);
-        }
+    mozilla::dom::FallbackEncoding::FromLocale()->Name(fileSystemCharset);
 
-    if (NS_FAILED(rv))
-      fileSystemCharset.AssignLiteral("ISO-8859-1");
-  }
   return fileSystemCharset.get();
 }
 
 // Charset used by the text file.
 void nsMsgI18NTextFileCharset(nsACString& aCharset)
 {
-  nsresult rv;
-  nsCOMPtr <nsIPlatformCharset> platformCharset =
-    do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv)) {
-    rv = platformCharset->GetCharset(kPlatformCharsetSel_PlainTextInFile,
-                                     aCharset);
-  }
-
-  if (NS_FAILED(rv))
-    aCharset.AssignLiteral("ISO-8859-1");
+  mozilla::dom::FallbackEncoding::FromLocale()->Name(aCharset);
 }
 
 // MIME encoder, output string should be freed by PR_FREE
 // XXX : fix callers later to avoid allocation and copy
 char * nsMsgI18NEncodeMimePartIIStr(const char *header, bool structured, const char *charset, int32_t fieldnamelen, bool usemime)
 {
   // No MIME, convert to the outgoing mail charset.
   if (false == usemime) {