Skip to content

Commit

Permalink
Phishing Detection Privacy Dashboard Entrypoint (#3195)
Browse files Browse the repository at this point in the history
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

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

**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)
  • Loading branch information
not-a-rootkit authored Sep 5, 2024
1 parent 58b70bc commit a0f2843
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 10 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */,
Expand Down Expand Up @@ -5259,6 +5260,7 @@
isa = PBXGroup;
children = (
9D9DE5712C63A96400D20B15 /* AppKitExtensions */,
CDE2489E2C821DE800F9399D /* BrowserServicesKit */,
7B9167A82C09E88800322310 /* AppLauncher */,
378E279D2970217400FCADA2 /* BuildToolPlugins */,
3192A2702A4C4E330084EA89 /* DataBrokerProtection */,
Expand Down
38 changes: 38 additions & 0 deletions DuckDuckGo/Assets.xcassets/Colors/AlertRed.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
32 changes: 22 additions & 10 deletions DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a0f2843

Please sign in to comment.