Bug 701824 - "Show character encoding" (Text encoding) preference should be hooked up. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 23 Jan 2012 13:47:48 -0800
changeset 86366 735345948d326c50f68c308cf600f707c5a4c3b9
parent 86365 ca8cb417520c71e2eed541c0696ff850dbabb684
child 86367 850ce7c81121f7731719449c974da81ee333a11f
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs701824
milestone12.0a1
Bug 701824 - "Show character encoding" (Text encoding) preference should be hooked up. r=mfinkle
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoPreferences.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/resources/layout/gecko_menu.xml
mobile/android/base/resources/values/arrays.xml
mobile/android/base/resources/xml/preferences.xml
mobile/android/base/strings.xml.in
mobile/android/chrome/content/browser.js
mobile/android/locales/en-US/chrome/browser.properties
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -435,16 +435,17 @@ abstract public class GeckoApp
             aMenu.findItem(R.id.settings).setEnabled(false);
 
         Tab tab = Tabs.getInstance().getSelectedTab();
         MenuItem bookmark = aMenu.findItem(R.id.bookmark);
         MenuItem forward = aMenu.findItem(R.id.forward);
         MenuItem share = aMenu.findItem(R.id.share);
         MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
         MenuItem downloads = aMenu.findItem(R.id.downloads);
+        MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
 
         if (tab == null) {
             bookmark.setEnabled(false);
             forward.setEnabled(false);
             share.setEnabled(false);
             saveAsPDF.setEnabled(false);
             return true;
         }
@@ -471,16 +472,18 @@ abstract public class GeckoApp
         // Disable save as PDF for about:home and xul pages
         saveAsPDF.setEnabled(!(tab.getURL().equals("about:home") ||
                                tab.getContentType().equals("application/vnd.mozilla.xul+xml")));
 
         // DownloadManager support is tied to level 12 and higher
         if (Build.VERSION.SDK_INT < 12)
             downloads.setVisible(false);
 
+        charEncoding.setVisible(GeckoPreferences.getCharEncodingState());
+
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         Tab tab = null;
         Intent intent = null;
         switch (item.getItemId()) {
@@ -533,16 +536,19 @@ abstract public class GeckoApp
                 return true;
             case R.id.addons:
                 loadUrlInTab("about:addons");
                 return true;
             case R.id.downloads:
                 intent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
                 startActivity(intent);
                 return true;
+            case R.id.char_encoding:
+                GeckoAppShell.sendEventToGecko(new GeckoEvent("CharEncoding:Get", null));
+                return true;
             default:
                 return super.onOptionsItemSelected(item);
         }
     }
 
     public String getLastViewport() {
         return mLastViewport;
     }
@@ -980,16 +986,61 @@ abstract public class GeckoApp
                 showSiteSettingsDialog(host, permissions);
             } else if (event.equals("Downloads:Done")) {
                 String displayName = message.getString("displayName");
                 String path = message.getString("path");
                 String mimeType = message.getString("mimeType");
                 int size = message.getInt("size");
 
                 handleDownloadDone(displayName, path, mimeType, size);
+            } else if (event.equals("CharEncoding:Data")) {
+                final JSONArray charsets = message.getJSONArray("charsets");
+                int selected = message.getInt("selected");
+
+                final int len = charsets.length();
+                final String[] titleArray = new String[len];
+                for (int i = 0; i < len; i++) {
+                    JSONObject charset = charsets.getJSONObject(i);
+                    titleArray[i] = charset.getString("title");
+                }
+
+                final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
+                dialogBuilder.setSingleChoiceItems(titleArray, selected, new AlertDialog.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        try {
+                            JSONObject charset = charsets.getJSONObject(which);
+                            GeckoAppShell.sendEventToGecko(new GeckoEvent("CharEncoding:Set", charset.getString("code")));
+                            dialog.dismiss();
+                        } catch (JSONException e) {
+                            Log.e(LOGTAG, "error parsing json", e);
+                        }
+                    }
+                });
+                dialogBuilder.setNegativeButton(R.string.button_cancel, new AlertDialog.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.dismiss();
+                    }
+                });
+                mMainHandler.post(new Runnable() {
+                    public void run() {
+                        dialogBuilder.show();
+                    }
+                });
+            } else if (event.equals("CharEncoding:State")) {
+                final boolean visible = message.getString("visible").equals("true");
+                GeckoPreferences.setCharEncodingState(visible);
+                if (sMenu != null) {
+                    mMainHandler.post(new Runnable() {
+                        public void run() {
+                            sMenu.findItem(R.id.char_encoding).setVisible(visible);
+                        }
+                    });
+                }
             }
         } catch (Exception e) {
             Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
         }
     }
 
     public void showAboutHome() {
         Runnable r = new AboutHomeRunnable(true);
@@ -1593,16 +1644,18 @@ abstract public class GeckoApp
         GeckoAppShell.registerGeckoEventListener("Menu:Remove", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Gecko:Ready", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Toast:Show", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("FormAssist:AutoComplete", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Permissions:Data", GeckoApp.mAppContext);
         GeckoAppShell.registerGeckoEventListener("Downloads:Done", GeckoApp.mAppContext);
+        GeckoAppShell.registerGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext);
+        GeckoAppShell.registerGeckoEventListener("CharEncoding:State", GeckoApp.mAppContext);
 
         mConnectivityFilter = new IntentFilter();
         mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
         mConnectivityReceiver = new GeckoConnectivityReceiver();
 
         IntentFilter batteryFilter = new IntentFilter();
         batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
         mBatteryReceiver = new GeckoBatteryManager();
@@ -1921,16 +1974,18 @@ abstract public class GeckoApp
         GeckoAppShell.unregisterGeckoEventListener("Menu:Remove", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Gecko:Ready", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Toast:Show", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Hide", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("ToggleChrome:Show", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("FormAssist:AutoComplete", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Permissions:Data", GeckoApp.mAppContext);
         GeckoAppShell.unregisterGeckoEventListener("Downloads:Done", GeckoApp.mAppContext);
+        GeckoAppShell.unregisterGeckoEventListener("CharEncoding:Data", GeckoApp.mAppContext);
+        GeckoAppShell.unregisterGeckoEventListener("CharEncoding:State", GeckoApp.mAppContext);
 
         mFavicons.close();
 
         if (SmsManager.getInstance() != null) {
           SmsManager.getInstance().shutdown();
         }
 
         GeckoNetworkManager.getInstance().stop();
--- a/mobile/android/base/GeckoPreferences.java
+++ b/mobile/android/base/GeckoPreferences.java
@@ -68,16 +68,17 @@ import org.json.JSONObject;
 public class GeckoPreferences
     extends PreferenceActivity
     implements OnPreferenceChangeListener, GeckoEventListener
 {
     private static final String LOGTAG = "GeckoPreferences";
 
     private ArrayList<String> mPreferencesList = new ArrayList<String>();
     private PreferenceScreen mPreferenceScreen;
+    private static boolean sIsCharEncodingEnabled = false;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (Build.VERSION.SDK_INT >= 11)
             new GeckoActionBar().setDisplayHomeAsUpEnabled(this, true);
 
@@ -135,22 +136,32 @@ public class GeckoPreferences
         }
 
         return super.onOptionsItemSelected(item);
     }
 
     final private int DIALOG_CREATE_MASTER_PASSWORD = 0;
     final private int DIALOG_REMOVE_MASTER_PASSWORD = 1;
 
+    public static void setCharEncodingState(boolean enabled) {
+        sIsCharEncodingEnabled = enabled;
+    }
+
+    public static boolean getCharEncodingState() {
+        return sIsCharEncodingEnabled;
+    }
+
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         String prefName = preference.getKey();
         if (prefName != null && prefName.equals("privacy.masterpassword.enabled")) {
             showDialog((Boolean)newValue ? DIALOG_CREATE_MASTER_PASSWORD : DIALOG_REMOVE_MASTER_PASSWORD);
             return false;
+        } else if (prefName != null && prefName.equals("browser.menu.showCharacterEncoding")) {
+            setCharEncodingState(((String) newValue).equals("true"));
         }
 
         setPreference(prefName, newValue);
         if (preference instanceof ListPreference) {
             // We need to find the entry for the new value
             int newIndex = ((ListPreference)preference).findIndexOfValue((String) newValue);
             CharSequence newEntry = ((ListPreference)preference).getEntries()[newIndex];
             ((ListPreference)preference).setSummary(newEntry);
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -46,17 +46,19 @@
 <!ENTITY pref_category_general "General">
 <!ENTITY pref_category_privacy "Privacy &amp; Security">
 <!ENTITY pref_category_content "Content">
 <!ENTITY pref_about_firefox "About &brandShortName;">
 <!ENTITY pref_do_not_track "Tell sites not to track me">
 <!ENTITY pref_telemetry "Send performance data">
 <!ENTITY pref_remember_signons "Remember passwords">
 <!ENTITY pref_cookies "Enable cookies">
-<!ENTITY pref_char_encoding "Show character encoding">
+<!ENTITY pref_char_encoding "Character encoding">
+<!ENTITY pref_char_encoding_on "Show menu">
+<!ENTITY pref_char_encoding_off "Don\'t show menu">
 <!ENTITY pref_clear_history "Clear history">
 <!ENTITY pref_clear_history_confirm "Browsing history will be deleted">
 <!ENTITY pref_clear_private_data "Clear private data">
 <!ENTITY pref_clear_private_data_confirm "Browsing settings, including passwords and cookies, will be deleted">
 <!ENTITY pref_plugins "Plugins">
 <!ENTITY pref_plugins_enabled "Enabled">
 <!ENTITY pref_plugins_tap_to_play "Tap to play">
 <!ENTITY pref_plugins_disabled "Disabled">
@@ -67,16 +69,17 @@
 <!ENTITY pref_font_size_large "Large">
 <!ENTITY pref_font_size_xlarge "Extra Large">
 <!ENTITY pref_use_master_password "Use master password">
 
 <!ENTITY quit "Quit">
 
 <!ENTITY addons "Add-ons">
 <!ENTITY downloads "Downloads">
+<!ENTITY char_encoding "Character Encoding">
 
 <!ENTITY share "Share">
 <!ENTITY save_as_pdf "Save as PDF">
 
 <!ENTITY contextmenu_open_new_tab "Open in New Tab">
 <!ENTITY contextmenu_remove_bookmark "Remove">
 <!ENTITY contextmenu_add_to_launcher "Add to Home Screen">
 <!ENTITY contextmenu_share "Share">
--- a/mobile/android/base/resources/layout/gecko_menu.xml
+++ b/mobile/android/base/resources/layout/gecko_menu.xml
@@ -25,14 +25,18 @@
           android:title="@string/site_settings_title" />
 
     <item android:id="@+id/addons"
           android:title="@string/addons"/>
 
     <item android:id="@+id/downloads"
           android:title="@string/downloads"/>
 
+    <item android:id="@+id/char_encoding"
+          android:visible="false"
+          android:title="@string/char_encoding"/>
+
     <item android:id="@+id/settings"
           android:title="@string/settings" />
 
     <item android:id="@+id/quit"
           android:title="@string/quit" />
 </menu>
--- a/mobile/android/base/resources/values/arrays.xml
+++ b/mobile/android/base/resources/values/arrays.xml
@@ -20,9 +20,17 @@
     </string-array>
     <string-array name="pref_font_size_values">
         <item>0</item>
         <item>80</item>
         <item>120</item>
         <item>160</item>
         <item>240</item>
     </string-array>
+    <string-array name="pref_char_encoding_entries">
+        <item>@string/pref_char_encoding_on</item>
+        <item>@string/pref_char_encoding_off</item>
+    </string-array>
+    <string-array name="pref_char_encoding_values">
+        <item>true</item>
+        <item>false</item>
+    </string-array>
 </resources>
--- a/mobile/android/base/resources/xml/preferences.xml
+++ b/mobile/android/base/resources/xml/preferences.xml
@@ -10,18 +10,20 @@
         <!-- TODO: Default Search Engine -->
 
         <!-- TODO: Sync -->
 
     </PreferenceCategory>
 
     <PreferenceCategory android:title="@string/pref_category_content">
 
-        <CheckBoxPreference android:key="browser.menu.showCharacterEncoding"
+        <ListPreference     android:key="browser.menu.showCharacterEncoding"
                             android:title="@string/pref_char_encoding"
+                            android:entries="@array/pref_char_encoding_entries"
+                            android:entryValues="@array/pref_char_encoding_values"
                             android:persistent="false" />
 
         <ListPreference     android:key="plugin.enable"
                             android:title="@string/pref_plugins"
                             android:entries="@array/pref_plugins_entries"
                             android:entryValues="@array/pref_plugins_values"
                             android:persistent="false" />
 
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -53,16 +53,18 @@
   <string name="pref_category_privacy">&pref_category_privacy;</string>
   <string name="pref_category_content">&pref_category_content;</string>
   <string name="pref_about_firefox">&pref_about_firefox;</string>
   <string name="pref_do_not_track">&pref_do_not_track;</string>
   <string name="pref_telemetry">&pref_telemetry;</string>
   <string name="pref_remember_signons">&pref_remember_signons;</string>
   <string name="pref_cookies">&pref_cookies;</string>
   <string name="pref_char_encoding">&pref_char_encoding;</string>
+  <string name="pref_char_encoding_on">&pref_char_encoding_on;</string>
+  <string name="pref_char_encoding_off">&pref_char_encoding_off;</string>
   <string name="pref_clear_history">&pref_clear_history;</string>
   <string name="pref_clear_history_confirm">&pref_clear_history_confirm;</string>
   <string name="pref_clear_private_data">&pref_clear_private_data;</string>
   <string name="pref_clear_private_data_confirm">&pref_clear_private_data_confirm;</string>
   <string name="pref_plugins">&pref_plugins;</string>
   <string name="pref_plugins_enabled">&pref_plugins_enabled;</string>
   <string name="pref_plugins_tap_to_play">&pref_plugins_tap_to_play;</string>
   <string name="pref_plugins_disabled">&pref_plugins_disabled;</string>
@@ -73,16 +75,17 @@
   <string name="pref_font_size_large">&pref_font_size_large;</string>
   <string name="pref_font_size_xlarge">&pref_font_size_xlarge;</string>
 
   <string name="reload">&reload;</string>
   <string name="forward">&forward;</string>
   <string name="new_tab">&new_tab;</string>
   <string name="addons">&addons;</string>
   <string name="downloads">&downloads;</string>
+  <string name="char_encoding">&char_encoding;</string>
 
   <string name="site_settings_title">&site_settings_title;</string>
   <string name="site_settings_cancel">&site_settings_cancel;</string>
   <string name="site_settings_clear">&site_settings_clear;</string>
   <string name="site_settings_no_settings">&site_settings_no_settings;</string>
 
   <string name="contextmenu_open_new_tab">&contextmenu_open_new_tab;</string>
   <string name="contextmenu_remove_bookmark">&contextmenu_remove_bookmark;</string>
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -141,17 +141,18 @@ function resolveGeckoURI(aURI) {
 }
 
 /**
  * Cache of commonly used string bundles.
  */
 var Strings = {};
 [
   ["brand",      "chrome://branding/locale/brand.properties"],
-  ["browser",    "chrome://browser/locale/browser.properties"]
+  ["browser",    "chrome://browser/locale/browser.properties"],
+  ["charset",    "chrome://global/locale/charsetTitles.properties"]
 ].forEach(function (aStringBundle) {
   let [name, bundle] = aStringBundle;
   XPCOMUtils.defineLazyGetter(Strings, name, function() {
     return Services.strings.createBundle(bundle);
   });
 });
 
 var MetadataProvider = {
@@ -247,16 +248,17 @@ var BrowserApp = {
     Downloads.init();
     FormAssistant.init();
     OfflineApps.init();
     IndexedDB.init();
     XPInstallObserver.init();
     ConsoleAPI.init();
     ClipboardHelper.init();
     PermissionsHelper.init();
+    CharacterEncoding.init();
 
     // Init LoginManager
     Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
     // Init FormHistory
     Cc["@mozilla.org/satchel/form-history;1"].getService(Ci.nsIFormHistory2);
 
     let url = "about:home";
     let restoreSession = false;
@@ -352,16 +354,17 @@ var BrowserApp = {
   shutdown: function shutdown() {
     NativeWindow.uninit();
     FormAssistant.uninit();
     OfflineApps.uninit();
     IndexedDB.uninit();
     ViewportHandler.uninit();
     XPInstallObserver.uninit();
     ConsoleAPI.uninit();
+    CharacterEncoding.uninit();
   },
 
   get tabs() {
     return this._tabs;
   },
 
   get selectedTab() {
     return this._selectedTab;
@@ -633,20 +636,16 @@ var BrowserApp = {
         // indicating enabled/disabled. since the java ui uses the type to
         // determine which ui elements to show, we need to normalize these
         // preferences to be actual booleans.
         switch (prefName) {
           case "network.cookie.cookieBehavior":
             pref.type = "bool";
             pref.value = pref.value == 0;
             break;
-          case "browser.menu.showCharacterEncoding":
-            pref.type = "bool";
-            pref.value = pref.value == "true";
-            break;
           case "font.size.inflation.minTwips":
             pref.type = "string";
             pref.value = pref.value.toString();
             break;
         }
 
         prefs.push(pref);
       }
@@ -678,20 +677,16 @@ var BrowserApp = {
     // when sending to java, we normalized special preferences that use
     // integers and strings to represent booleans.  here, we convert them back
     // to their actual types so we can store them.
     switch (json.name) {
       case "network.cookie.cookieBehavior":
         json.type = "int";
         json.value = (json.value ? 0 : 2);
         break;
-      case "browser.menu.showCharacterEncoding":
-        json.type = "string";
-        json.value = (json.value ? "true" : "false");
-        break;
       case "font.size.inflation.minTwips":
         json.type = "int";
         json.value = parseInt(json.value);
         break;
     }
 
     if (json.type == "bool")
       Services.prefs.setBoolPref(json.name, json.value);
@@ -3814,17 +3809,17 @@ var PermissionsHelper = {
       // Re-set login saving to enabled
       Services.logins.setLoginSavingEnabled(aURI.prePath, true);
     } else {
       Services.perms.remove(aURI.host, aType);
       // Clear content prefs set in ContentPermissionPrompt.js
       Services.contentPrefs.removePref(aURI, aType + ".request.remember");
     }
   }
-}
+};
 
 var MasterPassword = {
   pref: "privacy.masterpassword.enabled",
   _tokenName: "",
 
   get _secModuleDB() {
     delete this._secModuleDB;
     return this._secModuleDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].getService(Ci.nsIPKCS11ModuleDB);
@@ -3894,9 +3889,104 @@ var MasterPassword = {
 
     sendMessageToJava({
       gecko: {
         type: "Preferences:Data",
         preferences: prefs
       }
     });
   }
-}
+};
+
+var CharacterEncoding = {
+  _charsets: [],
+
+  init: function init() {
+    Services.obs.addObserver(this, "CharEncoding:Get", false);
+    Services.obs.addObserver(this, "CharEncoding:Set", false);
+    this.sendState();
+  },
+
+  uninit: function uninit() {
+    Services.obs.removeObserver(this, "CharEncoding:Get", false);
+    Services.obs.removeObserver(this, "CharEncoding:Set", false);
+  },
+
+  observe: function observe(aSubject, aTopic, aData) {
+    switch (aTopic) {
+      case "CharEncoding:Get":
+        this.getEncoding();
+        break;
+      case "CharEncoding:Set":
+        this.setEncoding(aData);
+        break;
+    }
+  },
+
+  sendState: function sendState() {
+    let showCharEncoding = "false";
+    try {
+      showCharEncoding = Services.prefs.getComplexValue("browser.menu.showCharacterEncoding", Ci.nsIPrefLocalizedString).data;
+    } catch (e) { /* Optional */ }
+
+    sendMessageToJava({
+      gecko: {
+        type: "CharEncoding:State",
+        visible: showCharEncoding
+      }
+    });
+  },
+
+  getEncoding: function getEncoding() {
+    function normalizeCharsetCode(charsetCode) {
+      return charsetCode.trim().toLowerCase();
+    }
+
+    function getTitle(charsetCode) {
+      let charsetTitle = charsetCode;
+      try {
+        charsetTitle = Strings.charset.GetStringFromName(charsetCode + ".title");
+      } catch (e) {
+        dump("error: title not found for " + charsetCode);
+      }
+      return charsetTitle;
+    }
+
+    if (!this._charsets.length) {
+      let charsets = Services.prefs.getComplexValue("intl.charsetmenu.browser.static", Ci.nsIPrefLocalizedString).data;
+      this._charsets = charsets.split(",").map(function (charset) {
+        return {
+          code: normalizeCharsetCode(charset),
+          title: getTitle(charset)
+        };
+      });
+    }
+
+    // if document charset is not in charset options, add it
+    let docCharset = normalizeCharsetCode(BrowserApp.selectedBrowser.contentDocument.characterSet);
+    let selected = 0;
+    let charsetCount = this._charsets.length;
+    for (; selected < charsetCount && this._charsets[selected].code != docCharset; selected++);
+    if (selected == charsetCount) {
+      this._charsets.push({
+        code: docCharset,
+        title: getTitle(docCharset)
+      });
+    }
+
+    sendMessageToJava({
+      gecko: {
+        type: "CharEncoding:Data",
+        charsets: this._charsets,
+        selected: selected
+      }
+    });
+  },
+
+  setEncoding: function setEncoding(aEncoding) {
+    let browser = BrowserApp.selectedBrowser;
+    let docCharset = browser.docShell.QueryInterface(Ci.nsIDocCharset);
+    docCharset.charset = aEncoding;
+    browser.reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
+  },
+
+};
+
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -167,17 +167,17 @@ clearPrivateData.message=Delete your bro
 # Encoding" menu in the site menu. Any other value will hide it. Without this
 # setting, the "Character Encoding" menu must be enabled via Preferences.
 # This is not a string to translate. If users frequently use the "Character Encoding"
 # menu, set this to "true". Otherwise, you can leave it as "false".
 browser.menu.showCharacterEncoding=false
 
 # LOCALIZATION NOTE (intl.charsetmenu.browser.static): Set to a series of comma separated
 # values for charsets that the user can select from in the Character Encoding menu.
-intl.charsetmenu.browser.static=iso-8859-1,utf-8,x-gbk,big5,iso-2022-jp,shift_jis,euc-jp
+intl.charsetmenu.browser.static=iso-8859-1,utf-8,big5,iso-2022-jp,shift_jis,euc-jp
 
 # Application Menu
 appMenu.more=More
 
 # Text Selection
 selectionHelper.textCopied=Text copied to clipboard
 
 # Context menu