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

Search with DuckDuckGo in PDF Context Menu #323

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

mallexxx
Copy link
Collaborator

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

Description:
Fixes "Search With %@" in PDF Plugin opening text search in Safari

Steps to test this PR:

  1. Open a PDF (https://www.apple.com/ca/mac/docs/Apple_T2_Security_Chip_Overview.pdf)
  2. Right-click a text, click "Search With DuckDuckGo" - should open new tab with SERP
  3. Open Safari Preferences, change Default Search Engine to something else, validate the PDF menu still displays "Search With DuckDuckGo"
  4. Validate other PDF Context Menu items are working as intended, including when clicking an empty space

Testing checklist:

  • Test with Release configuration

Internal references:

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

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.

LGTM! Awesome fix, thanks for diving deep into this! 👍 💯 🥇 I only have super tiny comments about code organization that are absolutely not important :D


import Foundation

final class PDFSearchTextMenuItemHandler: NSObject {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very tiny detail I've noticed. This class is not an extension, maybe View instead of Extensions folder is the better location?

final class MainView: NSView {
private typealias CFWebServicesCopyProviderInfoType = @convention(c) (CFString, UnsafeRawPointer?) -> NSDictionary?

// PDF Plugin context menu
Copy link
Contributor

Choose a reason for hiding this comment

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

Super not important, but good practice into the future as well. Sometimes instead of comment, it's good to wrap actions inside method.
func willOpenMenu() {
editSearchMenuItem()
}
Advantages are:

  • less comments
  • you can add more actions into the willOpenMenu and readers understand there is no relation between them

The goal is basically to understand what is happening without the need of reading the whole class

@tomasstrba tomasstrba assigned mallexxx and unassigned tomasstrba Nov 16, 2021
@mallexxx mallexxx merged commit 6f8907c into develop Nov 17, 2021
@mallexxx mallexxx deleted the alex/pdf-search-with-ddg branch November 17, 2021 04:52
samsymons added a commit that referenced this pull request Nov 22, 2021
* develop:
  Avoid using a specific browser as the default. (#341)
  Closing animation duration changed to 0.15 (#333)
  Hiding the favicon view when favicon is nil (#326)
  export bookmarks (#339)
  Ensure ITP database is cleared (#328)
  Execute print user script in page content world (#238)
  move the next/previous handlers to the main view controller (#331)
  Search with DuckDuckGo in PDF Context Menu (#323)
  Fix  Back button takes to r.duckduckgo.com (#321)
  Track the existing print handler to avoid DoS attacks. (#330)
  Minor copy fixes (#325)
  support cmd-option-left/right for navigating tabs (#324)
  Version 0.17.5
  Debounce privacy entry point update (#309)
  Change major tracker network threshold (#319)
  Check for click handler on printing user script (#318)
  Fix Homepage navigation (#322)
samsymons added a commit that referenced this pull request Nov 25, 2021
* develop: (23 commits)
  Update the credit card model + UI tweaks (#342)
  0.17.6
  Add Usage Pixel (#336)
  Bump find-in-page to latest version (#337)
  Forward delete collision with suffix resolved (#334)
  Avoid using a specific browser as the default. (#341)
  Closing animation duration changed to 0.15 (#333)
  Hiding the favicon view when favicon is nil (#326)
  export bookmarks (#339)
  Ensure ITP database is cleared (#328)
  Execute print user script in page content world (#238)
  move the next/previous handlers to the main view controller (#331)
  Search with DuckDuckGo in PDF Context Menu (#323)
  Fix  Back button takes to r.duckduckgo.com (#321)
  Track the existing print handler to avoid DoS attacks. (#330)
  Minor copy fixes (#325)
  support cmd-option-left/right for navigating tabs (#324)
  Version 0.17.5
  Debounce privacy entry point update (#309)
  Change major tracker network threshold (#319)
  ...
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