diff --git a/src/lib/other/useragentmanager.cpp b/src/lib/other/useragentmanager.cpp index ddcf70cb4..96ef1beb5 100644 --- a/src/lib/other/useragentmanager.cpp +++ b/src/lib/other/useragentmanager.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca +* Copyright (C) 2010-2015 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,13 +20,12 @@ #include "qztools.h" #include "settings.h" -#include // QTWEBKIT_VERSION_CHECK macro +#include UserAgentManager::UserAgentManager(QObject* parent) : QObject(parent) , m_usePerDomainUserAgent(false) { - m_fakeUserAgent = QString("Mozilla/5.0 (%1) AppleWebKit/%2 (KHTML, like Gecko) Chrome/37.0 Safari/537.36").arg(QzTools::operatingSystem()); } void UserAgentManager::loadSettings() @@ -49,6 +48,13 @@ void UserAgentManager::loadSettings() m_userAgentsList[domainList.at(i)] = userAgentsList.at(i); } } + + QString userAgent = m_globalUserAgent; + if (userAgent.isEmpty()) { + userAgent = QWebEngineProfile::defaultProfile()->httpUserAgent(); + userAgent.replace(QSL("QtWebEngine/%1").arg(qVersion()), QSL("QupZilla/%1").arg(Qz::VERSION)); + } + QWebEngineProfile::defaultProfile()->setHttpUserAgent(userAgent); } QString UserAgentManager::userAgentForUrl(const QUrl &url) const @@ -65,19 +71,6 @@ QString UserAgentManager::userAgentForUrl(const QUrl &url) const } } -#if QTWEBKIT_TO_2_3 - if (host.contains(QLatin1String("google"))) { - return m_fakeUserAgent; - } -#endif - -#ifdef Q_OS_WIN - // Facebook chat is not working with default user-agent - if (host.endsWith(QLatin1String("facebook.com"))) { - return "Mozilla/5.0 (Windows XP) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7"; - } -#endif - return m_globalUserAgent; } diff --git a/src/lib/other/useragentmanager.h b/src/lib/other/useragentmanager.h index 68bd8f96c..0ba0a0066 100644 --- a/src/lib/other/useragentmanager.h +++ b/src/lib/other/useragentmanager.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca +* Copyright (C) 2010-2015 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,6 @@ public: private: QString m_globalUserAgent; - QString m_fakeUserAgent; bool m_usePerDomainUserAgent; QHash m_userAgentsList;