summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/demobrowser/browserapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webenginewidgets/demobrowser/browserapplication.cpp')
-rw-r--r--examples/webenginewidgets/demobrowser/browserapplication.cpp101
1 files changed, 28 insertions, 73 deletions
diff --git a/examples/webenginewidgets/demobrowser/browserapplication.cpp b/examples/webenginewidgets/demobrowser/browserapplication.cpp
index 37bc05c34..0d5c54199 100644
--- a/examples/webenginewidgets/demobrowser/browserapplication.cpp
+++ b/examples/webenginewidgets/demobrowser/browserapplication.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -62,7 +72,6 @@
#include <QtNetwork/QLocalServer>
#include <QtNetwork/QLocalSocket>
#include <QtNetwork/QNetworkProxy>
-#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QSslSocket>
#include <QWebEngineProfile>
@@ -289,6 +298,21 @@ void BrowserApplication::loadSettings()
defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString());
defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString());
+
+ switch (settings.value(QLatin1String("faviconDownloadMode"), 1).toInt()) {
+ case 0:
+ defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false);
+ break;
+ case 1:
+ defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
+ defaultSettings->setAttribute(QWebEngineSettings::TouchIconsEnabled, false);
+ break;
+ case 2:
+ defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
+ defaultSettings->setAttribute(QWebEngineSettings::TouchIconsEnabled, true);
+ break;
+ }
+
settings.endGroup();
settings.beginGroup(QLatin1String("cookies"));
@@ -490,10 +514,6 @@ QNetworkAccessManager *BrowserApplication::networkAccessManager()
{
if (!s_networkAccessManager) {
s_networkAccessManager = new QNetworkAccessManager();
- connect(s_networkAccessManager, &QNetworkAccessManager::authenticationRequired,
- BrowserApplication::instance(), &BrowserApplication::authenticationRequired);
- connect(s_networkAccessManager, &QNetworkAccessManager::proxyAuthenticationRequired,
- BrowserApplication::instance(), &BrowserApplication::proxyAuthenticationRequired);
}
return s_networkAccessManager;
}
@@ -552,68 +572,3 @@ void BrowserApplication::setPrivateBrowsing(bool privateBrowsing)
}
emit privateBrowsingChanged(privateBrowsing);
}
-
-void BrowserApplication::setLastAuthenticator(QAuthenticator *authenticator)
-{
- m_lastAuthenticator = QAuthenticator(*authenticator);
-}
-
-void BrowserApplication::setLastProxyAuthenticator(QAuthenticator *authenticator)
-{
- m_lastProxyAuthenticator = QAuthenticator(*authenticator);
-}
-
-void BrowserApplication::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
-{
- if (m_lastAuthenticator.isNull())
- return;
-
-
- Q_ASSERT(m_lastAuthenticator.option("key").isValid());
- QByteArray lastKey = m_lastAuthenticator.option("key").toByteArray();
- QByteArray key = BrowserApplication::authenticationKey(reply->url(), authenticator->realm());
-
- if (lastKey == key)
- *authenticator = m_lastAuthenticator;
-}
-
-void BrowserApplication::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
-{
- if (m_lastProxyAuthenticator.isNull())
- return;
-
- QNetworkProxy::ProxyType proxyType = proxy.type();
- if (proxyType != QNetworkProxy::HttpProxy || proxyType != QNetworkProxy::HttpCachingProxy)
- return;
-
- Q_ASSERT(m_lastProxyAuthenticator.option("host").isValid());
- QByteArray lastKey = m_lastProxyAuthenticator.option("key").toByteArray();
- QByteArray key = BrowserApplication::proxyAuthenticationKey(proxy, authenticator->realm());
-
- if (lastKey == key)
- *authenticator = m_lastAuthenticator;
-}
-
-// TODO: Remove these functions (QTBUG-47967)
-QByteArray BrowserApplication::authenticationKey(const QUrl &url, const QString &realm)
-{
- QUrl copy = url;
- copy.setFragment(realm);
- return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery);
-}
-
-QByteArray BrowserApplication::proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm)
-{
- QString host = QString("%1:%2").arg(proxy.hostName()).arg(proxy.port());
- return BrowserApplication::proxyAuthenticationKey(proxy.user(), host, realm);
-}
-
-QByteArray BrowserApplication::proxyAuthenticationKey(const QString &user, const QString &host, const QString &realm)
-{
- QUrl key;
- key.setScheme(QLatin1String("proxy-http"));
- key.setUserName(user);
- key.setHost(host);
- key.setFragment(realm);
- return "auth:" + key.toEncoded();
-}