[tbb-commits] [tor-browser/tor-browser-60.5.1esr-8.5-1] squash! Bug 16940: After update, load local change notes.
gk at torproject.org
gk at torproject.org
Wed Mar 13 15:12:03 UTC 2019
commit 0c7bd3b2fa73e8be38f5aac46cbc68d025071f05
Author: Kathy Brade <brade at pearlcrescent.com>
Date: Thu Mar 7 15:48:00 2019 -0500
squash! Bug 16940: After update, load local change notes.
Also fix bug 29440. Now about:tbupdate is styled as a fairly simple
changelog page that is designed to be displayed via a link that is on
about:tor.
---
.../base/content/abouttbupdate/aboutTBUpdate.css | 71 ++++++++++++----------
.../base/content/abouttbupdate/aboutTBUpdate.xhtml | 26 ++++----
browser/base/content/tab-content.js | 13 +++-
browser/components/nsBrowserContentHandler.js | 49 +++++++++------
.../locales/en-US/chrome/browser/aboutTBUpdate.dtd | 6 +-
browser/modules/AboutTBUpdate.jsm | 67 ++++++++++++++------
6 files changed, 147 insertions(+), 85 deletions(-)
diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.css b/browser/base/content/abouttbupdate/aboutTBUpdate.css
index 90252d77a739..7c1a34b77f17 100644
--- a/browser/base/content/abouttbupdate/aboutTBUpdate.css
+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.css
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, The Tor Project, Inc.
+ * Copyright (c) 2019, The Tor Project, Inc.
* See LICENSE for licensing information.
*
* vim: set sw=2 sts=2 ts=8 et syntax=css:
@@ -12,56 +12,63 @@
body {
font-family: Helvetica, Arial, sans-serif;
- font-size: 110%;
color: var(--abouttor-text-color);
background-color: var(--abouttor-bg-toron-color);
background-attachment: fixed;
background-size: 100% 100%;
}
-#torbrowser-version {
- /* These CSS rules match the about:tor page */
- position: fixed;
- top: 6px;
- right: 6px;
- height: 30px;
- width: 200px;
- font-size: 15px;
- white-space: pre-wrap;
- text-align: right;
-}
-
a {
color: var(--abouttor-text-color);
}
-#logo {
- background-image: url("chrome://branding/content/icon128.png");
- height: 128px;
- width: 128px;
- margin: 20px;
- float: left;
+.two-column-grid {
+ display: inline-grid;
+ grid-template-columns: auto auto;
+ grid-column-gap: 50px;
+ margin: 10px 0px 0px 50px;
+}
+
+.two-column-grid div {
+ margin-top: 40px;
+ align-self: baseline; /* Align baseline of text across the row. */
+}
+
+.label-column {
+ font-size: 14px;
+ font-weight: 400;
+}
+
+/*
+ * Use a reduced top margin to bring the row that contains the
+ * "visit our website" link closer to the row that precedes it. This
+ * looks better because the "visit our website" row does not have a
+ * label in the left column.
+ */
+div.more-info-row {
+ margin-top: 5px;
+ font-size: 14px;
}
-#msg {
- margin-top: 50px;
- float: left;
+#version-content {
+ font-size: 50px;
+ font-weight: 300;
}
-#msg-updated {
- font-size: 120%;
- margin-bottom: 20px;
+body:not([havereleasedate]) .release-date-cell {
+ display: none;
}
-#changelog-container {
- margin: 0px 20px 20px 20px;
+#releasedate-content {
+ font-size: 17px;
}
-#changelog-heading {
- margin-bottom: 4px;
+#releasenotes-label {
+ align-self: start; /* Anchor "Release Notes" label at the top. */
}
-#changelog {
- margin-left: 20px;
+#releasenotes-content {
+ font-family: monospace;
+ font-size: 15px;
white-space: pre;
}
diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
index fe8ed69b537f..f703fe1e13a1 100644
--- a/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
@@ -13,24 +13,26 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>&aboutTBUpdate.title;</title>
+ <title>&aboutTBUpdate.changelogTitle;</title>
<link rel="stylesheet" type="text/css"
href="chrome://browser/content/abouttbupdate/aboutTBUpdate.css"/>
<script src="chrome://browser/content/abouttbupdate/aboutTBUpdate.js"
type="text/javascript"/>
</head>
<body dir="&locale.dir;" onload="init()">
-<div id="torbrowser-version"/>
-<div id="logo"/>
-<div id="msg">
-<div id="msg-updated">&aboutTBUpdate.updated;</div>
-<div>&aboutTBUpdate.linkPrefix;<a id="infolink">&aboutTBUpdate.linkLabel;</a>&aboutTBUpdate.linkSuffix;
-</div>
-</div>
-<br clear="all"/>
-<div id="changelog-container">
-<div id="changelog-heading">&aboutTBUpdate.changeLogHeading;</div>
-<div id="changelog"></div>
+<div class="two-column-grid">
+ <div class="label-column">&aboutTBUpdate.version;</div>
+ <div id="version-content"/>
+
+ <div class="label-column release-date-cell">&aboutTBUpdate.releaseDate;</div>
+ <div id="releasedate-content" class="release-date-cell"/>
+
+ <div class="more-info-row"/>
+ <div class="more-info-row">&aboutTBUpdate.linkPrefix;<a id="infolink">&aboutTBUpdate.linkLabel;</a>&aboutTBUpdate.linkSuffix;</div>
+
+ <div id="releasenotes-label"
+ class="label-column">&aboutTBUpdate.releaseNotes;</div>
+ <div id="releasenotes-content"></div>
</div>
</body>
</html>
diff --git a/browser/base/content/tab-content.js b/browser/base/content/tab-content.js
index e0cf6747aaa4..6450baa6d060 100644
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -384,12 +384,21 @@ let AboutTBUpdateListener = {
this.onUpdate(aMessage.data);
},
+ // aData may contain the following string properties:
+ // version
+ // releaseDate
+ // moreInfoURL
+ // releaseNotes
onUpdate: function(aData) {
let doc = content.document;
- doc.getElementById("torbrowser-version").textContent = aData.productInfo;
+ doc.getElementById("version-content").textContent = aData.version;
+ if (aData.releaseDate) {
+ doc.body.setAttribute("havereleasedate", "true");
+ doc.getElementById("releasedate-content").textContent = aData.releaseDate;
+ }
if (aData.moreInfoURL)
doc.getElementById("infolink").setAttribute("href", aData.moreInfoURL);
- doc.getElementById("changelog").textContent = aData.changeLog;
+ doc.getElementById("releasenotes-content").textContent = aData.releaseNotes;
},
onPageLoad: function() {
diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js
index a640bfc57663..4c698a9ebd90 100644
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -541,6 +541,21 @@ nsBrowserContentHandler.prototype = {
}
}
+ // Retrieve the home page early so we can compare it against about:tor
+ // to decide whether or not we need an override page (second tab) after
+ // an update was applied.
+ var startPage = "";
+ try {
+ var choice = prefb.getIntPref("browser.startup.page");
+ if (choice == 1 || choice == 3)
+ startPage = this.startPage;
+ } catch (e) {
+ Cu.reportError(e);
+ }
+
+ if (startPage == "about:blank")
+ startPage = "";
+
var override;
var overridePage = "";
var additionalPage = "";
@@ -580,11 +595,14 @@ nsBrowserContentHandler.prototype = {
// we may open the startPage in addition to restoring the session.
//
// Tor Browser: Instead of opening the post-update "override page"
- // directly, an about:tbupdate page is opened that includes a link
- // to the override page as well as text from the first part of the
- // local ChangeLog.txt file. The override page URL comes from the
- // openURL attribute within the updates.xml file or, if no showURL
- // action is present, from the startup.homepage_override_url pref.
+ // directly, we ensure that about:tor will be opened in a special
+ // mode that notifies the user that their browser was updated.
+ // The about:tor page will provide a link to the override page
+ // where the user can learn more about the update, as well as a
+ // link to the Tor Browser changelog page (about:tbupdate). The
+ // override page URL comes from the openURL attribute within the
+ // updates.xml file or, if no showURL action is present, from the
+ // startup.homepage_override_url pref.
var ss = Cc["@mozilla.org/browser/sessionstartup;1"]
.getService(Ci.nsISessionStartup);
willRestoreSession = ss.isAutomaticRestoreEnabled();
@@ -606,7 +624,14 @@ nsBrowserContentHandler.prototype = {
if (overridePage)
{
prefb.setCharPref("torbrowser.post_update.url", overridePage);
- overridePage = "about:tbupdate"
+ prefb.setBoolPref("torbrowser.post_update.shouldNotify", true);
+ // If the user's homepage is about:tor, we will inform them
+ // about the update on that page; otherwise, we arrange to
+ // open about:tor in a secondary tab.
+ if (startPage === "about:tor")
+ overridePage = "";
+ else
+ overridePage = "about:tor";
}
#endif
break;
@@ -636,18 +661,6 @@ nsBrowserContentHandler.prototype = {
}
}
- var startPage = "";
- try {
- var choice = prefb.getIntPref("browser.startup.page");
- if (choice == 1 || choice == 3)
- startPage = this.startPage;
- } catch (e) {
- Cu.reportError(e);
- }
-
- if (startPage == "about:blank")
- startPage = "";
-
let skipStartPage = override == OVERRIDE_NEW_PROFILE &&
prefb.getBoolPref("browser.startup.firstrunSkipsHomepage");
// Only show the startPage if we're not restoring an update session and are
diff --git a/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd b/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd
index 37567bd7e38c..2d1e59b40eaf 100644
--- a/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd
+++ b/browser/locales/en-US/chrome/browser/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/browser/modules/AboutTBUpdate.jsm b/browser/modules/AboutTBUpdate.jsm
index 49d9d9b0e18d..4d18d2980a6c 100644
--- a/browser/modules/AboutTBUpdate.jsm
+++ b/browser/modules/AboutTBUpdate.jsm
@@ -40,10 +40,8 @@ var AboutTBUpdate = {
},
sendAboutTBUpdateData: function(aTarget) {
- let data = { productInfo: this.productInfo,
- moreInfoURL: this.moreInfoURL,
- changeLog: this.changeLog };
-
+ let data = this.releaseNoteInfo;
+ data.moreInfoURL = this.moreInfoURL;
if (aTarget && aTarget.messageManager) {
aTarget.messageManager.sendAsyncMessage(kSendUpdateMessageName, data);
} else {
@@ -53,15 +51,6 @@ var AboutTBUpdate = {
}
},
- get productInfo() {
- const kBrandBundle = "chrome://branding/locale/brand.properties";
- let brandBundle = Cc["@mozilla.org/intl/stringbundle;1"]
- .getService(Ci.nsIStringBundleService)
- .createBundle(kBrandBundle);
- return brandBundle.GetStringFromName("brandFullName")
- + "\n" + TOR_BROWSER_VERSION;
- },
-
get moreInfoURL() {
try {
return Services.prefs.getCharPref("torbrowser.post_update.url");
@@ -71,12 +60,22 @@ var AboutTBUpdate = {
return Services.urlFormatter.formatURLPref("startup.homepage_override_url");
},
- // Read and return the text from the beginning of the changelog file that is
- // located at TorBrowser/Docs/ChangeLog.txt.
+ // Read the text from the beginning of the changelog file that is located
+ // at TorBrowser/Docs/ChangeLog.txt and return an object that contains
+ // the following properties:
+ // version e.g., Tor Browser 8.5
+ // releaseDate e.g., March 31 2019
+ // releaseNotes details of changes (lines 2 - end of ChangeLog.txt)
+ // We attempt to parse the first line of ChangeLog.txt to extract the
+ // version and releaseDate. If parsing fails, we return the entire first
+ // line in version and omit releaseDate.
+ //
// On Mac OS, when building with --enable-tor-browser-data-outside-app-dir
- // to support Gatekeeper signing, the file is located in
+ // to support Gatekeeper signing, the ChangeLog.txt file is located in
// TorBrowser.app/Contents/Resources/TorBrowser/Docs/.
- get changeLog() {
+ get releaseNoteInfo() {
+ let info = {};
+
try {
#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
// "XREExeF".parent is the directory that contains firefox, i.e.,
@@ -103,9 +102,39 @@ var AboutTBUpdate = {
fs.close();
// Truncate at the first empty line.
- return s.replace(/[\r\n][\r\n][\s\S]*$/m, "");
+ s = s.replace(/[\r\n][\r\n][\s\S]*$/m, "");
+
+ // Split into first line (version plus releaseDate) and
+ // remainder (releaseNotes).
+ // This first match() uses multiline mode with two capture groups:
+ // first line: (.*$)
+ // remaining lines: ([\s\S]+)
+ // [\s\S] matches all characters including end of line. This trick
+ // is needed because when using JavaScript regex in multiline mode,
+ // . does not match an end of line character.
+ let matchArray = s.match(/(.*$)\s*([\s\S]+)/m);
+ if (matchArray && (matchArray.length == 3)) {
+ info.releaseNotes = matchArray[2];
+ let line1 = matchArray[1];
+ // Extract the version and releaseDate. The first line looks like:
+ // Tor Browser 8.5 -- May 1 2019
+ // The regex uses two capture groups:
+ // text that does not include a hyphen: (^[^-]*)
+ // remaining text: (.*$)
+ // In between we match optional whitespace, one or more hyphens, and
+ // optional whitespace by using: \s*-+\s*
+ matchArray = line1.match(/(^[^-]*)\s*-+\s*(.*$)/);
+ if (matchArray && (matchArray.length == 3)) {
+ info.version = matchArray[1];
+ info.releaseDate = matchArray[2];
+ } else {
+ info.version = line1; // Match failed: return entire line in version.
+ }
+ } else {
+ info.releaseNotes = s; // Only one line: use as releaseNotes.
+ }
} catch (e) {}
- return "";
+ return info;
},
};
More information about the tbb-commits
mailing list