summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/api/qwebenginebrowsercontext.cpp73
-rw-r--r--src/core/api/qwebenginebrowsercontext_p.h83
-rw-r--r--src/core/proxy_config_service_qt.cpp14
-rw-r--r--src/core/web_contents_adapter.cpp4
5 files changed, 168 insertions, 8 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 270595378..93eebbc45 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -33,6 +33,7 @@ HEADERS = \
qwebenginecallback_p.h \
qtwebenginecoreglobal.h \
qtwebenginecoreglobal_p.h \
+ qwebenginebrowsercontext_p.h \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginehttprequest.h \
@@ -44,6 +45,7 @@ HEADERS = \
SOURCES = \
qtwebenginecoreglobal.cpp \
+ qwebenginebrowsercontext.cpp \
qwebenginecookiestore.cpp \
qwebenginehttprequest.cpp \
qwebengineurlrequestinfo.cpp \
diff --git a/src/core/api/qwebenginebrowsercontext.cpp b/src/core/api/qwebenginebrowsercontext.cpp
new file mode 100644
index 000000000..c3ab16460
--- /dev/null
+++ b/src/core/api/qwebenginebrowsercontext.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginebrowsercontext_p.h"
+
+#include "browser_context_adapter.h"
+#include <qtwebenginecoreglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext,
+ QtWebEngineCore::BrowserContextAdapterClient *profile)
+ : QObject(QtWebEngineCore::BrowserContextAdapter::globalQObjectRoot())
+ , browserContextRef(browserContext)
+ , m_profile(profile)
+{
+ browserContextRef->addClient(m_profile);
+}
+
+QWebEngineBrowserContext::~QWebEngineBrowserContext()
+{
+ if (m_profile)
+ shutdown();
+}
+
+void QWebEngineBrowserContext::shutdown()
+{
+ Q_ASSERT(m_profile);
+ // In the case the user sets this profile as the parent of the interceptor
+ // it can be deleted before the browser-context still referencing it is.
+ browserContextRef->setRequestInterceptor(nullptr);
+ browserContextRef->removeClient(m_profile);
+ m_profile = 0;
+ deleteLater();
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginebrowsercontext_p.h b/src/core/api/qwebenginebrowsercontext_p.h
new file mode 100644
index 000000000..713ab730e
--- /dev/null
+++ b/src/core/api/qwebenginebrowsercontext_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEBROWSERCONTEXT_P_H
+#define QWEBENGINEBROWSERCONTEXT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#include "qtwebenginecoreglobal_p.h"
+
+#include <QObject>
+#include <QSharedPointer>
+
+namespace QtWebEngineCore {
+class BrowserContextAdapter;
+class BrowserContextAdapterClient;
+}
+
+QT_BEGIN_NAMESPACE
+
+// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext
+// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject.
+// This guarantees the destruction together with the WebEngineContext.
+class QWEBENGINE_PRIVATE_EXPORT QWebEngineBrowserContext : public QObject {
+public:
+ QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QtWebEngineCore::BrowserContextAdapterClient *profile);
+ ~QWebEngineBrowserContext();
+
+ void shutdown();
+
+ QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef;
+
+private:
+ QtWebEngineCore::BrowserContextAdapterClient *m_profile;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEBROWSERCONTEXT_P_H
diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp
index cd8f4c0fe..7fca18eb6 100644
--- a/src/core/proxy_config_service_qt.cpp
+++ b/src/core/proxy_config_service_qt.cpp
@@ -52,22 +52,20 @@ using content::BrowserThread;
net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qtProxy)
{
- net::ProxyServer::Scheme proxyScheme = net::ProxyServer::SCHEME_INVALID;
+ net::HostPortPair hostPortPair(qtProxy.hostName().toStdString(), qtProxy.port());
switch (qtProxy.type()) {
case QNetworkProxy::Socks5Proxy:
- proxyScheme = net::ProxyServer::SCHEME_SOCKS5;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_SOCKS5, hostPortPair);
case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy:
case QNetworkProxy::FtpCachingProxy:
- proxyScheme = net::ProxyServer::SCHEME_HTTP;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_HTTP, hostPortPair);
case QNetworkProxy::NoProxy:
case QNetworkProxy::DefaultProxy:
- proxyScheme = net::ProxyServer::SCHEME_DIRECT;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_DIRECT, net::HostPortPair());
+ default:
+ return net::ProxyServer(net::ProxyServer::SCHEME_INVALID, net::HostPortPair());
}
- return net::ProxyServer(proxyScheme, net::HostPortPair(qtProxy.hostName().toStdString(), qtProxy.port()));
}
ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService)
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 0592e36fb..5850b07b5 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1320,7 +1320,11 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro
const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents();
const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
const QString &filePath = d->dndTmpDir->filePath(fileName);
+#else
+ const QString &filePath = d->dndTmpDir->path() + QLatin1Char('/') + fileName;
+#endif
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly)) {
qWarning("Cannot write temporary file %s.", qUtf8Printable(filePath));