Flatten util/IncognitoBrowser.{h,c}pp (#4280)

This commit is contained in:
pajlada 2023-01-01 13:06:34 +01:00 committed by GitHub
parent 1043f9f803
commit e48945e370
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 57 deletions

View file

@ -1,12 +1,14 @@
#include "IncognitoBrowser.hpp"
#include "util/IncognitoBrowser.hpp"
#include <QProcess>
#include <QRegularExpression>
#include <QSettings>
#include <QVariant>
namespace chatterino {
namespace {
using namespace chatterino;
#ifdef Q_OS_WIN
QString injectPrivateSwitch(QString command)
{
@ -55,18 +57,22 @@ namespace {
.toString();
// get default browser start command
auto command = QSettings("HKEY_CLASSES_ROOT\\" + browserId +
"\\shell\\open\\command",
auto command =
QSettings("HKEY_CLASSES_ROOT\\" + browserId + "\\shell\\open\\command",
QSettings::NativeFormat)
.value("Default")
.toString();
if (command.isNull())
{
return QString();
}
// inject switch to enable private browsing
command = injectPrivateSwitch(command);
if (command.isNull())
{
return QString();
}
// link
command += " " + link;
@ -74,8 +80,11 @@ namespace {
return command;
}
#endif
} // namespace
namespace chatterino {
bool supportsIncognitoLinks()
{
#ifdef Q_OS_WIN

View file

@ -1,6 +1,6 @@
#pragma once
#include <QtGlobal>
#include <QString>
namespace chatterino {