Commit f68e26b8 authored by henry's avatar henry Committed by richard
Browse files

fixup! Bug 42072: 2023 year end campaign for about:tor.

Bug 42188: Make the YEC banner closed state persist for the current
session.
parent f9c4691b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -453,6 +453,7 @@ let JSWINDOWACTORS = {
      events: {
        DOMContentLoaded: {},
        SubmitSearchOnionize: { wantUntrusted: true },
        YECHidden: { wantUntrusted: true },
      },
    },

+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ export class AboutTorChild extends JSWindowActorChild {
      case "SubmitSearchOnionize":
        this.sendAsyncMessage("AboutTor:SetSearchOnionize", !!event.detail);
        break;
      case "YECHidden":
        // YEC 2023 banner was closed. Persist this for the rest of this
        // session. See tor-browser#42188.
        this.sendAsyncMessage("AboutTor:HideYEC");
        break;
    }
  }
}
+17 −0
Original line number Diff line number Diff line
@@ -7,6 +7,19 @@ ChromeUtils.defineESModuleGetters(lazy, {
  TorConnect: "resource:///modules/TorConnect.sys.mjs",
});

/**
 * Whether we should hide the Year end campaign (YEC) 2023 donation banner for
 * new about:tor pages. Applied to all future about:tor pages within this
 * session (i.e. new tabs, new windows, and after new identity).
 *
 * Will reset back to shown at the next full restart.
 *
 * See tor-browser#42188.
 *
 * @type {boolean}
 */
let hideYEC = false;

export class AboutTorParent extends JSWindowActorParent {
  receiveMessage(message) {
    const onionizePref = "torbrowser.homepage.search.onionize";
@@ -22,10 +35,14 @@ export class AboutTorParent extends JSWindowActorParent {
            Services.locale.appLocaleAsBCP47 === "ja-JP-macos"
              ? "ja"
              : Services.locale.appLocaleAsBCP47,
          hideYEC,
        });
      case "AboutTor:SetSearchOnionize":
        Services.prefs.setBoolPref(onionizePref, message.data);
        break;
      case "AboutTor:HideYEC":
        hideYEC = true;
        break;
    }
    return undefined;
  }
+4 −2
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ const YecWidget = {

    this.isActive = now >= yecStart && now < yecEnd;
    document.getElementById("yec-2023-close").addEventListener("click", () => {
      dispatchEvent(new CustomEvent("YECHidden", { bubbles: true }));
      this.isOpen = false;
    });

@@ -215,7 +216,7 @@ const YecWidget = {

  _isStable: false,
  _isActive: false,
  _isOpen: true,
  _isOpen: false,

  /**
   * Whether this is a stable release.
@@ -294,7 +295,8 @@ window.addEventListener("DOMContentLoaded", () => {
});

window.addEventListener("InitialData", event => {
  const { appLocale, isStable } = event.detail;
  const { appLocale, isStable, hideYEC } = event.detail;
  YecWidget.setDonateLocale(appLocale);
  YecWidget.isStable = isStable;
  YecWidget.isOpen = !hideYEC;
});