+ +
+ + + +diff --git a/browser/components/DesktopActorRegistry.sys.mjs b/browser/components/DesktopActorRegistry.sys.mjs index ba219ac629bc540761ae1a9ed4abc90880ece1c1..020e6a9d3d6a87cb15b38c9cf52d24951e094893 100644 --- a/browser/components/DesktopActorRegistry.sys.mjs +++ b/browser/components/DesktopActorRegistry.sys.mjs @@ -202,6 +202,7 @@ let JSWINDOWACTORS = { L10nMutationsFinished: {}, SubmitSearchOnionize: { wantUntrusted: true }, SurveyDismissed: { wantUntrusted: true }, + UserDismissedYEC: { wantUntrusted: true }, }, }, diff --git a/browser/components/abouttor/AboutTorChild.sys.mjs b/browser/components/abouttor/AboutTorChild.sys.mjs index 1411e541dfc7ac43d3847690b19d7d86fc5081ba..f2baac072ee5a45d34f3b0c2b0830a2f0f97eaeb 100644 --- a/browser/components/abouttor/AboutTorChild.sys.mjs +++ b/browser/components/abouttor/AboutTorChild.sys.mjs @@ -26,6 +26,23 @@ export class AboutTorChild extends JSWindowActorChild { new this.contentWindow.CustomEvent("L10nMutationsFinished") ); break; + case "UserDismissedYEC": + // YEC banner was closed. Persist this for the rest of this session. + // See tor-browser#42188. + this.sendAsyncMessage("AboutTor:UserDismissedYEC"); + break; + } + } + + receiveMessage(message) { + switch (message.name) { + case "AboutTor:DismissYEC": { + this.contentWindow.dispatchEvent( + new this.contentWindow.CustomEvent("DismissYEC") + ); + break; + } } + return undefined; } } diff --git a/browser/components/abouttor/AboutTorParent.sys.mjs b/browser/components/abouttor/AboutTorParent.sys.mjs index 379d3b4e084275b77b59994083bf1fbf27012ede..eb3692b28f1ec67c91c5cf640a1671e9ec2580d2 100644 --- a/browser/components/abouttor/AboutTorParent.sys.mjs +++ b/browser/components/abouttor/AboutTorParent.sys.mjs @@ -7,16 +7,37 @@ ChromeUtils.defineESModuleGetters(lazy, { TorConnect: "resource://gre/modules/TorConnect.sys.mjs", }); +const initializedActors = new Set(); + /** * Actor parent class for the about:tor page. */ export class AboutTorParent extends JSWindowActorParent { + /* + * Whether the user has dismissed the Year End Campaign (YEC) banner this + * session. + * + * @type {boolean} + */ + static #dismissYEC = false; + + didDestroy() { + initializedActors.delete(this); + } + receiveMessage(message) { const onionizePref = "torbrowser.homepage.search.onionize"; const surveyDismissVersionPref = "torbrowser.homepage.survey.dismiss_version"; switch (message.name) { - case "AboutTor:GetInitialData": + case "AboutTor:GetInitialData": { + // Track this actor to send future updates. + initializedActors.add(this); + + let appLocale = Services.locale.appLocaleAsBCP47; + if (appLocale === "ja-JP-macos") { + appLocale = "ja"; + } return Promise.resolve({ torConnectEnabled: lazy.TorConnect.enabled, messageData: lazy.AboutTorMessage.getNext(), @@ -26,8 +47,10 @@ export class AboutTorParent extends JSWindowActorParent { surveyDismissVersionPref, 0 ), - appLocale: Services.locale.appLocaleAsBCP47, + appLocale, + dismissYEC: AboutTorParent.#dismissYEC, }); + } case "AboutTor:SetSearchOnionize": Services.prefs.setBoolPref(onionizePref, message.data); break; @@ -43,6 +66,23 @@ export class AboutTorParent extends JSWindowActorParent { // the version value to decrease. Services.prefs.setIntPref(surveyDismissVersionPref, message.data); break; + case "AboutTor:UserDismissedYEC": + AboutTorParent.#dismissYEC = true; + for (const actor of initializedActors) { + if (actor === this) { + // Don't send to ourselves. + continue; + } + // Tell all existing instances to also close the banner, if they still + // exist. + // NOTE: If the user's new tab page is `about:tor`, this may include + // some preloaded pages that have not been made visible yet (see + // NewTabPagePreloading). + try { + actor.sendAsyncMessage("AboutTor:DismissYEC"); + } catch {} + } + break; } return undefined; } diff --git a/browser/components/abouttor/content/aboutTor.css b/browser/components/abouttor/content/aboutTor.css index c6e4925b8ee45e9c9c6ea58843bc12c735f505db..5d41df5035503f6270e5e3a4023e266283fe1072 100644 --- a/browser/components/abouttor/content/aboutTor.css +++ b/browser/components/abouttor/content/aboutTor.css @@ -326,3 +326,209 @@ body:not(.show-survey) #survey { --in-content-primary-button-background-active: var(--tor-button-background-color-active-dark); } } + +/* Year End Campaign (YEC). */ +body:not(.show-yec) #yec-banner { + display: none; +} + +body.show-yec h1 { + /* Text of heading is still available to screen readers, but it does not + * contribute visually to the page or the body grid layout. */ + position: absolute; + clip-path: inset(50%); +} + +#yec-banner { + grid-area: heading; + border-radius: 8px; + border: 1px solid var(--in-content-box-border-color); + display: grid; + grid-template: + "yec-heading yec-image" auto + "yec-body yec-image" auto + "yec-matching yec-image" auto + "yec-donate yec-image" min-content + / 1fr min-content; + --yec-image-background: #1f0333; + /* Remove 1px from padding for border. */ + padding-block: 55px 55px; + padding-inline: 47px 47px; + box-sizing: border-box; + max-width: 850px; + margin-block-end: 40px; + /* Position for the close button. */ + position: relative; + gap: 0 24px; +} + +#yec-image { + grid-area: yec-image; + align-self: center; + /* Center horizontally for small width layout. */ + justify-self: center; + /* background color, padding and border radius only stands out when using a + * contrast or forced color theme. */ + background-color: var(--yec-image-background); + border-radius: 8px; + padding: 4px; + height: 196px; + border: 1px solid transparent; + /* Remove border and padding from the layout size. These parts are only + * visible in contrast or forced color themes. */ + margin: -5px; + /* Do not let forced colors ignore the background-color, which is needed to + * see the drawing. */ + forced-color-adjust: none; +} + +#yec-image:dir(rtl) { + transform: scaleX(-1); +} + +#yec-heading { + grid-area: yec-heading; + margin-block: 0 16px; + font-size: 64px; + font-weight: 400; + font-family: "Jacquard 12", serif; +} + +#yec-heading.all-jacquard12-chars { + /* All characters are supported by Jacquard 12. + * These have a high natural line-height. */ + line-height: 1.0; +} + +#yec-body { + grid-area: yec-body; + margin-block: 0 12px; +} + +#yec-body-highlight { + font-weight: 600; +} + +#yec-matching { + grid-area: yec-matching; + margin-block: 0 32px; +} + +#yec-donate-link { + grid-area: yec-donate; + justify-self: start; + /* Style like a button. */ + font-weight: var(--button-font-weight); + color: var(--in-content-button-text-color); + border: 1px solid var(--in-content-button-border-color); + border-radius: 4px; + background-color: var(--in-content-button-background); + padding: var(--button-padding); + box-sizing: border-box; + min-height: var(--button-min-height); + text-decoration: none; + display: flex; + align-items: center; + gap: 8px; + white-space: nowrap; +} + +#yec-donate-link > * { + flex: 0 0 auto; +} + +#yec-donate-link:hover { + background-color: var(--in-content-button-background-hover); + color: var(--in-content-button-text-color-hover); + border-color: var(--in-content-button-border-color-hover); +} + +#yec-donate-link:hover:active { + background-color: var(--in-content-button-background-active); + color: var(--in-content-button-text-color-active); + border-color: var(--in-content-button-border-color-active); +} + +#yec-donate-icon { + -moz-context-properties: fill; + fill: currentColor; +} + +#yec-close { + position: absolute; + inset-block-start: 16px; + inset-inline-end: 16px; +} + +@media (max-width: 768px) { + /* Small width layout. */ + #yec-banner { + grid-template: + "yec-image" min-content + "yec-heading" auto + "yec-body" auto + "yec-matching" auto + "yec-donate" min-content + / 1fr; + padding-block: 31px 39px; + padding-inline: 15px; + /* Match max-width of the form. */ + max-width: var(--form-max-width); + margin-block-end: 32px; + } + + #yec-image { + height: 156px; + } + + #yec-heading { + margin-block-start: 16px; + text-align: center; + text-wrap-style: balance; + } + + #yec-heading { + font-size: 3.5rem; + } + + #yec-matching { + margin-block-end: 16px; + } + + #yec-donate-link { + justify-self: center; + } +} + +@media ((prefers-contrast) or (forced-colors)) and (prefers-color-scheme: dark) { + #yec-image { + /* Give the dark image a light border to separate from background. */ + border-color: var(--in-content-box-border-color); + } +} + +@media not ((prefers-contrast) or (forced-colors)) { + #yec-banner { + border-color: transparent; + background-color: var(--yec-image-background); + --yec-text: #ffffff; + --yec-button-background: #b6e368; + --yec-button-background-hover: #d2f2a1; + --yec-button-background-active: #ecfcd8; + --yec-button-text: #15141A; + color: var(--yec-text); + } + + #yec-body-highlight { + color: var(--yec-button-background); + } + + #yec-donate-link { + --in-content-button-text-color: var(--yec-button-text); + --in-content-button-text-color-hover: var(--yec-button-text); + --in-content-button-text-color-active: var(--yec-button-text); + --in-content-button-background: var(--yec-button-background); + --in-content-button-background-hover: var(--yec-button-background-hover); + --in-content-button-background-active: var(--yec-button-background-active); + } +} diff --git a/browser/components/abouttor/content/aboutTor.html b/browser/components/abouttor/content/aboutTor.html index ddb9ae88baebc97dbc1d2c149ba06c67da9d44eb..292537056b33e681c35291b01cd8809794a14fae 100644 --- a/browser/components/abouttor/content/aboutTor.html +++ b/browser/components/abouttor/content/aboutTor.html @@ -4,7 +4,7 @@
+ +
+ + + +This license applies to embedded "Jacquard 12" font in browser/components/abouttor/content/yec2025-font.css.
+ Copyright 2023 The Soft Type Project Authors (https://github.com/scfried/soft-type-jacquard) + + This Font Software is licensed under the SIL Open Font License, Version 1.1. + This license is copied below, and is also available with a FAQ at: + https://openfontlicense.org + + + ----------------------------------------------------------- + SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 + ----------------------------------------------------------- + + PREAMBLE + The goals of the Open Font License (OFL) are to stimulate worldwide + development of collaborative font projects, to support the font creation + efforts of academic and linguistic communities, and to provide a free and + open framework in which fonts may be shared and improved in partnership + with others. + + The OFL allows the licensed fonts to be used, studied, modified and + redistributed freely as long as they are not sold by themselves. The + fonts, including any derivative works, can be bundled, embedded, + redistributed and/or sold with any software provided that any reserved + names are not used by derivative works. The fonts and derivatives, + however, cannot be released under any other type of license. The + requirement for fonts to remain under this license does not apply + to any document created using the fonts or their derivatives. + + DEFINITIONS + "Font Software" refers to the set of files released by the Copyright + Holder(s) under this license and clearly marked as such. This may + include source files, build scripts and documentation. + + "Reserved Font Name" refers to any names specified as such after the + copyright statement(s). + + "Original Version" refers to the collection of Font Software components as + distributed by the Copyright Holder(s). + + "Modified Version" refers to any derivative made by adding to, deleting, + or substituting -- in part or in whole -- any of the components of the + Original Version, by changing formats or by porting the Font Software to a + new environment. + + "Author" refers to any designer, engineer, programmer, technical + writer or other person who contributed to the Font Software. + + PERMISSION & CONDITIONS + Permission is hereby granted, free of charge, to any person obtaining + a copy of the Font Software, to use, study, copy, merge, embed, modify, + redistribute, and sell modified and unmodified copies of the Font + Software, subject to the following conditions: + + 1) Neither the Font Software nor any of its individual components, + in Original or Modified Versions, may be sold by itself. + + 2) Original or Modified Versions of the Font Software may be bundled, + redistributed and/or sold with any software, provided that each copy + contains the above copyright notice and this license. These can be + included either as stand-alone text files, human-readable headers or + in the appropriate machine-readable metadata fields within text or + binary files as long as those fields can be easily viewed by the user. + + 3) No Modified Version of the Font Software may use the Reserved Font + Name(s) unless explicit written permission is granted by the corresponding + Copyright Holder. This restriction only applies to the primary font name as + presented to the users. + + 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font + Software shall not be used to promote, endorse or advertise any + Modified Version, except to acknowledge the contribution(s) of the + Copyright Holder(s) and the Author(s) or with their explicit written + permission. + + 5) The Font Software, modified or unmodified, in part or in whole, + must be distributed entirely under this license, and must not be + distributed under any other license. The requirement for fonts to + remain under this license does not apply to any document created + using the Font Software. + + TERMINATION + This license becomes null and void if any of the above conditions are + not met. + + DISCLAIMER + THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE + COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL + DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM + OTHER DEALINGS IN THE FONT SOFTWARE. ++