Bug 596173 - Add a "Character Encoding" menu to the Firefox button if a hidden pref is turned on [r=gavin, ui-r=faaborg, a=blocking]
authorPatrick Walton <pwalton@mozilla.com>
Tue, 21 Sep 2010 14:56:52 -0700
changeset 54483 02e202603e0836f63ed2441ff8f3490ddf8b807e
parent 54482 1dd70e6dfe6122e863b42382da979b03dc28be7e
child 54484 13b48c1672c54eed534218ba94e57b9b145316d3
push id15903
push userposhannessy@mozilla.com
push dateTue, 21 Sep 2010 22:00:33 +0000
treeherdermozilla-central@13b48c1672c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, faaborg, blocking
bugs596173
milestone2.0b7pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 596173 - Add a "Character Encoding" menu to the Firefox button if a hidden pref is turned on [r=gavin, ui-r=faaborg, a=blocking]
browser/app/profile/firefox.js
browser/base/content/browser.js
browser/base/content/browser.xul
browser/base/content/test/tabview/browser_tabview_multiwindow_search.js
browser/locales/en-US/chrome/browser/browser.properties
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1043,8 +1043,13 @@ pref("services.sync.prefs.sync.spellchec
 pref("services.sync.prefs.sync.xpinstall.whitelist.required", true);
 #endif
 
 // Disable the Error Console
 pref("devtools.errorconsole.enabled", false);
 
 // disable the Inspector
 pref("devtools.inspector.enabled", false);
+
+// Whether the character encoding menu is under the main Firefox button. This
+// preference is a string so that localizers can alter it.
+pref("browser.menu.showCharacterEncoding", "chrome://browser/locale/browser.properties");
+
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -47,16 +47,17 @@
 #   Edward Lee <edward.lee@engineering.uiuc.edu>
 #   Paul O’Shannessy <paul@oshannessy.com>
 #   Nils Maier <maierman@web.de>
 #   Rob Arnold <robarnold@cmu.edu>
 #   Dietrich Ayala <dietrich@mozilla.com>
 #   Gavin Sharp <gavin@gavinsharp.com>
 #   Justin Dolske <dolske@mozilla.com>
 #   Rob Campbell <rcampbell@mozilla.com>
+#   Patrick Walton <pcwalton@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either 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
@@ -1594,16 +1595,28 @@ function delayedStartup(isLoadingBlank, 
 
   // Enable Error Console?
   let consoleEnabled = gPrefService.getBoolPref("devtools.errorconsole.enabled");
   if (consoleEnabled) {
     document.getElementById("javascriptConsole").hidden = false;
     document.getElementById("key_errorConsole").removeAttribute("disabled");
   }
 
+  // If the user (or the locale) hasn't enabled the top-level "Character
+  // Encoding" menu via the "browser.menu.showCharacterEncoding" preference,
+  // hide it.
+  const showCharacterEncodingPref = "browser.menu.showCharacterEncoding";
+  let extraCharacterEncodingMenuEnabled = gPrefService.
+    getComplexValue(showCharacterEncodingPref, Ci.nsIPrefLocalizedString).data;
+  if (extraCharacterEncodingMenuEnabled !== "true") {
+    let charsetMenu = document.getElementById("appmenu_charsetMenu");
+    if (charsetMenu)
+      charsetMenu.setAttribute("hidden", "true");
+  }
+
   Services.obs.notifyObservers(window, "browser-delayed-startup-finished", "");
 }
 
 function BrowserShutdown()
 {
   if (Win7Features)
     Win7Features.onCloseWindow();
 
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -563,27 +563,30 @@
                         command="Tools:Inspect"
                         key="key_inspect"/>
               <menuseparator/>
               <menuitem id="appmenu_pageSource"
                         label="&viewPageSourceCmd.label;"
                         command="View:PageSource"
                         key="key_viewSource"/>
               <menuseparator/>
-#define ID_PREFIX appmenu_
+#define ID_PREFIX appmenu_developer_
 #include browser-charsetmenu.inc
 #undef ID_PREFIX
               <menuseparator/>
               <menuitem label="&goOfflineCmd.label;"
                         type="checkbox"
                         observes="workOfflineMenuitemState"
                         oncommand="BrowserOffline.toggleOfflineStatus();"/>
             </menupopup>
           </menu>
           <menuseparator class="appmenu-menuseparator"/>
+#define ID_PREFIX appmenu_
+#include browser-charsetmenu.inc
+#undef ID_PREFIX
           <menuitem id="appmenu_fullScreen"
                     class="menuitem-tooltip"
                     label="&fullScreenCmd.label;"
                     type="checkbox"
                     observes="View:FullScreen"
                     key="key_fullScreen"/>
           <menuitem id="appmenu-quit"
                     class="menuitem-iconic"
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -313,8 +313,19 @@ ctrlTab.showAll.label=;Show all #1 tabs
 # Used as the bookmark name when saving a keyword for a search field.
 addKeywordTitleAutoFill=Search %S
 
 # TabView
 tabView2.title=%S - Group Your Tabs
 
 extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.name=Default
 extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description=The default theme.
+
+# LOCALIZATION NOTE (browser.menu.showCharacterEncoding): Set to the string
+# "true" (spelled and capitalized exactly that way) to show the "Character
+# Encoding" menu in the main Firefox button on Windows. Any other value will
+# hide it. Regardless of the value of this setting, the "Character Encoding"
+# menu will always be accessible via the "Web Developer" menu.
+# This is not a string to translate; it just controls whether the menu shows
+# up in the Firefox button. If users frequently use the "Character Encoding"
+# menu, set this to "true". Otherwise, you can leave it as "false".
+browser.menu.showCharacterEncoding=false
+