[tbb-commits] [torbutton/master] Bug 29440: Update about:tor when Tor Browser is updated

gk at torproject.org gk at torproject.org
Wed Mar 13 15:18:30 UTC 2019


commit 82a5f8665a6b5a7f5d4c78f0a526dfa16834ec7f
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Mon Mar 11 11:28:20 2019 -0400

    Bug 29440: Update about:tor when Tor Browser is updated
    
    After the browser has been updated, notify the user by displaying
    a message on the about:tor page. Also, in release and alpha builds,
    include on the about:tor page below the Tor Browser version a link
    to a simplified changelog page (which continues to be located at
    about:tbupdate).
---
 src/chrome/content/aboutTor/aboutTor-content.js | 15 +++++++++--
 src/chrome/content/aboutTor/aboutTor.xhtml      | 16 +++++++++---
 src/chrome/content/torbutton.js                 | 30 +++++++++++++++++++---
 src/chrome/locale/en-US/aboutTBUpdate.dtd       |  6 +++--
 src/chrome/locale/en-US/aboutTor.dtd            |  2 ++
 src/chrome/skin/aboutTor.css                    | 33 ++++++++++++++++---------
 6 files changed, 79 insertions(+), 23 deletions(-)

diff --git a/src/chrome/content/aboutTor/aboutTor-content.js b/src/chrome/content/aboutTor/aboutTor-content.js
index b91fd17d..2b65dbcf 100644
--- a/src/chrome/content/aboutTor/aboutTor-content.js
+++ b/src/chrome/content/aboutTor/aboutTor-content.js
@@ -94,6 +94,17 @@ var AboutTorListener = {
     else
       body.removeAttribute("showmanual");
 
+    if (aData.updateChannel)
+      body.setAttribute("updatechannel", aData.updateChannel);
+    else
+      body.removeAttribute("updatechannel");
+
+    if (aData.hasBeenUpdated) {
+      body.setAttribute("hasbeenupdated", "yes");
+      content.document.getElementById("update-infolink").setAttribute("href",
+                                                      aData.updateMoreInfoURL);
+    }
+
     if (aData.mobile)
       body.setAttribute("mobile", "yes");
 
@@ -114,11 +125,11 @@ var AboutTorListener = {
                           .createBundle(kBrandBundle);
       let productName = brandBundle.GetStringFromName("brandFullName");
       let tbbVersion = Services.prefs.getCharPref("torbrowser.version");
-      elem = content.document.getElementById("torstatus-version");
+      let elem = content.document.getElementById("torbrowser-version");
 
       while (elem.firstChild)
         elem.removeChild(elem.firstChild);
-      elem.appendChild(content.document.createTextNode(productName + '\n'
+      elem.appendChild(content.document.createTextNode(productName + ' '
                        + tbbVersion));
     } catch (e) {}
   }
diff --git a/src/chrome/content/aboutTor/aboutTor.xhtml b/src/chrome/content/aboutTor/aboutTor.xhtml
index 639c2fca..0789f851 100644
--- a/src/chrome/content/aboutTor/aboutTor.xhtml
+++ b/src/chrome/content/aboutTor/aboutTor.xhtml
@@ -14,6 +14,8 @@
   %globalDTD;
   <!ENTITY % aboutTorDTD SYSTEM "chrome://torbutton/locale/aboutTor.dtd">
   %aboutTorDTD;
+  <!ENTITY % tbUpdateDTD SYSTEM "chrome://browser/locale/aboutTBUpdate.dtd">
+  %tbUpdateDTD;
 ]>
 
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -33,15 +35,23 @@ window.addEventListener("pageshow", function() {
 </head>
 <body dir="&locale.dir;">
   <div class="torcontent-container">
-    <div id="torstatus-version"/>
+    <div id="torbrowser-info">
+      <div id="torbrowser-version"/>
+      <div id="torbrowser-changelog-link"><a href="about:tbupdate">&aboutTor.viewChangelog.label;</a></div>
+    </div>
     <img class="torcontent-logo" src="resource://torbutton-assets/torbrowser_mobile_logo.png"/>
     <div id="torstatus" class="top">
-      <div id="torstatus-on-container" class="hideIfTorOff torstatus-container">
+      <div class="hideIfTorOff hideIfHasBeenUpdated torstatus-container">
         <div class="heading1">&aboutTor.ready.label;</div>
         <br/>
         <div class="heading2">&aboutTor.ready2.label;</div>
       </div>
-      <div id="torstatus-off-container" class="hideIfTorOn torstatus-container">
+      <div class="showIfHasBeenUpdated torstatus-container">
+        <div class="heading1">&aboutTBUpdate.updated;</div>
+        <br/>
+        <div class="heading2">&aboutTBUpdate.linkPrefix;<a id="update-infolink">&aboutTBUpdate.linkLabel;</a>&aboutTBUpdate.linkSuffix;</div>
+      </div>
+      <div class="hideIfTorOn torstatus-container">
         <div class="heading1">&aboutTor.failure.label;</div>
         <br/>
         <div class="heading2">&aboutTor.failure2.label;</div>
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index f99be5b0..b425a276 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -8,6 +8,7 @@
 //       http://kb.mozillazine.org/Links_to_local_pages_don%27t_work
 
 let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 let { showDialog, show_torbrowser_manual } = Cu.import("resource://torbutton/modules/utils.js", {});
 let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {});
 let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {});
@@ -418,7 +419,7 @@ var torbutton_abouttor_message_handler = {
     switch(aMessage.name) {
       case "AboutTor:Loaded":
         aMessage.target.messageManager.sendAsyncMessage("AboutTor:ChromeData",
-                                                        this.chromeData);
+                                                    this.getChromeData(true));
         break;
     }
   },
@@ -426,7 +427,7 @@ var torbutton_abouttor_message_handler = {
   // Send privileged data to all of the about:tor content scripts.
   updateAllOpenPages: function() {
     window.messageManager.broadcastAsyncMessage("AboutTor:ChromeData",
-                                                this.chromeData);
+                                                this.getChromeData(false));
   },
 
   // The chrome data contains all of the data needed by the about:tor
@@ -434,11 +435,32 @@ var torbutton_abouttor_message_handler = {
   // It is sent to the content process when an about:tor window is opened
   // and in response to events such as the browser noticing that Tor is
   // not working.
-  get chromeData() {
-    return {
+  getChromeData: function(aIsRespondingToPageLoad) {
+    let dataObj = {
       mobile: torbutton_is_mobile(),
+      updateChannel: AppConstants.MOZ_UPDATE_CHANNEL,
       torOn: torbutton_tor_check_ok()
     };
+
+    if (aIsRespondingToPageLoad) {
+      const kShouldNotifyPref = "torbrowser.post_update.shouldNotify";
+      if (m_tb_prefs.getBoolPref(kShouldNotifyPref, false)) {
+        m_tb_prefs.clearUserPref(kShouldNotifyPref);
+        dataObj.hasBeenUpdated = true;
+        dataObj.updateMoreInfoURL = this.getUpdateMoreInfoURL();
+      }
+    }
+
+    return dataObj;
+  },
+
+  getUpdateMoreInfoURL: function() {
+    try {
+      return Services.prefs.getCharPref("torbrowser.post_update.url");
+    } catch (e) {}
+
+    // Use the default URL as a fallback.
+    return Services.urlFormatter.formatURLPref("startup.homepage_override_url");
   }
 };
 
diff --git a/src/chrome/locale/en-US/aboutTBUpdate.dtd b/src/chrome/locale/en-US/aboutTBUpdate.dtd
index 37567bd7..2d1e59b4 100644
--- a/src/chrome/locale/en-US/aboutTBUpdate.dtd
+++ b/src/chrome/locale/en-US/aboutTBUpdate.dtd
@@ -1,6 +1,8 @@
-<!ENTITY aboutTBUpdate.title "Tor Browser Update">
+<!ENTITY aboutTBUpdate.changelogTitle "Tor Browser Changelog">
 <!ENTITY aboutTBUpdate.updated "Tor Browser has been updated.">
 <!ENTITY aboutTBUpdate.linkPrefix "For the most up-to-date information about this release, ">
 <!ENTITY aboutTBUpdate.linkLabel  "visit our website">
 <!ENTITY aboutTBUpdate.linkSuffix ".">
-<!ENTITY aboutTBUpdate.changeLogHeading "Changelog:">
+<!ENTITY aboutTBUpdate.version "Version">
+<!ENTITY aboutTBUpdate.releaseDate "Release Date">
+<!ENTITY aboutTBUpdate.releaseNotes "Release Notes">
diff --git a/src/chrome/locale/en-US/aboutTor.dtd b/src/chrome/locale/en-US/aboutTor.dtd
index 1400d7b5..4f360a91 100644
--- a/src/chrome/locale/en-US/aboutTor.dtd
+++ b/src/chrome/locale/en-US/aboutTor.dtd
@@ -6,6 +6,8 @@
 
 <!ENTITY aboutTor.title "About Tor">
 
+<!ENTITY aboutTor.viewChangelog.label "View Changelog">
+
 <!ENTITY aboutTor.ready.label "Explore. Privately.">
 <!ENTITY aboutTor.ready2.label "You’re ready for the world’s most private browsing experience.">
 <!ENTITY aboutTor.failure.label "Something Went Wrong!">
diff --git a/src/chrome/skin/aboutTor.css b/src/chrome/skin/aboutTor.css
index 1bdf301d..baa92b42 100644
--- a/src/chrome/skin/aboutTor.css
+++ b/src/chrome/skin/aboutTor.css
@@ -60,16 +60,25 @@ body:not([initialized]) {
   }
 }
 
-#torstatus-version {
+#torbrowser-info {
   position: absolute;
-  top: 6px;
-  offset-inline-end: 6px;
-  inset-inline-end: 6px;
-  height: 30px;
+  top: 16px;
+  offset-inline-end: 16px;
+  inset-inline-end: 16px;
+  height: 36px;
   width: 200px;
-  font-size: 15px;
+}
+
+#torbrowser-info div {
+  font-size: 14px;
   white-space: pre-wrap;
   text-align: end;
+  margin-bottom: 6px;
+}
+
+/* Hide "View Changelog" link if update channel is not release or alpha. */
+body:not([updatechannel="release"]):not([updatechannel="alpha"]) #torbrowser-changelog-link {
+  display: none;
 }
 
 a {
@@ -79,15 +88,13 @@ a {
 #torstatus {
   margin-top: 135px;
   display: flex;
-  justify-content: center;
+  flex-direction: column;
+  align-content: center;
+  justify-content: flex-end;
   vertical-align: bottom;
   min-height: 92px;
 }
 
-#torstatus > div {
-  align-self: flex-end; /* align text to bottom of container */
-}
-
 .top {
   white-space: nowrap;
 }
@@ -96,11 +103,13 @@ a {
   text-align: center;
 }
 
+body[hasbeenupdated] .hideIfHasBeenUpdated,
 body[toron] .hideIfTorOn,
 body:not([toron]) .hideIfTorOff {
   display: none;
 }
 
+body:not([hasbeenupdated]) .showIfHasBeenUpdated,
 body:not([showmanual]) .showForManual {
   display: none;
 }
@@ -303,7 +312,7 @@ body:not([showmanual]) .showForManual {
   display: none;
 }
 
-body[mobile] #torstatus-version,
+body[mobile] #torbrowser-info,
 body[mobile] .searchbox,
 body[mobile] .top .heading2,
 body[mobile] #manual,



More information about the tbb-commits mailing list