Commit 711497a6 authored by Kathleen Brade's avatar Kathleen Brade Committed by Georg Koppen
Browse files

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.
parent 428387f6
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
// 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;
    }
  }
}
+5 −0
Original line number Diff line number Diff line
@@ -45,3 +45,8 @@ FINAL_TARGET_FILES.actors += [
    'URIFixupChild.jsm',
    'WebRTCChild.jsm',
]

if CONFIG['TOR_BROWSER_UPDATE']:
    FINAL_TARGET_FILES.actors += [
        'AboutTBUpdateChild.jsm',
    ]
+74 −0
Original line number Diff line number Diff line
/*
 * 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;
}
+10 −0
Original line number Diff line number Diff line
// 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);
});
+39 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html [
  <!ENTITY % htmlDTD
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "DTD/xhtml1-strict.dtd">
  %htmlDTD;
  <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
  %globalDTD;
  <!ENTITY % tbUpdateDTD SYSTEM "chrome://browser/locale/aboutTBUpdate.dtd">
  %tbUpdateDTD;
]>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Security-Policy" content="default-src chrome:" />
  <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;">
<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>
Loading