Bring back per-domain user agent settings

remotes/origin/falkon
David Rosca 9 years ago
parent a16cb5f4e0
commit ce3f50f50d
  1. 9
      src/lib/network/networkurlinterceptor.cpp
  2. 9
      src/lib/other/useragentmanager.cpp
  3. 9
      src/lib/preferences/useragentdialog.cpp

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - QtWebEngine based browser
* Copyright (C) 2015 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2015-2017 David Rosca <nowrep@gmail.com>
*
* 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
@ -15,10 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "networkurlinterceptor.h"
#include "urlinterceptor.h"
#include "settings.h"
#include "mainapplication.h"
#include "useragentmanager.h"
NetworkUrlInterceptor::NetworkUrlInterceptor(QObject *parent)
: QWebEngineUrlRequestInterceptor(parent)
@ -31,6 +32,8 @@ void NetworkUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
if (m_sendDNT)
info.setHttpHeader(QByteArrayLiteral("DNT"), QByteArrayLiteral("1"));
info.setHttpHeader(QByteArrayLiteral("User-Agent"), mApp->userAgentManager()->userAgentForUrl(info.firstPartyUrl()).toUtf8());
foreach (UrlInterceptor *interceptor, m_interceptors) {
interceptor->interceptRequest(info);
}

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
*
* 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
@ -61,6 +61,9 @@ QString UserAgentManager::userAgentForUrl(const QUrl &url) const
const QString host = url.host();
if (m_usePerDomainUserAgent) {
if (m_userAgentsList.contains(host)) {
return m_userAgentsList.value(host);
}
QHashIterator<QString, QString> i(m_userAgentsList);
while (i.hasNext()) {
i.next();
@ -70,7 +73,7 @@ QString UserAgentManager::userAgentForUrl(const QUrl &url) const
}
}
return m_globalUserAgent;
return QWebEngineProfile::defaultProfile()->httpUserAgent();
}
QString UserAgentManager::globalUserAgent() const

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
*
* 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
@ -85,11 +85,6 @@ UserAgentDialog::UserAgentDialog(QWidget* parent)
enableGlobalComboBox(ui->changeGlobal->isChecked());
enablePerSiteFrame(ui->changePerSite->isChecked());
#if !QTWEBENGINE_DISABLED
ui->perSiteFrame->setVisible(false);
ui->changePerSite->setVisible(false);
#endif
}
void UserAgentDialog::addSite()

Loading…
Cancel
Save