Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Website Permissions #165

Merged
merged 36 commits into from
Aug 12, 2021
Merged

Website Permissions #165

merged 36 commits into from
Aug 12, 2021

Conversation

mallexxx
Copy link
Collaborator

@mallexxx mallexxx commented Jul 28, 2021

Task/Issue URL: https://app.asana.com/0/1199237043630360/1200191553434234/f
Tech Design URL: https://app.asana.com/0/1199237043630360/1200503074536077/f
CC: @tomasstrba

Description:
This PR brings Geolocation, Camera and Microphone WebSite Permissions

Steps to test this PR:

  1. Websites used for testing: https://permission.site/ https://www.zpeed.in/ https://www.onlinemictest.com/ https://www.google.com/maps
  2. Grant/Deny a permission using a Permission Icon Context Menu
  3. Validate Camera&Mic are displayed under one icon when both in use
  4. Validate a Tab Icon is displayed for cam&mic Permissions used in background
  5. Fire Button should clear permanent permissions except for the Fireproofed
  6. Geolocation permission should not be persisted, should not work on background tabs, should not work while the App is in background

Use sudo /usr/libexec/PlistBuddy -c 'Delete com.duckduckgo.macos.browser.debug' /var/db/locationd/clients.plist ; sudo killall -HUP locationd to reset System Geolocation permission, sudo tccutil reset Camera com.duckduckgo.macos.browser.debug to reset Camera/Microphone permissions


Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

@mallexxx mallexxx changed the title Alex/permissions Website Permissions Jul 28, 2021
Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mallexxx I looked at code from the high perspective and it looks great! 🥇 This is not a trivial problem when we consider edge cases and private API usage, but you did a really great job! The architecture looks good to me.

I’ll do a testing and second pass focused on details tomorrow.

@@ -41,4 +42,13 @@ extension NSApplication {
return event.keyCode == 36 || event.keyCode == 76
}

func isActivePublisher() -> AnyPublisher<Bool, Never> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 this is a gem

@mallexxx mallexxx requested a review from tomasstrba August 9, 2021 09:07
Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT! 👍 I only found few minor issues and have couple of questions below but other than that it is awesome!!! 🥇 🎖️ 🏅
The architecture and technical solution is really great! Good job Alex! 👏 👏 👏

  1. Is this behavior intentional when using only microphone permissions?

weird state when allowing just microphone

  1. Is the icon for geolocation right? Should’t it be filled?

icon

@@ -1577,6 +1656,9 @@
4B723DEA26B0002B00E14D75 /* Data Import */,
4B723DF826B0002B00E14D75 /* Data Export */,
4B65143C26392483005B46EB /* Email */,
B64C84DB2692D6E80048FEBE /* Permissions */,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a tiny detail, could you preserve alphabetical order?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never noticed it was alphabetical :)

}
}

func revokePermissions(_ permissions: [PermissionType], completionHandler: (() -> Void)? = nil) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

}

@objc(_webView:mediaCaptureStateDidChange:)
func webView(_ webView: WKWebView, mediaCaptureStateDidChange state: _WKMediaCaptureStateDeprecated) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce this multiple times. 1. I visited https://permission.site/ 2. allowed geolocation, mic, camera and closed the tab.
Screenshot 2021-08-09 at 17 31 04

alistairjcbrown and others added 5 commits August 10, 2021 13:44
* Bring in using references to local build

* Pull in privacy dashboard as submodule

* Tracker info for the privacy dashboard

* ServerTrustViewModel for the privacy dashboard

* Tracker info and server trust encoded to JSON for JS layer. Enabling web inspector for the privacy dashboard

* Update tracker data

* Fix after rebase

* Fix to add back in script handlers

* Update submodules

* Update to get working on latest macOS and pull in latest dashboard build

* Remove macOS version checks and update privacy dashboard

* Fix adding handler not content world

* Update privacy dashboard to main branch

Co-authored-by: Tomas Strba <tom@duckduckgo.com>
@mallexxx
Copy link
Collaborator Author

Is this behavior intentional when using only microphone permissions?

No, it's a bug, good catch! 👍

Is the icon for geolocation right? Should’t it be filled?

This behaviour is correct because it's a one-shot getCurrentPosition Geolocation usage; To get the filled Geolocation icon watchPosition API should be used, it can be tested on zpeed.in
But it's a good catch that Pause shouldn't be present on the Inactive icons, I fixed it and also added Revoke Menu Items for both active and inactive permissions

@mallexxx mallexxx merged commit ba57b8a into develop Aug 12, 2021
@mallexxx mallexxx deleted the alex/permissions branch August 12, 2021 11:45
samsymons added a commit that referenced this pull request Aug 18, 2021
# By Alexey Martemyanov (6) and others
# Via GitHub
* develop:
  Fix geolocation in release build, minor fixes (#198)
  Basic Auth (#200)
  Fix PDF saving (#194)
  Support printing for macOS<11.0; Fix printing to PDF (#196)
  Version 0.14.1
  User agent updated
  Update BrowserServicesKit to 7.1.2 (#192)
  Friday Party (#197)
  Version 0.14.0
  Quick privacy icon animation (#188)
  Website Permissions (#165)
  Go back to close Child Tab (#187)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants