| 
Commits:
0d3b0974
 by Henry Wilkes   at 2024-04-08T13:00:37+02:00 
 fixup! MB 39: Add home page about:mullvad-browser
Bug 271: Show update in about:mullvad-browser
1e1a2221
 by Henry Wilkes   at 2024-04-08T13:00:46+02:00 
 fixup! MB 112: Updater customization for Mullvad Browser
Bug 271: Do not open update override page in a new tab, and show in
about:mullvad-browser instead.
 
11 changed files:
Changes:
browser/components/BrowserContentHandler.sys.mjs
 
| ... | ... | @@ -666,6 +666,23 @@ nsBrowserContentHandler.prototype = { |  
| 666 | 666 |        }
 |  
| 667 | 667 |      }
 |  
| 668 | 668 |  
 |  
|  | 669 | +    // Retrieve the home page early so we can compare it against
 |  
|  | 670 | +    // about:mullvad-browser to decide whether or not we need an override page
 |  
|  | 671 | +    // (second tab) after an update was applied.
 |  
|  | 672 | +    var startPage = "";
 |  
|  | 673 | +    try {
 |  
|  | 674 | +      var choice = prefb.getIntPref("browser.startup.page");
 |  
|  | 675 | +      if (choice == 1 || choice == 3) {
 |  
|  | 676 | +        startPage = lazy.HomePage.get();
 |  
|  | 677 | +      }
 |  
|  | 678 | +    } catch (e) {
 |  
|  | 679 | +      console.error(e);
 |  
|  | 680 | +    }
 |  
|  | 681 | +
 |  
|  | 682 | +    if (startPage == "about:blank") {
 |  
|  | 683 | +      startPage = "";
 |  
|  | 684 | +    }
 |  
|  | 685 | +
 |  
| 669 | 686 |      var override;
 |  
| 670 | 687 |      var overridePage = "";
 |  
| 671 | 688 |      var additionalPage = "";
 |  
| ... | ... | @@ -734,6 +751,17 @@ nsBrowserContentHandler.prototype = { |  
| 734 | 751 |                "%OLD_BASE_BROWSER_VERSION%",
 |  
| 735 | 752 |                old_forkVersion
 |  
| 736 | 753 |              );
 |  
|  | 754 | +            if (overridePage && AppConstants.BASE_BROWSER_UPDATE) {
 |  
|  | 755 | +              // Mullvad Browser, copied from tor-browser: Instead of opening
 |  
|  | 756 | +              // the post-update "override page" directly, we include a link in
 |  
|  | 757 | +              // about:mullvad-browser.
 |  
|  | 758 | +              prefb.setCharPref("mullvadbrowser.post_update.url", overridePage);
 |  
|  | 759 | +              prefb.setBoolPref("mullvadbrowser.post_update.shouldNotify", true);
 |  
|  | 760 | +              // If the user's homepage is about:tor, we will inform them
 |  
|  | 761 | +              // about the update on that page; otherwise, we arrange to
 |  
|  | 762 | +              // open about:tor in a secondary tab.
 |  
|  | 763 | +              overridePage = startPage === "about:mullvad-browser" ? "" : "about:mullvad-browser";
 |  
|  | 764 | +            }
 |  
| 737 | 765 |              break;
 |  
| 738 | 766 |            case OVERRIDE_NEW_BUILD_ID:
 |  
| 739 | 767 |              if (lazy.UpdateManager.readyUpdate) {
 |  
| ... | ... | @@ -806,20 +834,6 @@ nsBrowserContentHandler.prototype = { |  
| 806 | 834 |        }
 |  
| 807 | 835 |      }
 |  
| 808 | 836 |  
 |  
| 809 |  | -    var startPage = "";
 |  
| 810 |  | -    try {
 |  
| 811 |  | -      var choice = prefb.getIntPref("browser.startup.page");
 |  
| 812 |  | -      if (choice == 1 || choice == 3) {
 |  
| 813 |  | -        startPage = lazy.HomePage.get();
 |  
| 814 |  | -      }
 |  
| 815 |  | -    } catch (e) {
 |  
| 816 |  | -      console.error(e);
 |  
| 817 |  | -    }
 |  
| 818 |  | -
 |  
| 819 |  | -    if (startPage == "about:blank") {
 |  
| 820 |  | -      startPage = "";
 |  
| 821 |  | -    }
 |  
| 822 |  | -
 |  
| 823 | 837 |      let skipStartPage =
 |  
| 824 | 838 |        override == OVERRIDE_NEW_PROFILE &&
 |  
| 825 | 839 |        prefb.getBoolPref("browser.startup.firstrunSkipsHomepage");
 |  browser/components/BrowserGlue.sys.mjs
 
 
| ... | ... | @@ -370,6 +370,20 @@ let JSWINDOWACTORS = { |  
| 370 | 370 |      matches: ["about:messagepreview", "about:messagepreview?*"],
 |  
| 371 | 371 |    },
 |  
| 372 | 372 |  
 |  
|  | 373 | +  AboutMullvadBrowser: {
 |  
|  | 374 | +    parent: {
 |  
|  | 375 | +      esModuleURI: "resource:///actors/AboutMullvadBrowserParent.sys.mjs",
 |  
|  | 376 | +    },
 |  
|  | 377 | +    child: {
 |  
|  | 378 | +      esModuleURI: "resource:///actors/AboutMullvadBrowserChild.sys.mjs",
 |  
|  | 379 | +      events: {
 |  
|  | 380 | +        DOMContentLoaded: {},
 |  
|  | 381 | +      },
 |  
|  | 382 | +    },
 |  
|  | 383 | +
 |  
|  | 384 | +    matches: ["about:mullvad-browser"],
 |  
|  | 385 | +  },
 |  
|  | 386 | +
 |  
| 373 | 387 |    AboutPlugins: {
 |  
| 374 | 388 |      parent: {
 |  
| 375 | 389 |        esModuleURI: "resource:///actors/AboutPluginsParent.sys.mjs",
 |  browser/components/mullvad-browser/AboutMullvadBrowserChild.sys.mjs
 
 
|  | 1 | +export class AboutMullvadBrowserChild extends JSWindowActorChild {
 |  
|  | 2 | +  handleEvent(event) {
 |  
|  | 3 | +    switch (event.type) {
 |  
|  | 4 | +      case "DOMContentLoaded":
 |  
|  | 5 | +        this.sendQuery("AboutMullvadBrowser:GetUpdateData").then(data => {
 |  
|  | 6 | +          const updateEvent = new this.contentWindow.CustomEvent("UpdateData", {
 |  
|  | 7 | +            detail: Cu.cloneInto(data, this.contentWindow),
 |  
|  | 8 | +          });
 |  
|  | 9 | +          this.contentWindow.dispatchEvent(updateEvent);
 |  
|  | 10 | +        });
 |  
|  | 11 | +        break;
 |  
|  | 12 | +    }
 |  
|  | 13 | +  }
 |  
|  | 14 | +} |  browser/components/mullvad-browser/AboutMullvadBrowserParent.sys.mjs
 
 
|  | 1 | +export class AboutMullvadBrowserParent extends JSWindowActorParent {
 |  
|  | 2 | +  receiveMessage(message) {
 |  
|  | 3 | +    const shouldNotifyPref = "mullvadbrowser.post_update.shouldNotify";
 |  
|  | 4 | +    switch (message.name) {
 |  
|  | 5 | +      case "AboutMullvadBrowser:GetUpdateData":
 |  
|  | 6 | +        if (!Services.prefs.getBoolPref(shouldNotifyPref, false)) {
 |  
|  | 7 | +          return Promise.resolve(null);
 |  
|  | 8 | +        }
 |  
|  | 9 | +        Services.prefs.clearUserPref(shouldNotifyPref);
 |  
|  | 10 | +        return Promise.resolve({
 |  
|  | 11 | +          version: Services.prefs.getCharPref(
 |  
|  | 12 | +            "browser.startup.homepage_override.mullvadbrowser.version"
 |  
|  | 13 | +          ),
 |  
|  | 14 | +          url:
 |  
|  | 15 | +            Services.prefs.getCharPref("mullvadbrowser.post_update.url", "") ||
 |  
|  | 16 | +            Services.urlFormatter.formatURLPref(
 |  
|  | 17 | +              "startup.homepage_override_url"
 |  
|  | 18 | +            ),
 |  
|  | 19 | +        });
 |  
|  | 20 | +    }
 |  
|  | 21 | +    return undefined;
 |  
|  | 22 | +  }
 |  
|  | 23 | +} |  browser/components/mullvad-browser/content/2728-sparkles.svg
 
 
|  | 1 | +<!-- FROM https://github.com/twitter/twemoji
 |  
|  | 2 | +   - licensed under CC-BY 4.0: https://creativecommons.org/licenses/by/4.0/ -->
 |  
|  | 3 | +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><path fill="#FFAC33" d="M34.347 16.893l-8.899-3.294-3.323-10.891c-.128-.42-.517-.708-.956-.708-.439 0-.828.288-.956.708l-3.322 10.891-8.9 3.294c-.393.146-.653.519-.653.938 0 .418.26.793.653.938l8.895 3.293 3.324 11.223c.126.424.516.715.959.715.442 0 .833-.291.959-.716l3.324-11.223 8.896-3.293c.391-.144.652-.518.652-.937 0-.418-.261-.792-.653-.938z"/><path fill="#FFCC4D" d="M14.347 27.894l-2.314-.856-.9-3.3c-.118-.436-.513-.738-.964-.738-.451 0-.846.302-.965.737l-.9 3.3-2.313.856c-.393.145-.653.52-.653.938 0 .418.26.793.653.938l2.301.853.907 3.622c.112.444.511.756.97.756.459 0 .858-.312.97-.757l.907-3.622 2.301-.853c.393-.144.653-.519.653-.937 0-.418-.26-.793-.653-.937zM10.009 6.231l-2.364-.875-.876-2.365c-.145-.393-.519-.653-.938-.653-.418 0-.792.26-.938.653l-.875 2.365-2.365.875c-.393.146-.653.52-.653.938 0 .418.26.793.653.938l2.365.875.875 2.365c.146.393.52.653.938.653.418 0 .792-.26.938-.653l.875-2.365 2.365-.875c.393-.146.653-.52.653-.938 0-.418-.26-.792-.653-.938z"/></svg> |  browser/components/mullvad-browser/content/aboutMullvadBrowser.css
 
 
| ... | ... | @@ -44,14 +44,14 @@ p { |  
| 44 | 44 |  
 |  
| 45 | 45 |  #header {
 |  
| 46 | 46 |    display: grid;
 |  
| 47 |  | -  grid-template-rows: auto auto;
 |  
| 48 |  | -  grid-template-columns: auto;
 |  
|  | 47 | +  grid-template: "heading" auto "text" auto / auto;
 |  
| 49 | 48 |    justify-items: center;
 |  
| 50 | 49 |    align-content: center;
 |  
| 51 | 50 |    gap: 1.5em;
 |  
| 52 | 51 |  }
 |  
| 53 | 52 |  
 |  
| 54 | 53 |  #headingContainer {
 |  
|  | 54 | +  grid-area: heading;
 |  
| 55 | 55 |    display: inline flex;
 |  
| 56 | 56 |    flex-direction: row;
 |  
| 57 | 57 |    white-space: nowrap;
 |  
| ... | ... | @@ -59,6 +59,32 @@ p { |  
| 59 | 59 |    gap: 16px;
 |  
| 60 | 60 |  }
 |  
| 61 | 61 |  
 |  
|  | 62 | +#mullvad-browser-update,
 |  
|  | 63 | +#mullvad-browser-intro {
 |  
|  | 64 | +  grid-area: text;
 |  
|  | 65 | +}
 |  
|  | 66 | +
 |  
|  | 67 | +body:not(.has-update) #mullvad-browser-update {
 |  
|  | 68 | +  display: none;
 |  
|  | 69 | +}
 |  
|  | 70 | +
 |  
|  | 71 | +body:not(.no-update) #mullvad-browser-intro {
 |  
|  | 72 | +  /* Invisible but still reserves space for when the page is initially loaded to
 |  
|  | 73 | +   * prevent the Mullvad title from jumping. */
 |  
|  | 74 | +  visibility: hidden;
 |  
|  | 75 | +}
 |  
|  | 76 | +
 |  
|  | 77 | +#mullvad-browser-update-img {
 |  
|  | 78 | +  height: 1em;
 |  
|  | 79 | +  vertical-align: sub;
 |  
|  | 80 | +  margin-inline-end: 0.3em;
 |  
|  | 81 | +}
 |  
|  | 82 | +
 |  
|  | 83 | +#mullvad-browser-update a {
 |  
|  | 84 | +  /* Increase gap between the link and the rest of the text. */
 |  
|  | 85 | +  margin-inline: 0.4em;
 |  
|  | 86 | +}
 |  
|  | 87 | +
 |  
| 62 | 88 |  #footer {
 |  
| 63 | 89 |    padding-block: 40px;
 |  
| 64 | 90 |    background: rgba(0, 0, 0, 0.2);
 |  browser/components/mullvad-browser/content/aboutMullvadBrowser.js
 
 
|  | 1 | +"use strict";
 |  
|  | 2 | +
 |  
|  | 3 | +window.addEventListener("UpdateData", event => {
 |  
|  | 4 | +  const detail = event.detail;
 |  
|  | 5 | +  if (detail) {
 |  
|  | 6 | +    const { url, version } = detail;
 |  
|  | 7 | +
 |  
|  | 8 | +    const text = document.getElementById("mullvad-browser-update");
 |  
|  | 9 | +    document.l10n.setAttributes(
 |  
|  | 10 | +      text.querySelector("span"),
 |  
|  | 11 | +      "about-mullvad-browser-update-message",
 |  
|  | 12 | +      { version }
 |  
|  | 13 | +    );
 |  
|  | 14 | +    text.querySelector("a").href = url;
 |  
|  | 15 | +  }
 |  
|  | 16 | +  // Before the first call, neither the intro nor update text are shown, this
 |  
|  | 17 | +  // prevents the intro text from flashing in and out when we have an update.
 |  
|  | 18 | +  document.body.classList.toggle("no-update", !detail);
 |  
|  | 19 | +  document.body.classList.toggle("has-update", !!detail);
 |  
|  | 20 | +}); |  browser/components/mullvad-browser/content/aboutMullvadBrowser.xhtml
 
 
| ... | ... | @@ -21,6 +21,8 @@ |  
| 21 | 21 |        rel="localization"
 |  
| 22 | 22 |        href="">"browser/mullvad-browser/aboutMullvadBrowser.ftl"
 |  
| 23 | 23 |      />
 |  
|  | 24 | +
 |  
|  | 25 | +    <script src="">"chrome://browser/content/mullvad-browser/aboutMullvadBrowser.js"></script>
 |  
| 24 | 26 |    </head>
 |  
| 25 | 27 |    <body>
 |  
| 26 | 28 |      <div id="header">
 |  
| ... | ... | @@ -48,11 +50,22 @@ |  
| 48 | 50 |            data-l10n-id="about-mullvad-browser-heading"
 |  
| 49 | 51 |          ></h1>
 |  
| 50 | 52 |        </div>
 |  
| 51 |  | -      <p data-l10n-id="about-mullvad-browser-developed-by">
 |  
|  | 53 | +      <p
 |  
|  | 54 | +        id="mullvad-browser-intro"
 |  
|  | 55 | +        data-l10n-id="about-mullvad-browser-developed-by"
 |  
|  | 56 | +      >
 |  
| 52 | 57 |          <a data-l10n-name="tor-project-link" href="">"https://www.torproject.org">
 |  
| 53 | 58 |          </a>
 |  
| 54 | 59 |          <a data-l10n-name="mullvad-vpn-link" href="">"https://mullvad.net"> </a>
 |  
| 55 | 60 |        </p>
 |  
|  | 61 | +      <p id="mullvad-browser-update">
 |  
|  | 62 | +        <img
 |  
|  | 63 | +          id="mullvad-browser-update-img"
 |  
|  | 64 | +          alt=""
 |  
|  | 65 | +          src="">"chrome://browser/content/mullvad-browser/2728-sparkles.svg"
 |  
|  | 66 | +        />
 |  
|  | 67 | +        <span><a data-l10n-name="update-link"></a></span>
 |  
|  | 68 | +      </p>
 |  
| 56 | 69 |      </div>
 |  
| 57 | 70 |      <div id="footer">
 |  
| 58 | 71 |        <p data-l10n-id="about-mullvad-browser-use-vpn">
 |  browser/components/mullvad-browser/jar.mn
 
 
| 1 | 1 |  browser.jar:
 |  
|  | 2 | +  content/browser/mullvad-browser/aboutMullvadBrowser.js      (content/aboutMullvadBrowser.js)
 |  
| 2 | 3 |    content/browser/mullvad-browser/aboutMullvadBrowser.xhtml   (content/aboutMullvadBrowser.xhtml)
 |  
| 3 | 4 |    content/browser/mullvad-browser/aboutMullvadBrowser.css     (content/aboutMullvadBrowser.css)
 |  
| 4 | 5 |    content/browser/mullvad-browser/mullvadBrowserFont.css      (content/mullvadBrowserFont.css)
 |  
|  | 6 | +  content/browser/mullvad-browser/2728-sparkles.svg           (content/2728-sparkles.svg) |  browser/components/mullvad-browser/moz.build
 
 
| 1 | 1 |  JAR_MANIFESTS += ["jar.mn"]
 |  
|  | 2 | +
 |  
|  | 3 | +FINAL_TARGET_FILES.actors += [
 |  
|  | 4 | +    "AboutMullvadBrowserChild.sys.mjs",
 |  
|  | 5 | +    "AboutMullvadBrowserParent.sys.mjs",
 |  
|  | 6 | +] |  browser/locales/en-US/browser/mullvad-browser/aboutMullvadBrowser.ftl
 
 
| ... | ... | @@ -3,6 +3,11 @@ about-mullvad-browser-developed-by = Developed in collaboration between the <a d |  
| 3 | 3 |  about-mullvad-browser-use-vpn = Get more privacy by using the browser <a data-l10n-name="with-vpn-link">with Mullvad VPN</a>.
 |  
| 4 | 4 |  about-mullvad-browser-learn-more = Curious to learn more about the browser? <a data-l10n-name="learn-more-link">Take a dive into the mole hole</a>.
 |  
| 5 | 5 |  
 |  
|  | 6 | +# Update message.
 |  
|  | 7 | +# <a data-l10n-name="update-link"> should contain the link text and close with </a>.
 |  
|  | 8 | +# $version (String) - The new browser version.
 |  
|  | 9 | +about-mullvad-browser-update-message =  { -brand-short-name } has been updated to { $version }. <a data-l10n-name="update-link">See what’s new</a>
 |  
|  | 10 | +
 |  
| 6 | 11 |  
 |  
| 7 | 12 |  ## Deprecated. To be removed when 13.5 becomes stable.
 |  
| 8 | 13 |  
 |  
 |