From 52d747735d92907db738e3f562fbb31c6a6e6bb8 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Mon, 23 Dec 2024 16:53:06 +0000 Subject: [PATCH] Windows support for Malicious website protection --- special-pages/index.mjs | 1 + .../app/components/AdvancedInfo.module.css | 24 ++++++--- .../app/components/App.module.css | 21 ++++++-- .../app/components/Components.jsx | 13 ++--- .../special-error/app/components/Warning.jsx | 50 +++++++++++++------ .../app/components/Warning.module.css | 50 ++++++++++++++++++- .../app/providers/SettingsProvider.jsx | 5 ++ .../special-error/app/styles/variables.css | 5 -- .../pages/special-error/src/inline.js | 2 +- .../pages/special-error/src/mock-transport.js | 3 +- .../shared/components/Button/Button.js | 20 +++++--- .../shared/components/Text/Text.module.css | 18 +++++++ 12 files changed, 165 insertions(+), 47 deletions(-) diff --git a/special-pages/index.mjs b/special-pages/index.mjs index 2e5d9f157..d063ada5e 100644 --- a/special-pages/index.mjs +++ b/special-pages/index.mjs @@ -50,6 +50,7 @@ export const support = { 'special-error': { integration: ['copy', 'build-js'], apple: ['copy', 'build-js', 'inline-html'], + windows: ['copy', 'build-js', 'inline-html'], }, /** @type {Partial>} */ 'new-tab': { diff --git a/special-pages/pages/special-error/app/components/AdvancedInfo.module.css b/special-pages/pages/special-error/app/components/AdvancedInfo.module.css index 3cfeb1107..641066f59 100644 --- a/special-pages/pages/special-error/app/components/AdvancedInfo.module.css +++ b/special-pages/pages/special-error/app/components/AdvancedInfo.module.css @@ -49,14 +49,6 @@ /* Platform-specific styles */ -/* macOS */ -[data-platform-name="macos"] { - & .container { - background: var(--advanced-info-bg); - box-shadow: inset 0 1px 0 0 var(--border-color); - } -} - /* iOS */ [data-platform-name="ios"] { & .wrapper { @@ -90,3 +82,19 @@ line-height: calc(21 * var(--px-in-rem)); } } + +/* macOS */ +[data-platform-name="macos"] { + & .container { + background: var(--advanced-info-bg); + box-shadow: inset 0 1px 0 0 var(--border-color); + } +} + +/* windows */ +[data-platform-name="windows"] { + & .container { + background: var(--advanced-info-bg); + box-shadow: inset 0 1px 0 0 var(--border-color); + } +} diff --git a/special-pages/pages/special-error/app/components/App.module.css b/special-pages/pages/special-error/app/components/App.module.css index fc44c7ff3..57ccca91c 100644 --- a/special-pages/pages/special-error/app/components/App.module.css +++ b/special-pages/pages/special-error/app/components/App.module.css @@ -2,6 +2,8 @@ html, body { height: 100%; margin: 0; + + --theme-font-family: system, -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; } .main { @@ -37,6 +39,13 @@ body { /* Platform-specific styles */ +/* iOS */ +[data-platform-name="ios"] { + & .container { + align-items: center; + } +} + /* macOS */ [data-platform-name="macos"] { & .container { @@ -48,9 +57,13 @@ body { } } -/* iOS */ -[data-platform-name="ios"] { +/* Windows */ +[data-platform-name="windows"] { & .container { - align-items: center; + background: var(--container-bg); + border-radius: var(--sp-4); + border: 1px solid var(--border-color); + min-width: calc(400 * var(--px-in-rem)); + width: calc(504 * var(--px-in-rem)); } -} +} \ No newline at end of file diff --git a/special-pages/pages/special-error/app/components/Components.jsx b/special-pages/pages/special-error/app/components/Components.jsx index d59819392..ed3d3bbea 100644 --- a/special-pages/pages/special-error/app/components/Components.jsx +++ b/special-pages/pages/special-error/app/components/Components.jsx @@ -17,10 +17,11 @@ import { AdvancedInfoButton, LeaveSiteButton, Warning, WarningContent, WarningHe * @typedef {SSLExpiredCertificate|SSLInvalidCertificate|SSLSelfSignedCertificate|SSLWrongHost} SSLError */ -/** @type {Record, string>} */ +/** @type {Record, string>} */ const platforms = { - macos: 'macOS', ios: 'iOS', + macos: 'macOS', + windows: 'Windows', }; /** @@ -58,8 +59,8 @@ export function Components() { }; return ( -
-
+
+
-
+ +

Special Error Components

diff --git a/special-pages/pages/special-error/app/components/Warning.jsx b/special-pages/pages/special-error/app/components/Warning.jsx index fee264d1e..9fd04ea1a 100644 --- a/special-pages/pages/special-error/app/components/Warning.jsx +++ b/special-pages/pages/special-error/app/components/Warning.jsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import { useTypedTranslation } from '../types'; import { useMessaging } from '../providers/MessagingProvider'; import { useErrorData } from '../providers/SpecialErrorProvider'; -import { usePlatformName } from '../providers/SettingsProvider'; +import { usePlatformName, useIsMobile } from '../providers/SettingsProvider'; import { useWarningHeading, useWarningContent } from '../hooks/ErrorStrings'; import { Text } from '../../../../shared/components/Text/Text'; import { Button } from '../../../../shared/components/Button/Button'; @@ -16,15 +16,12 @@ import styles from './Warning.module.css'; */ export function AdvancedInfoButton({ onClick }) { const { t } = useTypedTranslation(); - const platformName = usePlatformName(); + const isMobile = useIsMobile(); + const buttonVariant = isMobile ? 'ghost' : 'standard'; return ( - ); } @@ -34,12 +31,22 @@ export function LeaveSiteButton() { const { messaging } = useMessaging(); const platformName = usePlatformName(); + /** @type {import('../../../../shared/components/Button/Button').ButtonProps['variant']} */ + let buttonVariant; + switch (platformName) { + case 'ios': + case 'android': + buttonVariant = 'primary'; + break; + case 'windows': + buttonVariant = 'accentBrand'; + break; + default: + buttonVariant = 'accent'; + } + return ( - ); @@ -49,11 +56,26 @@ export function WarningHeading() { const { kind } = useErrorData(); const heading = useWarningHeading(); const platformName = usePlatformName(); + const isMobile = useIsMobile(); + + /** @type {'title-2'|'title-2-emphasis'|'custom-title-1'} */ + let textVariant; + switch (platformName) { + case 'ios': + case 'android': + textVariant = 'title-2'; + break; + case 'windows': + textVariant = 'custom-title-1'; + break; + default: + textVariant = 'title-2-emphasis'; + } return (