diff --git a/examples/webenginewidgets/browser/browser.pro b/examples/webenginewidgets/browser/browser.pro index f541868568728bb09a93b5fd2f16117cd5114394..6b31d7ef29d026747a6a077861d34f7fe43f48cf 100644 --- a/examples/webenginewidgets/browser/browser.pro +++ b/examples/webenginewidgets/browser/browser.pro @@ -62,11 +62,6 @@ SOURCES += \ RESOURCES += data/data.qrc htmls/htmls.qrc -contains(DEFINES, QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) { - HEADERS += cookiejar.h networkaccessmanager.h - SOURCES += cookiejar.cpp networkaccessmanager.cpp -} - build_all:!build_pass { CONFIG -= build_all CONFIG += release diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/browser/browserapplication.cpp index 5fb8aad4c37a4564d92037f9c262b263c49c0172..84d8a0e3a0a42a7f752fd37fd071b84f3925228b 100644 --- a/examples/webenginewidgets/browser/browserapplication.cpp +++ b/examples/webenginewidgets/browser/browserapplication.cpp @@ -46,7 +46,6 @@ #include "cookiejar.h" #include "downloadmanager.h" #include "history.h" -#include "networkaccessmanager.h" #include "tabwidget.h" #include "webview.h" @@ -299,6 +298,21 @@ void BrowserApplication::loadSettings() defaultProfile->setPersistentStoragePath(pdataPath); settings.endGroup(); + + settings.beginGroup(QLatin1String("proxy")); + QNetworkProxy proxy; + if (settings.value(QLatin1String("enabled"), false).toBool()) { + if (settings.value(QLatin1String("type"), 0).toInt() == 0) + proxy = QNetworkProxy::Socks5Proxy; + else + proxy = QNetworkProxy::HttpProxy; + proxy.setHostName(settings.value(QLatin1String("hostName")).toString()); + proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt()); + proxy.setUser(settings.value(QLatin1String("userName")).toString()); + proxy.setPassword(settings.value(QLatin1String("password")).toString()); + } + QNetworkProxy::setApplicationProxy(proxy); + settings.endGroup(); } QList<BrowserMainWindow*> BrowserApplication::mainWindows() @@ -474,18 +488,10 @@ DownloadManager *BrowserApplication::downloadManager() QNetworkAccessManager *BrowserApplication::networkAccessManager() { -#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - if (!s_networkAccessManager) { - s_networkAccessManager = new NetworkAccessManager(); - s_networkAccessManager->setCookieJar(new CookieJar); - } - return s_networkAccessManager; -#else if (!s_networkAccessManager) { s_networkAccessManager = new QNetworkAccessManager(); } return s_networkAccessManager; -#endif } HistoryManager *BrowserApplication::historyManager() diff --git a/examples/webenginewidgets/browser/downloadmanager.cpp b/examples/webenginewidgets/browser/downloadmanager.cpp index 90b0cec9d400cd1c6dd286b375c4a6bcdb4b9bb8..eab28942e116dcf6639d0c3e99f82a4633a84a12 100644 --- a/examples/webenginewidgets/browser/downloadmanager.cpp +++ b/examples/webenginewidgets/browser/downloadmanager.cpp @@ -43,7 +43,6 @@ #include "autosaver.h" #include "browserapplication.h" -#include "networkaccessmanager.h" #include <math.h> diff --git a/examples/webenginewidgets/browser/networkaccessmanager.cpp b/examples/webenginewidgets/browser/networkaccessmanager.cpp deleted file mode 100644 index d2b4f827f710ed013b3aaadc63d1872bacaba385..0000000000000000000000000000000000000000 --- a/examples/webenginewidgets/browser/networkaccessmanager.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "networkaccessmanager.h" - -#include "browserapplication.h" -#include "browsermainwindow.h" - -#include <QtCore/QSettings> - -#include <QtGui/QDesktopServices> -#include <QtWidgets/QDialog> -#include <QtWidgets/QMessageBox> -#include <QtWidgets/QStyle> -#include <QtGui/QTextDocument> - -#include <QtNetwork/QAuthenticator> -#include <QtNetwork/QNetworkDiskCache> -#include <QtNetwork/QNetworkProxy> -#include <QtNetwork/QNetworkRequest> -#include <QtNetwork/QNetworkReply> -#include <QtNetwork/QSslError> - -NetworkAccessManager::NetworkAccessManager(QObject *parent) - : QNetworkAccessManager(parent), - requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0), - requestFinishedSecureCount(0), requestFinishedDownloadBufferCount(0) -{ - connect(this, SIGNAL(finished(QNetworkReply*)), - SLOT(requestFinished(QNetworkReply*))); -#ifndef QT_NO_OPENSSL - connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), - SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); -#endif - loadSettings(); - - QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); - QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - diskCache->setCacheDirectory(location); - setCache(diskCache); -} - -QNetworkReply* NetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData) -{ - QNetworkRequest request = req; // copy so we can modify - // this is a temporary hack until we properly use the pipelining flags from QtWebkit - // pipeline everything! :) - request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - return QNetworkAccessManager::createRequest(op, request, outgoingData); -} - -void NetworkAccessManager::requestFinished(QNetworkReply *reply) -{ - requestFinishedCount++; - - if (reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool() == true) - requestFinishedFromCacheCount++; - - if (reply->attribute(QNetworkRequest::HttpPipeliningWasUsedAttribute).toBool() == true) - requestFinishedPipelinedCount++; - - if (reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool() == true) - requestFinishedSecureCount++; - - if (reply->attribute(QNetworkRequest::DownloadBufferAttribute).isValid() == true) - requestFinishedDownloadBufferCount++; - - if (requestFinishedCount % 10) - return; - -#ifdef QT_DEBUG - double pctCached = (double(requestFinishedFromCacheCount) * 100.0/ double(requestFinishedCount)); - double pctPipelined = (double(requestFinishedPipelinedCount) * 100.0/ double(requestFinishedCount)); - double pctSecure = (double(requestFinishedSecureCount) * 100.0/ double(requestFinishedCount)); - double pctDownloadBuffer = (double(requestFinishedDownloadBufferCount) * 100.0/ double(requestFinishedCount)); - - qDebug("STATS [%lli requests total] [%3.2f%% from cache] [%3.2f%% pipelined] [%3.2f%% SSL/TLS] [%3.2f%% Zerocopy]", requestFinishedCount, pctCached, pctPipelined, pctSecure, pctDownloadBuffer); -#endif -} - -void NetworkAccessManager::loadSettings() -{ - QSettings settings; - settings.beginGroup(QLatin1String("proxy")); - QNetworkProxy proxy; - if (settings.value(QLatin1String("enabled"), false).toBool()) { - if (settings.value(QLatin1String("type"), 0).toInt() == 0) - proxy = QNetworkProxy::Socks5Proxy; - else - proxy = QNetworkProxy::HttpProxy; - proxy.setHostName(settings.value(QLatin1String("hostName")).toString()); - proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt()); - proxy.setUser(settings.value(QLatin1String("userName")).toString()); - proxy.setPassword(settings.value(QLatin1String("password")).toString()); - } - setProxy(proxy); -} - -#ifndef QT_NO_OPENSSL -void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error) -{ - // check if SSL certificate has been trusted already - QString replyHost = reply->url().host() + QString(":%1").arg(reply->url().port()); - if (! sslTrustedHostList.contains(replyHost)) { - BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); - - QStringList errorStrings; - for (int i = 0; i < error.count(); ++i) - errorStrings += error.at(i).errorString(); - QString errors = errorStrings.join(QLatin1String("\n")); - int ret = QMessageBox::warning(mainWindow, QCoreApplication::applicationName(), - tr("SSL Errors:\n\n%1\n\n%2\n\n" - "Do you want to ignore these errors for this host?").arg(reply->url().toString()).arg(errors), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (ret == QMessageBox::Yes) { - reply->ignoreSslErrors(); - sslTrustedHostList.append(replyHost); - } - } -} -#endif diff --git a/examples/webenginewidgets/browser/networkaccessmanager.h b/examples/webenginewidgets/browser/networkaccessmanager.h deleted file mode 100644 index f3ee2d3385ab2298df479900ede6d566ee87c074..0000000000000000000000000000000000000000 --- a/examples/webenginewidgets/browser/networkaccessmanager.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef NETWORKACCESSMANAGER_H -#define NETWORKACCESSMANAGER_H - -#include <QtNetwork/QNetworkAccessManager> -#include <QtNetwork/QNetworkRequest> - -class NetworkAccessManager : public QNetworkAccessManager -{ - Q_OBJECT - -public: - NetworkAccessManager(QObject *parent = 0); - - virtual QNetworkReply* createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 ); - -private: - QList<QString> sslTrustedHostList; - qint64 requestFinishedCount; - qint64 requestFinishedFromCacheCount; - qint64 requestFinishedPipelinedCount; - qint64 requestFinishedSecureCount; - qint64 requestFinishedDownloadBufferCount; - -public slots: - void loadSettings(); - void requestFinished(QNetworkReply *reply); - -private slots: -#ifndef QT_NO_OPENSSL - void sslErrors(QNetworkReply *reply, const QList<QSslError> &error); -#endif -}; - -#endif // NETWORKACCESSMANAGER_H diff --git a/examples/webenginewidgets/browser/settings.cpp b/examples/webenginewidgets/browser/settings.cpp index ee8c719b4e9cbef2e03e32d86fb064cffb21ca92..35e5e26c9fded583a966605c9a3abb100f3ee323 100644 --- a/examples/webenginewidgets/browser/settings.cpp +++ b/examples/webenginewidgets/browser/settings.cpp @@ -47,7 +47,6 @@ #include "cookiejar.h" #endif #include "history.h" -#include "networkaccessmanager.h" #include "webview.h" #include <QtCore/QLocale> @@ -240,7 +239,6 @@ void SettingsDialog::saveToSettings() BrowserApplication::instance()->loadSettings(); #if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - BrowserApplication::networkAccessManager()->loadSettings(); BrowserApplication::cookieJar()->loadSettings(); #endif BrowserApplication::historyManager()->loadSettings(); diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/browser/webview.cpp index 7705e7ab4a51dc112c264899fedda50f5bc790c8..00ec40874a867a2f0cf81b6cad7377ad0703569d 100644 --- a/examples/webenginewidgets/browser/webview.cpp +++ b/examples/webenginewidgets/browser/webview.cpp @@ -44,7 +44,6 @@ #include "cookiejar.h" #include "downloadmanager.h" #include "featurepermissionbar.h" -#include "networkaccessmanager.h" #include "ui_passworddialog.h" #include "ui_proxy.h" #include "tabwidget.h" diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 1824b3e9648400a610ff989f4c87b6c86d13fddf..1f68879e33f6860047a77e5d332a69397e4017b1 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -116,8 +116,8 @@ public: int httpCacheMaximumSize() const; void setHttpCacheMaximumSize(int maxSize); - Q_REVISION(2) QString httpAcceptLanguage() const; - Q_REVISION(2) void setHttpAcceptLanguage(const QString &httpAcceptLanguage); + Q_REVISION(1) QString httpAcceptLanguage() const; + Q_REVISION(1) void setHttpAcceptLanguage(const QString &httpAcceptLanguage); static QQuickWebEngineProfile *defaultProfile(); @@ -130,7 +130,7 @@ signals: void httpCacheTypeChanged(); void persistentCookiesPolicyChanged(); void httpCacheMaximumSizeChanged(); - Q_REVISION(2) void httpAcceptLanguageChanged(); + Q_REVISION(1) void httpAcceptLanguageChanged(); void downloadRequested(QQuickWebEngineDownloadItem *download); void downloadFinished(QQuickWebEngineDownloadItem *download); diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index e4b96c47b4fb8585204f043a586e7e443d753af4..cb8950019eaf80d6a3c39e8d9843cc6b59fd668a 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -71,6 +71,7 @@ public: qmlRegisterType<QQuickWebEngineView, 1>(uri, 1, 1, "WebEngineView"); qmlRegisterType<QQuickWebEngineView, 2>(uri, 1, 2, "WebEngineView"); qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile"); + qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript"); qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", QObject::tr("Cannot create separate instance of WebEngineCertificateError")); qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",