Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling external schemes in address bar #493

Merged
merged 9 commits into from
Apr 1, 2022

Conversation

ayoy
Copy link
Collaborator

@ayoy ayoy commented Mar 31, 2022

Task/Issue URL: https://app.asana.com/0/inbox/1201621708108816/1202055192971137/1202055303685720/f
Tech Design URL:
CC:

Description:
The original issue is about define:foo being recognized as an external URL (with define: scheme) and not triggering a search, but instead opening a blank page. I realized that other external URLs don't work either when typed directly into the address bar. I figured out that it's because of a recently modified code in Tab.swift which allows for handling external URLs (optionally converting them to search URLs if they can't be handled by NSWorkspace) only when the source of a navigation is the main frame. However, when user enters a URL into the address bar, the source of navigation is not main frame either, so I handled it by checking that navigation type is .other (which covers manually input URLs).

Steps to test this PR:

  1. Verify that define:foo triggers a search
  2. Verify that Zoom links still work
  3. Verify that sms://+44123123123 tries to open Messages.app
  4. Verify that mailto:[email protected] tries to open a system default Mail app
  5. Verify that test://hello triggers a search, because this scheme is not supported by any app in the system

Testing checklist:

  • Test with Release configuration
  • Test proper deallocation of tabs
  • Make sure committed submodule changes are desired

Internal references:

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

@mallexxx mallexxx self-assigned this Mar 31, 2022
@ayoy ayoy force-pushed the dominik/external-schemes-in-address-bar branch from 08045d9 to 9c991d4 Compare March 31, 2022 12:02
Copy link
Collaborator

@mallexxx mallexxx left a comment

Choose a reason for hiding this comment

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

Looks good overall, but one test case fails:

@ayoy ayoy assigned ayoy and unassigned mallexxx Mar 31, 2022
Scenario:
1. Enter `mailto:[email protected]`, submit: confirmation popover appears
2. Without reloading the page, enter a search phrase in the address bar
3. The search is performed for `mailto:[email protected]`

This is caused by PermissionAuthorizationQuery deinitializer
which calls decisionHandler that ends up requesting a search
for the external URL. The query is deinitialized when the new search
phrase is submitted and the sequence of events is following:
1. make search URL for the search phrase
2. make search URL for the external URL from a deinitialized PermissionAuthorizationQuery
The latter overrides the search phrase and that's how the bug is
observed.

I updated PermissionModel.queryAuthorization to not call its decision
handler at all when decision from query is `.deinitialized`.
@ayoy ayoy assigned mallexxx and unassigned ayoy Apr 1, 2022
@ayoy ayoy requested a review from mallexxx April 1, 2022 07:03
ayoy added 3 commits April 1, 2022 09:32
Verify that when the query is reset (deinitialized)
then decision handler is not called at all.
Copy link
Collaborator

@mallexxx mallexxx left a comment

Choose a reason for hiding this comment

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

LGTM! Wonderful! 🏅
May I ask adding the following changes before you merge in order to improve memory usage:

  • add (item as? TabBarViewItem)?.clear() to collectionView:didEndDisplayingItem:forRepresentedObjectAtIndexPath: in TabBarViewController.swift
  • add usedPermissions = Permissions() to TabBarViewItem.clear() method
  • change clearSubscriptions() method to cancellables.removeAll()
    This will clear usedPermissions as soon as Tab is closed and so deallocate the Permission Query without delays

@mallexxx mallexxx assigned ayoy and unassigned mallexxx Apr 1, 2022
@ayoy
Copy link
Collaborator Author

ayoy commented Apr 1, 2022

@mallexxx is seems that the changes you asked me to make fixed the visual glitch in the address bar 🚀

@ayoy ayoy merged commit ffa7bc4 into develop Apr 1, 2022
@ayoy ayoy deleted the dominik/external-schemes-in-address-bar branch April 1, 2022 15:26
samsymons added a commit that referenced this pull request Apr 4, 2022
# By Tomas Strba (5) and others
# Via GitHub
* develop:
  Refresh the Autofill panel after importing (#496)
  Require authentication for login export (#494)
  Observations database clearing improvements (#495)
  Fix handling external schemes in address bar (#493)
  New autoconsent rules and move tab cleanup out of onCommitted (#489)
  Safari CSV Passwords import +LastPass, 1Password (#483)
  Split preferences into multiple screens and add an option to show full URL (#487)
  Color of hover label fixed (#497)
  Add AMP links protection (#488)
  Enhancements of fire button options (#484)
  Rename Logins+ to Autofill (#492)
  new tab page low hanging fruit (#491)
  Fix threading issues in Autoconsent (#478)
  Navigation bar improvement: CMD + back or CMD + forward opens a new tab (#486)
  TextField refactored to TextView in order to make it scrollable (#481)
  More Xcode cleaning (#485)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants