From a0f2843cefbb0c1d549826f698e364db92a20d69 Mon Sep 17 00:00:00 2001 From: Thom Espach Date: Thu, 5 Sep 2024 15:12:03 +0100 Subject: [PATCH] Phishing Detection Privacy Dashboard Entrypoint (#3195) Task/Issue URL: https://app.asana.com/0/1199230911884351/1208149630394249/f Tech Design URL: https://app.asana.com/0/481882893211075/1207220724600204/f CC: **Description**: Implement AddressBarButtons to reflect designs from https://app.asana.com/0/0/1207896057014803/f **Steps to test this PR**: 1. Visit privacy-test-pages.site/security/badware/phishing.html 2. Ensure error page is shown 3. Click through the warning 4. Red alert circle should be shown for the privacy dashboard entrypoint button **Definition of Done**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? --- ###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) --- DuckDuckGo.xcodeproj/project.pbxproj | 2 + .../Colors/AlertRed.colorset/Contents.json | 38 +++++++++++++++++++ .../AlertRedHover.colorset/Contents.json | 38 +++++++++++++++++++ .../AlertRedPressed.colorset/Contents.json | 38 +++++++++++++++++++ .../AddressBarButtonsViewController.swift | 32 +++++++++++----- 5 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 DuckDuckGo/Assets.xcassets/Colors/AlertRed.colorset/Contents.json create mode 100644 DuckDuckGo/Assets.xcassets/Colors/AlertRedHover.colorset/Contents.json create mode 100644 DuckDuckGo/Assets.xcassets/Colors/AlertRedPressed.colorset/Contents.json diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 803b261ffc..86b8868273 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -4708,6 +4708,7 @@ EE7295E32A545B9A008C0991 /* NetworkProtection in Frameworks */, 9807F645278CA16F00E1547B /* BrowserServicesKit in Frameworks */, D6BC8AC62C5A95AA0025375B /* DuckPlayer in Frameworks */, + CDE248A02C821DF400F9399D /* PhishingDetection in Frameworks */, 987799ED299998B1005D8EB6 /* Bookmarks in Frameworks */, 1E950E3F2912A10D0051A99B /* ContentBlocking in Frameworks */, 31A3A4E32B0C115F0021063C /* DataBrokerProtection in Frameworks */, @@ -5259,6 +5260,7 @@ isa = PBXGroup; children = ( 9D9DE5712C63A96400D20B15 /* AppKitExtensions */, + CDE2489E2C821DE800F9399D /* BrowserServicesKit */, 7B9167A82C09E88800322310 /* AppLauncher */, 378E279D2970217400FCADA2 /* BuildToolPlugins */, 3192A2702A4C4E330084EA89 /* DataBrokerProtection */, diff --git a/DuckDuckGo/Assets.xcassets/Colors/AlertRed.colorset/Contents.json b/DuckDuckGo/Assets.xcassets/Colors/AlertRed.colorset/Contents.json new file mode 100644 index 0000000000..bc19d490b1 --- /dev/null +++ b/DuckDuckGo/Assets.xcassets/Colors/AlertRed.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.215", + "green" : "0.197", + "red" : "0.846" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.375", + "green" : "0.380", + "red" : "0.924" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DuckDuckGo/Assets.xcassets/Colors/AlertRedHover.colorset/Contents.json b/DuckDuckGo/Assets.xcassets/Colors/AlertRedHover.colorset/Contents.json new file mode 100644 index 0000000000..cb6f0571d0 --- /dev/null +++ b/DuckDuckGo/Assets.xcassets/Colors/AlertRedHover.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.190", + "green" : "0.172", + "red" : "0.743" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.327", + "green" : "0.330", + "red" : "0.810" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DuckDuckGo/Assets.xcassets/Colors/AlertRedPressed.colorset/Contents.json b/DuckDuckGo/Assets.xcassets/Colors/AlertRedPressed.colorset/Contents.json new file mode 100644 index 0000000000..56b8ac89d3 --- /dev/null +++ b/DuckDuckGo/Assets.xcassets/Colors/AlertRedPressed.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.178", + "green" : "0.161", + "red" : "0.696" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.307", + "green" : "0.307", + "red" : "0.759" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift b/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift index 9c3f11dfdf..55c30d32cc 100644 --- a/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift +++ b/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift @@ -496,8 +496,11 @@ final class AddressBarButtonsViewController: NSViewController { bookmarkButton.position = .right privacyEntryPointButton.position = .left } - - privacyEntryPointButton.contentTintColor = .privacyEnabled + let isFlaggedPhishing = tabViewModel?.tab.privacyInfo?.isPhishing ?? false + privacyEntryPointButton.isAnimationEnabled = !isFlaggedPhishing + privacyEntryPointButton.normalTintColor = isFlaggedPhishing ? .fireButtonRedPressed : .privacyEnabled + privacyEntryPointButton.mouseOverTintColor = isFlaggedPhishing ? .alertRedHover : privacyEntryPointButton.mouseOverTintColor + privacyEntryPointButton.mouseDownTintColor = isFlaggedPhishing ? .alertRedPressed : privacyEntryPointButton.mouseDownTintColor privacyEntryPointButton.sendAction(on: .leftMouseUp) imageButton.applyFaviconStyle() @@ -755,19 +758,28 @@ final class AddressBarButtonsViewController: NSViewController { let isNotSecure = url.scheme == URL.NavigationalScheme.http.rawValue let isCertificateValid = tabViewModel.tab.isCertificateValid ?? true - + let isFlaggedPhishing = tabViewModel.tab.privacyInfo?.isPhishing ?? false let configuration = ContentBlocking.shared.privacyConfigurationManager.privacyConfig let isUnprotected = configuration.isUserUnprotected(domain: host) let isShieldDotVisible = isNotSecure || isUnprotected || !isCertificateValid - privacyEntryPointButton.image = isShieldDotVisible ? .shieldDot : .shield - - let shieldDotMouseOverAnimationNames = MouseOverAnimationButton.AnimationNames(aqua: "shield-dot-mouse-over", - dark: "dark-shield-dot-mouse-over") - let shieldMouseOverAnimationNames = MouseOverAnimationButton.AnimationNames(aqua: "shield-mouse-over", - dark: "dark-shield-mouse-over") - privacyEntryPointButton.animationNames = isShieldDotVisible ? shieldDotMouseOverAnimationNames: shieldMouseOverAnimationNames + if isFlaggedPhishing { + privacyEntryPointButton.isAnimationEnabled = false + privacyEntryPointButton.image = .redAlertCircle16 + privacyEntryPointButton.normalTintColor = .alertRed + privacyEntryPointButton.mouseOverTintColor = .alertRedHover + privacyEntryPointButton.mouseDownTintColor = .alertRedPressed + } else { + privacyEntryPointButton.image = isShieldDotVisible ? .shieldDot : .shield + privacyEntryPointButton.isAnimationEnabled = true + + let animationNames = MouseOverAnimationButton.AnimationNames( + aqua: isShieldDotVisible ? "shield-dot-mouse-over" : "shield-mouse-over", + dark: isShieldDotVisible ? "dark-shield-dot-mouse-over" : "dark-shield-mouse-over" + ) + privacyEntryPointButton.animationNames = animationNames + } default: break }