[tbb-commits] [tor-browser/tor-browser-38.2.1esr-5.5-2] fixup! Bug #4234: Use the Firefox Update Process for Tor Browser.

gk at torproject.org gk at torproject.org
Tue Sep 1 09:05:18 UTC 2015


commit 8882fd2ca86bc843060556b8126de75046a35f8f
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Tue Aug 25 11:03:21 2015 -0400

    fixup! Bug #4234: Use the Firefox Update Process for Tor Browser.
    
    Fixes #13512: After update, load a static tab with change notes.
    
    To use this feature, include the following attributes within the
    <update> element of each XML update manifest:
      actions="showURL" openURL="https://..."
    Within the URL, %OLD_VERSION% will be replaced with the previous
    Gecko version (e.g., 38.2.0) and %OLD_TOR_BROWSER_VERSION% will
    be replaced with the previous Tor Browser version (e.g., 5.5a1).
    
    Note that the "Update Installed" window that previously was
    displayed after an update is no longer opened.
---
 browser/app/profile/000-tor-browser.js        |    9 ++++-
 browser/app/profile/firefox.js                |    2 +-
 browser/components/nsBrowserContentHandler.js |   50 ++++++++++++++++++++++++-
 3 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/browser/app/profile/000-tor-browser.js b/browser/app/profile/000-tor-browser.js
index 5918a3e..b32728b 100644
--- a/browser/app/profile/000-tor-browser.js
+++ b/browser/app/profile/000-tor-browser.js
@@ -7,9 +7,14 @@
 // Disable initial homepage notifications
 pref("browser.search.update", false);
 pref("browser.rights.3.shown", true);
-pref("browser.startup.homepage_override.mstone", "ignore");
 pref("startup.homepage_welcome_url", "");
-pref("startup.homepage_override_url", "");
+
+// Set a generic, default URL that will be opened in a tab after an update.
+// Typically, this will not be used; instead, the <update> element within
+// each update manifest should contain attributes similar to:
+//   actions="showURL"
+//   openURL="https://blog.torproject.org/tor-browser-55a2-released"
+pref("startup.homepage_override_url", "https://blog.torproject.org/category/tags/tor-browser");
 
 // Try to nag a bit more about updates: Pop up a restart dialog an hour after the initial dialog
 pref("app.update.promptWaitTime", 3600);
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index 53fd8d2..7d9677a 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -190,7 +190,7 @@ pref("app.update.idletime", 60);
 // upgrade start page instead! Other apps may wish to show this UI, and supply
 // a whatsNewURL field in their brand.properties that contains a link to a page
 // which tells users what's new in this new update.
-pref("app.update.showInstalledUI", true);
+pref("app.update.showInstalledUI", false);
 
 // 0 = suppress prompting for incompatibilities if there are updates available
 //     to newer versions of installed addons that resolve them.
diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js
index 9ae384e..a3465a0 100644
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -43,6 +43,10 @@ const NS_ERROR_ABORT = Components.results.NS_ERROR_ABORT;
 const URI_INHERITS_SECURITY_CONTEXT = Components.interfaces.nsIHttpProtocolHandler
                                         .URI_INHERITS_SECURITY_CONTEXT;
 
+#ifdef TOR_BROWSER_VERSION
+const kTBSavedVersionPref = "browser.startup.homepage_override.torbrowser.version";
+#endif
+
 function shouldLoadURI(aURI) {
   if (aURI && !aURI.schemeIs("chrome"))
     return true;
@@ -94,7 +98,8 @@ const OVERRIDE_NEW_BUILD_ID = 3;
  * Returns:
  *  OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
  *  OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
- *                      Gecko milestone (i.e. right after an upgrade).
+ *                      Gecko milestone or Tor Browser version (i.e. right
+ *                      after an upgrade).
  *  OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
  *                        same Gecko milestone (i.e. after a nightly upgrade).
  *  OVERRIDE_NONE otherwise.
@@ -110,6 +115,15 @@ function needHomepageOverride(prefb) {
 
   var mstone = Services.appinfo.platformVersion;
 
+#ifdef TOR_BROWSER_VERSION
+#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__;
+
+  var savedTBVersion = null;
+  try {
+    savedTBVersion = prefb.getCharPref(kTBSavedVersionPref);
+  } catch (e) {}
+#endif
+
   var savedBuildID = null;
   try {
     savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID");
@@ -127,9 +141,30 @@ function needHomepageOverride(prefb) {
     
     prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
     prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
+#ifdef TOR_BROWSER_VERSION
+    prefb.setCharPref(kTBSavedVersionPref, TOR_BROWSER_VERSION);
+
+    // After an upgrade from an older release of Tor Browser (<= 5.5a1), the
+    // savedmstone will be undefined because those releases included the
+    // value "ignore" for the browser.startup.homepage_override.mstone pref.
+    // To correctly detect an upgrade vs. a new profile, we check for the
+    // presence of the "app.update.postupdate" pref.
+    var updated = prefb.prefHasUserValue("app.update.postupdate");
+    return (savedmstone || updated) ? OVERRIDE_NEW_MSTONE
+                                    : OVERRIDE_NEW_PROFILE;
+#else
     return (savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE);
+#endif
   }
 
+#ifdef TOR_BROWSER_VERSION
+  if (TOR_BROWSER_VERSION != savedTBVersion) {
+    prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
+    prefb.setCharPref(kTBSavedVersionPref, TOR_BROWSER_VERSION);
+    return OVERRIDE_NEW_MSTONE;
+  }
+#endif
+
   if (buildID != savedBuildID) {
     prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
     return OVERRIDE_NEW_BUILD_ID;
@@ -572,6 +607,15 @@ nsBrowserContentHandler.prototype = {
       try {
         old_mstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
       } catch (ex) {}
+
+#ifdef TOR_BROWSER_VERSION
+      // We do the same for the Tor Browser version.
+      var old_tbversion = null;
+      try {
+        old_tbversion = prefb.getCharPref(kTBSavedVersionPref);
+      } catch (e) {}
+#endif
+
       let override = needHomepageOverride(prefb);
       if (override != OVERRIDE_NONE) {
         switch (override) {
@@ -594,6 +638,10 @@ nsBrowserContentHandler.prototype = {
               overridePage = getPostUpdateOverridePage(overridePage);
 
             overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
+#ifdef TOR_BROWSER_VERSION
+            overridePage = overridePage.replace("%OLD_TOR_BROWSER_VERSION%",
+                                                old_tbversion);
+#endif
             break;
         }
       }



More information about the tbb-commits mailing list