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

Add support for opening links in incognito mode on Linux & BSD #4745

Merged
merged 35 commits into from
Aug 6, 2023

Conversation

sheybey
Copy link
Contributor

@sheybey sheybey commented Aug 2, 2023

Description

This PR adds support for opening links in private/incognito mode under Linux/BSD when using a desktop environment that follows the freedesktop specification. See #4366

List of technical changes

  • Add private switches for firefox-esr and chromium
  • Get only the browser executable name instead of the full command line on windows (to match new behavior under linux)
  • Implement XDG specs for reading desktop files and finding default applications
  • ego check (add myself to contributors.txt)

Discussion points

I originally thought that you could read desktop files, which are essentially .ini files, with QSettings. However, the default app database (which is a desktop file) uses mimetypes as key names, which is incompatible with QSettings as the key may include /. I wrote a parser for them which didn't end up bigger than the code consuming it, so I feel comfortable still not adding another dependency for this. That being said, it should probably get as many eyes on it as possible since it is still a home-rolled parser.

Some other points I would appreciate opinions on:

  • XDGDesktopFile: is returning a static empty group for non-existent groups the right move here? std::optional instead?
  • IncognitoBrowser.cpp: I didn't change too much of this implementation, which means that getDefaultBrowserExecutable is called twice per settings open. Is a big search like this PR adds worth caching?
  • The XDG spec allows for multiple defaults listed by preference. This implementation just returns the first one, and if chatterino doesn't know how to open it in private mode, it gives up immediately. Could try to fall back to the next default if there is one, but this might end up seemingly ignoring whatever the user set in their DE if we don't support it.

I've tested this under Windows (for the minor behavior change) and under Debian testing with gnome. Throw your hairiest setups at this and let me know if anything breaks.

sheybey added 2 commits August 2, 2023 13:03
- don't use .leftRef/.splitRef
- use QStringView where applicable
@sheybey sheybey force-pushed the linux-open-incognito branch from ca93b88 to c1b7258 Compare August 2, 2023 17:03
sheybey added 4 commits August 2, 2023 13:39
add Qt.hpp helper include to XDGDirectory.cpp
before this change, this ::mid call would have resulted in undefined
behavior when running under Qt older than 5.15 on a key with an empty
value (equals sign at the end of the line)
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/util/IncognitoBrowser.cpp Show resolved Hide resolved
src/util/XDGHelper.cpp Outdated Show resolved Hide resolved
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

Looked through everything except XDGHelper so far, other than some nitpicks that I've fixed myself it looks fine 👍

@pajlada pajlada self-requested a review August 5, 2023 15:59
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

Works as expected for me now. If you can think of some other tests, please add them.
Please also read through the commits I've done and see if there's anything I've misunderstood

When you're happy to have this merged in, let us know and we'll hit the merge button

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/util/IncognitoBrowser.cpp Show resolved Hide resolved
src/util/XDGHelper.cpp Show resolved Hide resolved
tests/src/XDGHelper.cpp Show resolved Hide resolved
- paths with spaces in them
- paths with characters reserved by spec
@sheybey
Copy link
Contributor Author

sheybey commented Aug 6, 2023

Works as expected for me now. If you can think of some other tests, please add them. Please also read through the commits I've done and see if there's anything I've misunderstood

Done and done. Looks good to me

@pajlada pajlada changed the title Add support for opening links in incognito mode under Linux/BSD Add support for opening links in incognito mode on Linux & BSD Aug 6, 2023
@pajlada pajlada merged commit 69c983e into Chatterino:master Aug 6, 2023
Nerixyz pushed a commit to Nerixyz/chatterino2 that referenced this pull request Aug 12, 2023
…erino#4745)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
Nerixyz pushed a commit to Nerixyz/chatterino2 that referenced this pull request Aug 19, 2023
…erino#4745)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
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.

3 participants