Commit 97981b21 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Detect Vivaldi based on binary name

Vivaldi no longer includes its name in the User Agent, see [1].
Try detecting it based on binary name instead.
This could perhaps also be used to detect other chromium-based browsers such as Brave.

[1] https://vivaldi.com/blog/user-agent-changes/

Differential Revision: https://phabricator.kde.org/D28893
parent 5a5369a0
......@@ -25,6 +25,7 @@ Widgets
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
KIO
I18n
CoreAddons
Config
Crash
DBusAddons
......
......@@ -28,6 +28,7 @@ target_link_libraries(
Qt5::Gui
Qt5::Widgets
KF5::Activities
KF5::CoreAddons
KF5::Crash
KF5::I18n
KF5::KIOCore
......
......@@ -23,10 +23,14 @@
#include "settings.h"
#include <unistd.h> // getppid
#include <QGuiApplication>
#include <QDBusConnection>
#include <QProcess>
#include <KProcessList>
#include "pluginmanager.h"
#include "settingsadaptor.h"
......@@ -127,6 +131,16 @@ void Settings::handleData(const QString &event, const QJsonObject &data)
QProcess::startDetached(QStringLiteral("kcmshell5"), {QStringLiteral("kcm_plasmasearch")});
} else if (event == QLatin1String("setEnvironment")) {
QString name = data[QStringLiteral("browserName")].toString();
// Most chromium-based browsers just impersonate Chromium nowadays to keep websites from locking them out
// so we'll need to make an educated guess from our parent process
if (name == QLatin1String("chromium")) {
const auto processInfo = KProcessList::processInfo(getppid());
if (processInfo.name().contains(QLatin1String("vivaldi"))) {
name = QStringLiteral("vivaldi");
}
}
m_environment = Settings::environmentNames.key(name, Settings::Environment::Unknown);
m_currentEnvironment = Settings::environmentDescriptions.value(m_environment);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment