Backed out changeset b84e23f32f81 (bug 943262) for causing bug 1003897. a=lsblakk
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 05 May 2014 17:23:53 -0400
changeset 258644 6b14de55b252
parent 258643 07e9f010bf08
child 258645 b14554c010ad
push id4700
push userryanvm@gmail.com
push date2015-04-21 23:53 +0000
treeherdermozilla-beta@d27c9211ebb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsblakk
bugs943262, 1003897
milestone29.0
backs outb84e23f32f81
Backed out changeset b84e23f32f81 (bug 943262) for causing bug 1003897. a=lsblakk
intl/uconv/tests/unit/test_bug713519.js
mobile/android/app/mobile.js
mobile/android/chrome/content/browser.js
mobile/android/locales/jar.mn
--- a/intl/uconv/tests/unit/test_bug713519.js
+++ b/intl/uconv/tests/unit/test_bug713519.js
@@ -11,9 +11,18 @@ function run_test() {
 
   try {
     svc.getCharsetAlias("no such thing");
     do_throw("Calling getCharsetAlias with invalid value should throw.");
   }
   catch (ex) {
     // The exception is expected.
   }
+
+  do_check_eq(svc.getCharsetTitle("windows-1255"), "Hebrew (Windows-1255)");
+  try {
+    svc.getCharsetTitle("no such thing");
+    do_throw("Calling getCharsetTitle with invalid value should throw.");
+  }
+  catch (ex) {
+    // The exception is expected.
+  }
 }
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -229,16 +229,17 @@ pref("accessibility.typeaheadfind.timeou
 pref("accessibility.typeaheadfind.flashBar", 1);
 pref("accessibility.typeaheadfind.linksonly", false);
 pref("accessibility.typeaheadfind.casesensitive", 0);
 pref("accessibility.browsewithcaret_shortcut.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");
+pref("intl.charsetmenu.browser.static", "chrome://browser/locale/browser.properties");
 
 // pointer to the default engine name
 pref("browser.search.defaultenginename", "chrome://browser/locale/region.properties");
 // SSL error page behaviour
 pref("browser.ssl_override_behavior", 2);
 pref("browser.xul.error_pages.expert_bad_cert", false);
 
 // disable logging for the search service by default
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -71,19 +71,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://shumway/ShumwayUtils.jsm");
 #endif
 
 #ifdef MOZ_ANDROID_SYNTHAPKS
 XPCOMUtils.defineLazyModuleGetter(this, "WebappManager",
                                   "resource://gre/modules/WebappManager.jsm");
 #endif
 
-XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
-                                  "resource://gre/modules/CharsetMenu.jsm");
-
 // Lazily-loaded browser scripts:
 [
   ["SelectHelper", "chrome://browser/content/SelectHelper.js"],
   ["InputWidgetHelper", "chrome://browser/content/InputWidgetHelper.js"],
   ["AboutReader", "chrome://browser/content/aboutReader.js"],
   ["MasterPassword", "chrome://browser/content/MasterPassword.js"],
   ["PluginHelper", "chrome://browser/content/PluginHelper.js"],
   ["OfflineApps", "chrome://browser/content/OfflineApps.js"],
@@ -247,17 +244,18 @@ function shouldShowProgress(url) {
 }
 
 /**
  * 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);
   });
 });
 
 const kFormHelperModeDisabled = 0;
@@ -6497,41 +6495,50 @@ var CharacterEncoding = {
 
     sendMessageToJava({
       type: "CharEncoding:State",
       visible: showCharEncoding
     });
   },
 
   getEncoding: function getEncoding() {
-    function infoToCharset(info) {
-      return { code: info.value, title: info.label };
+    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 data = CharsetMenu.getData();
-
-      // In the desktop UI, the pinned charsets are shown above the rest.
-      let pinnedCharsets = data.pinnedCharsets.map(infoToCharset);
-      let otherCharsets = data.otherCharsets.map(infoToCharset)
-
-      this._charsets = pinnedCharsets.concat(otherCharsets);
-    }
-
-    // Look for the index of the selected charset. Default to -1 if the
-    // doc charset isn't found in the list of available charsets.
-    let docCharset = BrowserApp.selectedBrowser.contentDocument.characterSet;
-    let selected = -1;
+      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 (let i = 0; i < charsetCount; i++) {
-      if (this._charsets[i].code === docCharset) {
-        selected = i;
-        break;
-      }
+    for (; selected < charsetCount && this._charsets[selected].code != docCharset; selected++);
+    if (selected == charsetCount) {
+      this._charsets.push({
+        code: docCharset,
+        title: getTitle(docCharset)
+      });
     }
 
     sendMessageToJava({
       type: "CharEncoding:Data",
       charsets: this._charsets,
       selected: selected
     });
   },
--- a/mobile/android/locales/jar.mn
+++ b/mobile/android/locales/jar.mn
@@ -81,18 +81,20 @@ relativesrcdir toolkit/locales:
 % override chrome://global/locale/crashes.dtd chrome://browser/locale/overrides/crashreporter/crashes.dtd
 % override chrome://global/locale/crashes.properties chrome://browser/locale/overrides/crashreporter/crashes.properties
 % override chrome://global/locale/mozilla.dtd chrome://browser/locale/overrides/global/mozilla.dtd
 % override chrome://global/locale/aboutTelemetry.dtd chrome://browser/locale/overrides/global/aboutTelemetry.dtd
 % override chrome://global/locale/aboutTelemetry.properties chrome://browser/locale/overrides/global/aboutTelemetry.properties
 
 # overrides for dom l10n, also for en-US
 relativesrcdir dom/locales:
+  locale/@AB_CD@/browser/overrides/charsetTitles.properties    (%chrome/charsetTitles.properties)
   locale/@AB_CD@/browser/overrides/global.dtd                  (%chrome/global.dtd)
   locale/@AB_CD@/browser/overrides/AccessFu.properties         (%chrome/accessibility/AccessFu.properties)
   locale/@AB_CD@/browser/overrides/dom/dom.properties          (%chrome/dom/dom.properties)
 #about:plugins
   locale/@AB_CD@/browser/overrides/plugins.properties          (%chrome/plugins.properties)
 
+% override chrome://global/locale/charsetTitles.properties chrome://browser/locale/overrides/charsetTitles.properties
 % override chrome://global/locale/global.dtd chrome://browser/locale/overrides/global.dtd
 % override chrome://global/locale/AccessFu.properties chrome://browser/locale/overrides/AccessFu.properties
 % override chrome://global/locale/dom/dom.properties chrome://browser/locale/overrides/dom/dom.properties
 % override chrome://global/locale/plugins.properties chrome://browser/locale/overrides/plugins.properties