Bug 943732 Port the new Character Encoding menu r=IanN a=Ratty RELEASE_BASE_20140317 SEAMONKEY_2_25b3_BUILD1 SEAMONKEY_2_25b3_RELEASE
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 13 Mar 2014 19:24:27 +0000
changeset 17044 023e6dbe3d748eddeaaa79e4cb21f2adc2f47b5b
parent 17043 b8bfb74699cb7621098ea6cff164cd6643dc2854
child 17045 626864e894a86d93f04d5e34e17df6b322da0a10
child 17047 fd4b2b4ff046caa730556921e479988923c8be40
push idunknown
push userunknown
push dateunknown
reviewersIanN, Ratty
bugs943732
Bug 943732 Port the new Character Encoding menu r=IanN a=Ratty a=Callek for checkin to a CLOSED TREE
editor/ui/composer/content/editingOverlay.js
editor/ui/composer/content/editingOverlay.xul
editor/ui/composer/content/editor.js
editor/ui/composer/content/editor.xul
suite/browser/browser.js
suite/browser/navigatorOverlay.xul
suite/common/charsetOverlay.xul
suite/common/jar.mn
suite/debugQA/content/debugQATextEditorShell.xul
suite/mailnews/compose/MsgComposeCommands.js
suite/mailnews/compose/messengercompose.xul
suite/mailnews/mailWindow.js
suite/mailnews/mailWindowOverlay.js
suite/mailnews/mailWindowOverlay.xul
suite/mailnews/messageWindow.xul
suite/mailnews/messenger.xul
--- a/editor/ui/composer/content/editingOverlay.js
+++ b/editor/ui/composer/content/editingOverlay.js
@@ -321,16 +321,18 @@ function EditorInitFileMenu()
 
     // See if there's more if current file is only entry in history list.
     if (historyUrl && historyUrl == docUrl)
       historyUrl = GetStringPref("editor.history_url_1");
   }
   SetElementEnabledById("menu_RecentFiles", historyUrl != "");
 }
 
-function updateCharsetPopupMenu(aMenuPopup)
+function EditorUpdateCharsetMenu(aMenuPopup)
 {
   if (IsDocumentModified() && !IsDocumentEmpty())
   {
     for (var i = 0; i < aMenuPopup.childNodes.length; i++)
       aMenuPopup.childNodes[i].setAttribute("disabled", "true");
   }
+
+  UpdateCharsetMenu(content.document.characterSet, aMenuPopup);
 }
--- a/editor/ui/composer/content/editingOverlay.xul
+++ b/editor/ui/composer/content/editingOverlay.xul
@@ -134,20 +134,16 @@
               oncommand="InlineSpellCheckerUI.enabled = !InlineSpellCheckerUI.enabled"/>
     <menuitem id="menu_publishSettings"
               insertafter="sep_preferences"
               label="&publishSettings.label;"
               accesskey="&publishSettings.accesskey;"
               command="cmd_publishSettings"/>
   </menupopup>
 
-  <!-- View menu items -->
-  <menupopup id="composerCharsetMenuPopup"
-             onpopupshowing="updateCharsetPopupMenu(this);"/>
-
   <!-- Toolbar buttons/items -->
   <toolbarbutton id="newButton"
                  class="toolbarbutton-1"
                  label="&newToolbarCmd.label;"
                  command="cmd_newEditor"
                  tooltiptext="&newToolbarCmd.tooltip;"/>
   <toolbarbutton id="openButton"
                  class="toolbarbutton-1"
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -617,21 +617,22 @@ function CheckAndSaveDocument(command, a
     return true;
 
   // Default or result == 1 (Cancel)
   return false;
 }
 
 // --------------------------- View menu ---------------------------
 
-function EditorSetDocumentCharacterSet(aCharset)
+function EditorSetCharacterSet(aEvent)
 {
   try {
     var editor = GetCurrentEditor();
-    editor.documentCharacterSet = aCharset;
+    if (aEvent.target.id.startsWith("charset."))
+      editor.documentCharacterSet = aEvent.target.id.slice("charset.".length);
     var docUrl = GetDocumentUrl();
     if( !IsUrlAboutBlank(docUrl))
     {
       // reloading the document will reverse any changes to the META charset, 
       // we need to put them back in, which is achieved by a dedicated listener
       editor.addDocumentStateListener( DocumentReloadListener );
       EditorLoadUrl(docUrl);
     }
--- a/editor/ui/composer/content/editor.xul
+++ b/editor/ui/composer/content/editor.xul
@@ -10,17 +10,17 @@
 <?xml-stylesheet href="chrome://editor/skin/editorFormatToolbar.css" type="text/css"?> 
 <?xml-stylesheet href="chrome://editor/skin/editorModeToolbar.css" type="text/css"?> 
 <?xul-overlay href="chrome://editor/content/editorOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/editingOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/composerOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/contentAreaContextOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/EditorContextMenuOverlay.xul"?>
 <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
-<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
+<?xul-overlay href="chrome://communicator/content/charsetOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % editorDTD SYSTEM "chrome://editor/locale/editor.dtd" >
 %editorDTD;
 <!ENTITY % editorOverlayDTD SYSTEM "chrome://editor/locale/editorOverlay.dtd" >
@@ -169,17 +169,19 @@
                 command="cmd_HTMLSourceMode"/>
       <menuitem id="viewPreviewMode"
                 type="radio"
                 group="mode"
                 label="&PreviewMode.label;"
                 accesskey="&PreviewMode.accesskey;"
                 command="cmd_PreviewMode"/>
       <menuseparator id="viewSep2"/>
-      <menu id = "composerCharsetMenu" />
+      <menu id="charsetMenu"
+            onpopupshowing="EditorUpdateCharsetMenu(event.target);"
+            oncommand="EditorSetCharacterSet(event);"/>
     </menupopup>
     </menu>
  
     <menu id="insertMenu"/>
 
     <menu id="formatMenu" label="&formatMenu.label;" accesskey="&formatMenu.accesskey;">
       <menupopup id="formatMenuPopup">
         <menuitem id="snapToGrid"
--- a/suite/browser/browser.js
+++ b/suite/browser/browser.js
@@ -166,32 +166,46 @@ function getNavToolbox()
   return gNavToolbox;
 }
 
 function BrowserPrintPreview()
 {
   PrintUtils.printPreview(PrintPreviewListener);
 }
 
-function BrowserSetDefaultCharacterSet(aCharset)
+function BrowserSetCharacterSet(aEvent)
 {
-  // no longer needed; set when setting Force; see bug 79608
-}
-
-function BrowserSetForcedCharacterSet(aCharset)
-{
-  getBrowser().docShell.charset = aCharset;
+  if (aEvent.target.id.startsWith("charset."))
+    getBrowser().docShell.charset = aEvent.target.id.slice("charset.".length);
   BrowserCharsetReload();
 }
 
 function BrowserCharsetReload()
 {
   BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
 }
 
+function BrowserUpdateCharsetMenu(aNode)
+{
+  var wnd = document.commandDispatcher.focusedWindow;
+  if (wnd.top != content)
+    wnd = content;
+  UpdateCharsetMenu(wnd.document.characterSet, aNode);
+}
+
+function EnableCharsetMenu()
+{
+  var menuitem = document.getElementById("charsetMenu");
+  if (getBrowser() && getBrowser().docShell &&
+      getBrowser().docShell.mayEnableCharacterEncodingMenu)
+    menuitem.removeAttribute("disabled");
+  else
+    menuitem.setAttribute("disabled", "true");
+}
+
 var gFindInstData;
 function getFindInstData()
 {
   if (!gFindInstData) {
     gFindInstData = new nsFindInstData();
     gFindInstData.browser = getBrowser();
     // defaults for rootSearchWindow and currentSearchWindow are fine here
   }
--- a/suite/browser/navigatorOverlay.xul
+++ b/suite/browser/navigatorOverlay.xul
@@ -4,17 +4,17 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/viewZoomOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/viewApplyThemeOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/bookmarks/placesOverlay.xul"?>
-<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
+<?xul-overlay href="chrome://communicator/content/charsetOverlay.xul"?>
 <?xul-overlay href="chrome://navigator/content/mailNavigatorOverlay.xul"?>
 <?xul-overlay href="chrome://navigator/content/platformNavigationBindings.xul"?>
 
 <!DOCTYPE overlay [
 <!ENTITY % navigatorDTD SYSTEM "chrome://navigator/locale/navigator.dtd" >
 %navigatorDTD;
 <!ENTITY % navigatorOverlayDTD SYSTEM "chrome://navigator/locale/navigatorOverlay.dtd">
 %navigatorOverlayDTD;
@@ -292,17 +292,17 @@
         <menuitem id="textfieldDirection-swap" hidden="true"/>
 
         <menuseparator id="menu_PrefsSeparator"/> 
         <menuitem id="menu_preferences" oncommand="goPreferences('navigator_pane')"/>
       </menupopup>
     </menu>
 
     <menu id="menu_View">
-      <menupopup id="menu_View_Popup">
+      <menupopup id="menu_View_Popup" onpopupshowing="EnableCharsetMenu();">
         <menu label="&toolbarsCmd.label;" accesskey="&toolbarsCmd.accesskey;" id="menu_Toolbars">
           <menupopup id="view_toolbars_popup"
                      onpopupshowing="updateToolbarStates(event);"
                      oncommand="onViewToolbarCommand(event);">
             <menuitem id="menuitem_showhide_tabbar"
                       label="&tabbarCmd.label;"
                       accesskey="&tabbarCmd.accesskey;"
                       class="menuitem-iconic"
@@ -359,17 +359,19 @@
                       oncommand="setStyleDisabled(true); event.stopPropagation();"
                       type="radio"/>
             <menuitem id="menu_pageStylePersistentOnly"
                       label="&useStyleSheetPersistentOnly.label;"
                       accesskey="&useStyleSheetPersistentOnly.accesskey;"
                       type="radio"/>
           </menupopup>
         </menu>
-        <menu id="charsetMenu" observes="isImage"/>
+        <menu id="charsetMenu"
+              onpopupshowing="BrowserUpdateCharsetMenu(this);"
+              oncommand="BrowserSetCharacterSet(event);"/>
         <menuitem hidden="true" id="documentDirection-swap"
                   label="&bidiSwitchPageDirectionItem.label;"
                   accesskey="&bidiSwitchPageDirectionItem.accesskey;"
                   command="cmd_SwitchDocumentDirection"/>
         <menuseparator />
         <menuitem id="menuitem_pageSourceCmd"
                   label="&pageSourceCmd.label;"
                   accesskey="&pageSourceCmd.accesskey;"
new file mode 100644
--- /dev/null
+++ b/suite/common/charsetOverlay.xul
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!-- 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/. -->
+
+<!DOCTYPE overlay SYSTEM "chrome://global/locale/charsetMenu.dtd">
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script>
+    Components.utils.import("resource://gre/modules/CharsetMenu.jsm");
+
+    function UpdateCharsetMenu(aCharset, aNode)
+    {
+      var bundle = document.getElementById("charsetBundle");
+      var charset = bundle.getString(aCharset.toLowerCase());
+      var menuitem = document.getElementById("charset." + charset);
+      menuitem.setAttribute("checked", "true");
+    }
+
+    function SelectCharsetDetector(aEvent)
+    {
+      const nsISupportsString = Components.interfaces.nsISupportsString;
+      var str = Components.classes["@mozilla.org/supports-string;1"]
+                          .createInstance(nsISupportsString);
+      str.data = aEvent.target.getAttribute("detector");
+      Services.prefs.setComplexValue("intl.charset.detector", nsISupportsString, str);
+    }
+
+    function UpdateCharsetDetector(aNode)
+    {
+      var detector = GetLocalizedStringPref("intl.charset.detector");
+      var menuitem = aNode.getElementsByAttribute("detector", detector).item(0);
+      if (menuitem)
+        menuitem.setAttribute("checked", "true");
+    }
+  </script>
+
+  <stringbundleset>
+    <stringbundle id="charsetBundle"
+                  src="chrome://communicator/content/labelsencodings.properties"/>
+  </stringbundleset>
+
+  <menu id="charsetMenu"
+        label="&charsetMenu.label;"
+        accesskey="&charsetMenu.accesskey;">
+    <menupopup id="charsetPopup" onpopupshowing="CharsetMenu.build(event);">
+      <menu id="charsetMenuAutodet"
+            label="&charsetMenuAutodet.label;"
+            accesskey="&charsetMenuAutodet.accesskey;"
+            onpopupshowing="UpdateCharsetDetector(this);"
+            oncommand="SelectCharsetDetector(event);">
+        <menupopup>
+          <menuitem type="radio"
+                    name="detectorGroup"
+                    detector=""
+                    label="&charsetMenuAutodet.off.label;"
+                    accesskey="&charsetMenuAutodet.off.accesskey;"/>
+          <menuitem type="radio"
+                    name="detectorGroup"
+                    detector="ja_parallel_state_machine"
+                    label="&charsetMenuAutodet.ja.label;"
+                    accesskey="&charsetMenuAutodet.ja.accesskey;"/>
+          <menuitem type="radio"
+                    name="detectorGroup"
+                    detector="ruprob"
+                    label="&charsetMenuAutodet.ru.label;"
+                    accesskey="&charsetMenuAutodet.ru.accesskey;"/>
+          <menuitem type="radio"
+                    name="detectorGroup"
+                    detector="ukprob"
+                    label="&charsetMenuAutodet.uk.label;"
+                    accesskey="&charsetMenuAutodet.uk.accesskey;"/>
+        </menupopup>
+      </menu>
+      <menuseparator id="charsetMenuSeparator"/>
+    </menupopup>
+  </menu>
+</overlay>
--- a/suite/common/jar.mn
+++ b/suite/common/jar.mn
@@ -52,29 +52,31 @@ comm.jar:
    content/communicator/aboutSessionRestore.js
    content/communicator/aboutSessionRestore.xhtml
    content/communicator/askViewZoom.xul
    content/communicator/askViewZoom.js
    content/communicator/blockedSite.xhtml
    content/communicator/certError.css
    content/communicator/certError.xhtml
    content/communicator/certError.xml
+   content/communicator/charsetOverlay.xul
    content/communicator/communicator.css
    content/communicator/consoleOverlay.xul
    content/communicator/contentAreaClick.js
    content/communicator/contentAreaContextOverlay.xul
    content/communicator/defaultClientDialog.js
    content/communicator/defaultClientDialog.xul
    content/communicator/findUtils.js
    content/communicator/fullscreen-video.xhtml
    content/communicator/helpEditorOverlay.xul
    content/communicator/helpMessengerOverlay.xul
    content/communicator/helpSecurityOverlay.xul
    content/communicator/helpOverlay.js
    content/communicator/helpOverlay.xul
+   content/communicator/labelsencodings.properties                  (/mozilla/dom/encoding/labelsencodings.properties)
 # the following file is a suite-specific override of the generic license.html, using suite/common/app-license.html as input:
 *  content/communicator/license.html                                (/mozilla/toolkit/content/license.html)
    content/communicator/nsContextMenu.js
    content/communicator/openLocation.js
    content/communicator/openLocation.xul
    content/communicator/passwordManager.xul
    content/communicator/printPreviewBindings.xml
    content/communicator/safeMode.js
--- a/suite/debugQA/content/debugQATextEditorShell.xul
+++ b/suite/debugQA/content/debugQATextEditorShell.xul
@@ -4,17 +4,17 @@
    - 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/. -->
 
 <?xml-stylesheet href="chrome://editor/skin/editor.css" type="text/css"?>
 <?xml-stylesheet href="chrome://editor/skin/editorPrimaryToolbar.css" type="text/css"?>
 <?xul-overlay href="chrome://editor/content/editorOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/editingOverlay.xul"?>
 <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
-<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
+<?xul-overlay href="chrome://communicator/content/charsetOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/contentAreaContextOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
 <?xul-overlay href="chrome://debugQA/content/debugQAEditorOverlay.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % debugQAEditorOverlayDTD SYSTEM "chrome://debugqa/locale/debugQAEditorOverlay.dtd">
@@ -94,17 +94,19 @@
                         type="checkbox"
                         label="&compositionToolbarCmd.label;"
                         accesskey="&compositionToolbarCmd.accesskey;"
                         command="cmd_viewCompToolbar"/>
               <menuitem id="menu_showTaskbar"/>
             </menupopup>
           </menu>
           <menuseparator id="viewSep1"/>
-          <menu id="composerCharsetMenu"/>
+          <menu id="charsetMenu"
+                onpopupshowing="EditorUpdateCharsetMenu(event.target);"
+                oncommand="EditorSetCharacterSet(event);"/>
         </menupopup>
       </menu>
 
       <menu id="insertMenuPlainText"
             label="&insertMenu.label;"
             accesskey="&insertMenu.accesskey;">
         <menupopup id="insertMenuPlainTextPopup">
           <menuitem id="insertPlainTextChars"
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -1191,64 +1191,27 @@ function ComposeUnload()
   RemoveMessageComposeOfflineQuitObserver();
 
   if (gMsgCompose)
     gMsgCompose.UnregisterStateListener(stateListener);
   if (gAutoSaveTimeout)
     clearTimeout(gAutoSaveTimeout);
 }
 
-function SetDocumentCharacterSet(aCharset)
+function ComposeSetCharacterSet(aEvent)
 {
   if (gMsgCompose) {
-    gMsgCompose.SetDocumentCharset(aCharset);
+    gMsgCompose.SetDocumentCharset(aEvent.target.id.slice("charset.".length));
     gCharsetTitle = null;
     SetComposeWindowTitle();
   }
   else
     dump("Compose has not been created!\n");
 }
 
-function UpdateMailEditCharset()
-{
-  var send_default_charset = gMsgCompose.compFields.defaultCharacterSet;
-//  dump("send_default_charset is " + send_default_charset + "\n");
-
-  var compFieldsCharset = gMsgCompose.compFields.characterSet;
-//  dump("gMsgCompose.compFields is " + compFieldsCharset + "\n");
-
-  if (gCharsetConvertManager) {
-    var charsetAlias = gCharsetConvertManager.getCharsetAlias(compFieldsCharset);
-    if (charsetAlias == "us-ascii")
-      compFieldsCharset = "ISO-8859-1";   // no menu item for "us-ascii"
-  }
-
-  // charset may have been set implicitly in case of reply/forward
-  // or use pref default otherwise
-  var menuitem = document.getElementById(send_default_charset == compFieldsCharset ?
-                                         send_default_charset : compFieldsCharset);
-  if (menuitem)
-    menuitem.setAttribute('checked', 'true');
-
-  // Set a document charset to a default mail send charset.
-  if (send_default_charset == compFieldsCharset)
-    SetDocumentCharacterSet(send_default_charset);
-}
-
-function InitCharsetMenuCheckMark()
-{
-  // Check the menu
-  UpdateMailEditCharset();
-  // use setTimeout workaround to delay checkmark the menu
-  // when onmenucomplete is ready then use it instead of oncreate
-  // see bug #78290 for the details
-  setTimeout(UpdateMailEditCharset, 50);
-
-}
-
 function GetCharsetUIString()
 {
   var charset = gMsgCompose.compFields.characterSet;
   if (gSendDefaultCharset == null) {
     gSendDefaultCharset = gMsgCompose.compFields.defaultCharacterSet;
   }
 
   charset = charset.toUpperCase();
--- a/suite/mailnews/compose/messengercompose.xul
+++ b/suite/mailnews/compose/messengercompose.xul
@@ -3,17 +3,17 @@
    - 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/. -->
 
 <?xml-stylesheet href="chrome://messenger/skin/messengercompose/messengercompose.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 <?xml-stylesheet href="chrome://editor/skin/editorFormatToolbar.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/addressingWidget.css" type="text/css"?>
 
-<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
+<?xul-overlay href="chrome://communicator/content/charsetOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/contentAreaContextOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/messengercompose/msgComposeContextOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/messengercompose/addressingWidgetOverlay.xul"?>
 <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/editorOverlay.xul"?>
@@ -353,17 +353,24 @@
                            onpopupshowing="updatePriorityMenu(this);">
                   <menuitem id="priority_highest" type="radio" name="priority" label="&highestPriorityCmd.label;" accesskey="&highestPriorityCmd.accesskey;" value="Highest"/>
                   <menuitem id="priority_high"    type="radio" name="priority" label="&highPriorityCmd.label;"    accesskey="&highPriorityCmd.accesskey;"    value="High"/>
                   <menuitem id="priority_normal"  type="radio" name="priority" label="&normalPriorityCmd.label;"  accesskey="&normalPriorityCmd.accesskey;"  value="Normal"/>
                   <menuitem id="priority_low"     type="radio" name="priority" label="&lowPriorityCmd.label;"     accesskey="&lowPriorityCmd.accesskey;"     value="Low"/>
                   <menuitem id="priority_lowest"  type="radio" name="priority" label="&lowestPriorityCmd.label;"  accesskey="&lowestPriorityCmd.accesskey;"  value="Lowest"/>
                 </menupopup>
               </menu>
-              <menu id="maileditCharsetMenu" />
+              <menu id="charsetMenu"
+                    onpopupshowing="UpdateCharsetMenu(gMsgCompose.compFields.characterSet, this);"
+                    oncommand="ComposeSetCharacterSet(event);">
+                <menupopup id="charsetPopup">
+                  <menu id="charsetMenuAutodet" hidden="true"/>
+                  <menuseparator id="charsetMenuSeparator" hidden="true"/>
+                </menupopup>
+              </menu>
               <menu id="fccMenu"
                     label="&fileCarbonCopyCmd.label;"
                     accesskey="&fileCarbonCopyCmd.accesskey;"
                     sortResource="http://home.netscape.com/NC-rdf#FolderTreeName"
                     sortDirection="ascending"
                     datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
                     ref="msgaccounts:/"
                     oncommand="MessageFcc(event.target);">
--- a/suite/mailnews/mailWindow.js
+++ b/suite/mailnews/mailWindow.js
@@ -567,8 +567,17 @@ function SetKeywords(aKeywords)
       // if no keywords, reset class to the original class
       element.setAttribute("class", originalclass);
     }
   }
 
   // cache the keywords 
   gLastKeywords = aKeywords;
 }
+
+function MailSetCharacterSet(aEvent)
+{
+  if (aEvent.target.id.startsWith("charset.")) {
+    msgWindow.mailCharacterSet = aEvent.target.id.slice("charset.".length);
+    msgWindow.charsetOverride = true;
+  }
+  messenger.setDocumentCharset(msgWindow.mailCharacterSet);
+}
--- a/suite/mailnews/mailWindowOverlay.js
+++ b/suite/mailnews/mailWindowOverlay.js
@@ -149,16 +149,20 @@ function view_init()
   var view_menuitem = document.getElementById("viewMessageViewMenu");
   if (view_menuitem)
     view_menuitem.setAttribute("disabled", gAccountCentralLoaded);
 
   var threads_menuitem = document.getElementById("viewMessagesMenu");
   if (threads_menuitem)
     threads_menuitem.setAttribute("disabled", gAccountCentralLoaded);
 
+  var charset_menuitem = document.getElementById("charsetMenu");
+  if (charset_menuitem)
+    charset_menuitem.setAttribute("disabled", !msgWindow.mailCharacterSet);
+
   // Initialize the Message Body menuitem
   var isFeed = gFolderDisplay.selectedMessageIsFeed;
   document.getElementById('viewBodyMenu').hidden = isFeed;
 
   // Initialize the Show Feed Summary menu
   var viewFeedSummary = document.getElementById('viewFeedSummary');
   var winType = document.documentElement.getAttribute('windowtype');
   if (winType != "mail:3pane")
--- a/suite/mailnews/mailWindowOverlay.xul
+++ b/suite/mailnews/mailWindowOverlay.xul
@@ -1,17 +1,17 @@
 <?xml version="1.0"?>
 
 <!-- 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/. -->
 
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 
-<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
+<?xul-overlay href="chrome://communicator/content/charsetOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/contentAreaContextOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/viewZoomOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/viewApplyThemeOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/msgHdrViewOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/mailOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/mailKeysOverlay.xul"?>
 
 <!DOCTYPE overlay [
@@ -1306,17 +1306,19 @@
       <menuitem id="menu_Stop"
                 label="&reloadCmd.label;"
                 key="key_reload"
                 accesskey="&reloadCmd.accesskey;"
                 command="cmd_reload"/>
       <menuseparator id="viewAfterStopSeparator"/>
       <!-- overlayed from viewZoomOverlay.xul -->
       <menu id="menu_zoom"/>
-      <menu id="mailviewCharsetMenu" />
+      <menu id="charsetMenu"
+            onpopupshowing="UpdateCharsetMenu(msgWindow.mailCharacterSet, this);"
+            oncommand="MailSetCharacterSet(event);"/>
       <menuseparator id="viewAfterCharsetSeparator"/>
       <menuitem id="pageSourceMenuItem" label="&pageSourceCmd.label;" key="key_viewPageSource" accesskey="&pageSourceCmd.accesskey;" command="cmd_viewPageSource"/>
       <menuseparator observes="mailHideMenus"/>
       <!-- overlayed from viewApplyThemeOverlay.xul -->
       <menu id="menu_viewApplyTheme" observes="mailHideMenus"/>
     </menupopup>
   </menu>
 
--- a/suite/mailnews/messageWindow.xul
+++ b/suite/mailnews/messageWindow.xul
@@ -34,17 +34,16 @@
         windowtype="mail:messageWindow">
 
   <stringbundleset id="stringbundleset">
     <stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
     <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
     <stringbundle id="bundle_offlinePrompts" src="chrome://messenger/locale/offline.properties"/>
   </stringbundleset>
 
-  <script type="application/javascript" src="chrome://messenger/content/shareglue.js"/>
   <script type="application/javascript" src="chrome://messenger/content/commandglue.js"/>
   <script type="application/javascript" src="chrome://messenger/content/mailWindow.js"/>
   <script type="application/javascript" src="chrome://messenger/content/messageWindow.js"/>
   <script type="application/javascript" src="chrome://messenger/content/accountUtils.js"/>
   <script type="application/javascript" src="chrome://messenger/content/mailContextMenus.js"/>
   <script type="application/javascript" src="chrome://messenger/content/phishingDetector.js"/>
   <script type="application/javascript" src="chrome://communicator/content/contentAreaClick.js"/>
   <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
--- a/suite/mailnews/messenger.xul
+++ b/suite/mailnews/messenger.xul
@@ -39,17 +39,16 @@
 <stringbundleset id="stringbundleset">
   <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
   <stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
   <stringbundle id="bundle_search" src="chrome://messenger/locale/search.properties"/>
 </stringbundleset>
 
 <script type="application/javascript" src="chrome://messenger/content/widgetglue.js"/>
 <script type="application/javascript" src="chrome://messenger/content/commandglue.js"/>
-<script type="application/javascript" src="chrome://messenger/content/shareglue.js"/>
 <script type="application/javascript" src="chrome://messenger/content/msgViewNavigation.js"/>
 <script type="application/javascript" src="chrome://messenger/content/mailWindow.js"/>
 <script type="application/javascript" src="chrome://messenger/content/msgMail3PaneWindow.js"/>
 <script type="application/javascript" src="chrome://messenger/content/mail3PaneWindowCommands.js"/>
 <script type="application/javascript" src="chrome://messenger/content/mailContextMenus.js"/>
 <script type="application/javascript" src="chrome://messenger/content/messengerdnd.js"/>
 <script type="application/javascript" src="chrome://messenger/content/accountUtils.js"/>
 <script type="application/javascript" src="chrome://messenger/content/phishingDetector.js"/>