Bug 947507 - [Holly] Limit the charset detector pref to values available from the UI. r=dao,emk, a=lsblakk.
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 19 Dec 2013 18:07:12 +0200
changeset 175454 6395885b7e0e40e3e5a70c150a6ba1bf5be930ea
parent 175453 1be80da4f90d90596c33b9267a449daf09d8cf8d
child 175455 f9ab4c85e196f8b4f22d04e52765430b94aee592
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao, emk, lsblakk
bugs947507
milestone28.0a2
Bug 947507 - [Holly] Limit the charset detector pref to values available from the UI. r=dao,emk, a=lsblakk.
browser/components/nsBrowserGlue.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1284,30 +1284,46 @@ BrowserGlue.prototype = {
     var notifyBox = win.gBrowser.getNotificationBox();
     var notification = notifyBox.appendNotification(text, title, null,
                                                     notifyBox.PRIORITY_CRITICAL_MEDIUM,
                                                     buttons);
     notification.persistence = -1; // Until user closes it
   },
 
   _migrateUI: function BG__migrateUI() {
-    const UI_VERSION = 14;
+    const UI_VERSION = 15;
     const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
 
     let wasCustomizedAndOnAustralis = Services.prefs.prefHasUserValue("browser.uiCustomization.state");
     let currentUIVersion = 0;
     try {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } catch(ex) {}
     if (!wasCustomizedAndOnAustralis && currentUIVersion >= UI_VERSION)
       return;
 
     this._rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
     this._dataSource = this._rdf.GetDataSource("rdf:local-store");
 
+    function migrateDetector() {
+      let detector = null;    
+      try {
+        detector = Services.prefs.getComplexValue("intl.charset.detector",
+                                                  Ci.nsIPrefLocalizedString).data;
+      } catch (ex) {}
+      if (!(detector == "" ||
+            detector == "ja_parallel_state_machine" ||
+            detector == "ruprob" ||
+            detector == "ukprob")) {
+        // If the encoding detector pref value is not reachable from the UI,
+        // reset to default (varies by localization).
+        Services.prefs.clearUserPref("intl.charset.detector");
+      }
+    }
+
     // No version check for this as this code should run until we have Australis everywhere:
     if (wasCustomizedAndOnAustralis) {
       // This profile's been on australis! If it's missing the back/fwd button
       // or go/stop/reload button, then put them back:
       let currentsetResource = this._rdf.GetResource("currentset");
       let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
       let currentset = this._getPersist(toolbarResource, currentsetResource);
       let oldCurrentset = currentset;
@@ -1323,16 +1339,21 @@ BrowserGlue.prototype = {
           currentset = currentset.replace("reload-button", "reload-button,stop-button");
         }
       }
       Services.prefs.clearUserPref("browser.uiCustomization.state");
 
       if (oldCurrentset != currentset) {
         this._setPersist(toolbarResource, currentsetResource, currentset);
       }
+
+      // Taking the opportunity to do the version 15 action here as well to
+      // address profiles that have been on Australis.
+      migrateDetector();
+
       // If we don't have anything else to do, we can bail here:
       if (currentUIVersion >= UI_VERSION) {
         if (this._dirty) {
           this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
         }
         delete this._rdf;
         delete this._dataSource;
         return;
@@ -1518,16 +1539,24 @@ BrowserGlue.prototype = {
 
     if (currentUIVersion < 14) {
       // DOM Storage doesn't specially handle about: pages anymore.
       let path = OS.Path.join(OS.Constants.Path.profileDir,
                               "chromeappsstore.sqlite");
       OS.File.remove(path);
     }
 
+    // Reusing the version 15, which is no longer in use on m-c, on Holly.
+    // This fails if the user has used Australis with this profile without
+    // customization and then gone back no the non-Australis version stream.
+    // However, the situation will fix itself once Australis reaches the user.
+    if (currentUIVersion < 15) {
+      migrateDetector();
+    }
+
     if (this._dirty)
       this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
 
     delete this._rdf;
     delete this._dataSource;
 
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);