From 721a7b32cba8f9ce826de4be45704c6430d93524 Mon Sep 17 00:00:00 2001 From: Kathy Brade Date: Wed, 25 Nov 2015 11:36:20 -0500 Subject: [PATCH] Bug 16940: After update, load local change notes. Add an about:tbupdate page that displays the first section from TorBrowser/Docs/ChangeLog.txt and includes a link to the remote post-update page (typically our blog entry for the release). Always load about:tbupdate in a content process, but implement the code that reads the file system (changelog) in the chrome process for compatibility with future sandboxing efforts. 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. --- browser/actors/AboutTBUpdateChild.jsm | 53 +++++++ browser/actors/moz.build | 5 + .../content/abouttbupdate/aboutTBUpdate.css | 74 ++++++++++ .../content/abouttbupdate/aboutTBUpdate.js | 10 ++ .../content/abouttbupdate/aboutTBUpdate.xhtml | 39 +++++ .../abouttbupdate/aboutTBUpdateLogo.png | Bin 0 -> 23266 bytes browser/base/content/browser-siteIdentity.js | 2 +- browser/base/content/browser.js | 4 + browser/base/jar.mn | 6 + browser/base/moz.build | 3 + browser/components/BrowserContentHandler.jsm | 55 +++++-- browser/components/BrowserGlue.jsm | 25 ++++ browser/components/about/AboutRedirector.cpp | 6 + browser/components/about/components.conf | 3 + browser/components/moz.build | 5 +- .../en-US/chrome/browser/aboutTBUpdate.dtd | 8 ++ browser/locales/jar.mn | 3 + browser/modules/AboutTBUpdate.jsm | 134 ++++++++++++++++++ browser/modules/moz.build | 5 + toolkit/modules/AppConstants.jsm | 7 + toolkit/modules/moz.build | 3 + 21 files changed, 434 insertions(+), 16 deletions(-) create mode 100644 browser/actors/AboutTBUpdateChild.jsm create mode 100644 browser/base/content/abouttbupdate/aboutTBUpdate.css create mode 100644 browser/base/content/abouttbupdate/aboutTBUpdate.js create mode 100644 browser/base/content/abouttbupdate/aboutTBUpdate.xhtml create mode 100644 browser/base/content/abouttbupdate/aboutTBUpdateLogo.png create mode 100644 browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd create mode 100644 browser/modules/AboutTBUpdate.jsm diff --git a/browser/actors/AboutTBUpdateChild.jsm b/browser/actors/AboutTBUpdateChild.jsm new file mode 100644 index 0000000000000..91bb4dbba888f --- /dev/null +++ b/browser/actors/AboutTBUpdateChild.jsm @@ -0,0 +1,53 @@ +// Copyright (c) 2019, The Tor Project, Inc. +// See LICENSE for licensing information. +// +// vim: set sw=2 sts=2 ts=8 et syntax=javascript: + +var EXPORTED_SYMBOLS = ["AboutTBUpdateChild"]; + +const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm"); + +class AboutTBUpdateChild extends ActorChild { + receiveMessage(aMessage) { + if (aMessage.name == "AboutTBUpdate:Update") + this.onUpdate(aMessage.data); + } + + handleEvent(aEvent) { + switch (aEvent.type) { + case "AboutTBUpdateLoad": + this.onPageLoad(); + break; + case "pagehide": + this.onPageHide(aEvent); + break; + } + } + + // aData may contain the following string properties: + // version + // releaseDate + // moreInfoURL + // releaseNotes + onUpdate(aData) { + let doc = this.content.document; + 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("releasenotes-content").textContent = aData.releaseNotes; + } + + onPageLoad() { + this.mm.sendAsyncMessage("AboutTBUpdate:RequestUpdate"); + } + + onPageHide(aEvent) { + if (aEvent.target.defaultView.frameElement) { + return; + } + } +} diff --git a/browser/actors/moz.build b/browser/actors/moz.build index 6f5b4c0cc0c61..44d5c07c29344 100644 --- a/browser/actors/moz.build +++ b/browser/actors/moz.build @@ -45,3 +45,8 @@ FINAL_TARGET_FILES.actors += [ 'URIFixupChild.jsm', 'WebRTCChild.jsm', ] + +if CONFIG['TOR_BROWSER_UPDATE']: + FINAL_TARGET_FILES.actors += [ + 'AboutTBUpdateChild.jsm', + ] diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.css b/browser/base/content/abouttbupdate/aboutTBUpdate.css new file mode 100644 index 0000000000000..7c1a34b77f176 --- /dev/null +++ b/browser/base/content/abouttbupdate/aboutTBUpdate.css @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, The Tor Project, Inc. + * See LICENSE for licensing information. + * + * vim: set sw=2 sts=2 ts=8 et syntax=css: + */ + +:root { + --abouttor-text-color: white; + --abouttor-bg-toron-color: #420C5D; +} + +body { + font-family: Helvetica, Arial, sans-serif; + color: var(--abouttor-text-color); + background-color: var(--abouttor-bg-toron-color); + background-attachment: fixed; + background-size: 100% 100%; +} + +a { + color: var(--abouttor-text-color); +} + +.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; +} + +#version-content { + font-size: 50px; + font-weight: 300; +} + +body:not([havereleasedate]) .release-date-cell { + display: none; +} + +#releasedate-content { + font-size: 17px; +} + +#releasenotes-label { + align-self: start; /* Anchor "Release Notes" label at the top. */ +} + +#releasenotes-content { + font-family: monospace; + font-size: 15px; + white-space: pre; +} diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.js b/browser/base/content/abouttbupdate/aboutTBUpdate.js new file mode 100644 index 0000000000000..da7553f0ae815 --- /dev/null +++ b/browser/base/content/abouttbupdate/aboutTBUpdate.js @@ -0,0 +1,10 @@ +// Copyright (c) 2019, The Tor Project, Inc. +// See LICENSE for licensing information. +// +// vim: set sw=2 sts=2 ts=8 et syntax=javascript: + + +addEventListener("load", () => { + let event = new CustomEvent("AboutTBUpdateLoad", { bubbles: true }); + document.dispatchEvent(event); +}); diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml new file mode 100644 index 0000000000000..ab4c53df007c9 --- /dev/null +++ b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml @@ -0,0 +1,39 @@ + + + + %htmlDTD; + + %globalDTD; + + %tbUpdateDTD; +]> + + + + + &aboutTBUpdate.changelogTitle; + +