summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Stromme <christian.stromme@qt.io>2017-10-13 22:31:58 +0200
committerChristian Stromme <christian.stromme@qt.io>2018-01-26 22:38:07 +0000
commitd037c87d94666f94faf2c6fbb0f5d11107496de4 (patch)
tree2c03a9b6a8004c2455ec32c8a518543d15cd60a8 /src
parent71be1de8162f38fc544605743a0169e10a19dc39 (diff)
Make QtWebView plugin based
This removes the hard build dependency to QtWebEngine, which opens up the possibility for QtWebEngine, or others, to provide their own plugin. Another benefit of having the backends loaded at run-time, is that we can provide an alternative for developers that wants to publish their application in the App Store, where shipping QtWebEngine isn't an option, due to store policies, and where we already have an alternative/experimental backend that can be used. [ChangeLog][WebView] QtWebView will now load its backends at run-time. Task-number: QTBUG-63137 Change-Id: I581940fe4c3b5e6bb41896367d3163ac8bc7b6b9 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/android/android.json3
-rw-r--r--src/plugins/android/android.pro20
-rw-r--r--src/plugins/android/qandroidwebview.cpp (renamed from src/webview/qwebview_android.cpp)13
-rw-r--r--src/plugins/android/qandroidwebview_p.h (renamed from src/webview/qwebview_android_p.h)10
-rw-r--r--src/plugins/android/qandroidwebviewplugin.cpp56
-rw-r--r--src/plugins/darwin/darwin.json4
-rw-r--r--src/plugins/darwin/darwin.pro21
-rw-r--r--src/plugins/darwin/qdarwinwebview.mm (renamed from src/webview/qwebview_darwin.mm)20
-rw-r--r--src/plugins/darwin/qdarwinwebview_p.h (renamed from src/webview/qwebview_darwin_p.h)10
-rw-r--r--src/plugins/darwin/qdarwinwebviewplugin.cpp68
-rw-r--r--src/plugins/plugins.pro13
-rw-r--r--src/plugins/webengine/qwebenginewebview.cpp (renamed from src/webview/qwebview_webengine.cpp)15
-rw-r--r--src/plugins/webengine/qwebenginewebview_p.h (renamed from src/webview/qwebview_webengine_p.h)10
-rw-r--r--src/plugins/webengine/qwebenginewebviewplugin.cpp63
-rw-r--r--src/plugins/webengine/webengine.json4
-rw-r--r--src/plugins/webengine/webengine.pro19
-rw-r--r--src/plugins/winrt/qwinrtwebview.cpp (renamed from src/webview/qwebview_winrt.cpp)11
-rw-r--r--src/plugins/winrt/qwinrtwebview_p.h (renamed from src/webview/qwebview_winrt_p.h)10
-rw-r--r--src/plugins/winrt/qwinrtwebviewplugin.cpp56
-rw-r--r--src/plugins/winrt/winrt.json3
-rw-r--r--src/plugins/winrt/winrt.pro21
-rw-r--r--src/src.pro7
-rw-r--r--src/webview/qabstractwebview_p.h (renamed from src/webview/qwebview_p_p.h)12
-rw-r--r--src/webview/qtwebviewfunctions.cpp41
-rw-r--r--src/webview/qwebview.cpp42
-rw-r--r--src/webview/qwebview_p.h5
-rw-r--r--src/webview/qwebviewfactory.cpp130
-rw-r--r--src/webview/qwebviewfactory_p.h (renamed from src/webview/qtwebviewfunctions_p.h)20
-rw-r--r--src/webview/qwebviewplugin.cpp56
-rw-r--r--src/webview/qwebviewplugin_p.h74
-rw-r--r--src/webview/webview-lib.pri75
-rw-r--r--src/webview/webview.pro40
32 files changed, 727 insertions, 225 deletions
diff --git a/src/plugins/android/android.json b/src/plugins/android/android.json
new file mode 100644
index 0000000..9f65fd4
--- /dev/null
+++ b/src/plugins/android/android.json
@@ -0,0 +1,3 @@
+{
+ "Keys": ["native"]
+}
diff --git a/src/plugins/android/android.pro b/src/plugins/android/android.pro
new file mode 100644
index 0000000..c10a9d4
--- /dev/null
+++ b/src/plugins/android/android.pro
@@ -0,0 +1,20 @@
+TARGET = qtwebview_android
+
+PLUGIN_TYPE = webview
+PLUGIN_CLASS_NAME = QAndroidWebViewPlugin
+load(qt_plugin)
+
+QT += core gui webview-private
+LIBS_PRIVATE += -ljnigraphics
+
+HEADERS += \
+ qandroidwebview_p.h
+
+SOURCES += \
+ qandroidwebviewplugin.cpp \
+ qandroidwebview.cpp
+
+OTHER_FILES +=
+
+DISTFILES += \
+ android.json
diff --git a/src/webview/qwebview_android.cpp b/src/plugins/android/qandroidwebview.cpp
index cec395d..94e123c 100644
--- a/src/webview/qwebview_android.cpp
+++ b/src/plugins/android/qandroidwebview.cpp
@@ -34,9 +34,9 @@
**
****************************************************************************/
-#include "qwebview_android_p.h"
-#include "qwebview_p.h"
-#include "qwebviewloadrequest_p.h" // TODO:
+#include "qandroidwebview_p.h"
+#include <private/qwebview_p.h>
+#include <private/qwebviewloadrequest_p.h>
#include <QtCore/private/qjnihelpers_p.h>
#include <QtCore/private/qjni_p.h>
@@ -50,11 +50,6 @@
QT_BEGIN_NAMESPACE
-QWebViewPrivate *QWebViewPrivate::create(QWebView *q)
-{
- return new QAndroidWebViewPrivate(q);
-}
-
static const char qtAndroidWebViewControllerClass[] = "org/qtproject/qt5/android/view/QtAndroidWebViewController";
//static bool favIcon(JNIEnv *env, jobject icon, QImage *image)
@@ -78,7 +73,7 @@ typedef QMap<quintptr, QAndroidWebViewPrivate *> WebViews;
Q_GLOBAL_STATIC(WebViews, g_webViews)
QAndroidWebViewPrivate::QAndroidWebViewPrivate(QObject *p)
- : QWebViewPrivate(p)
+ : QAbstractWebView(p)
, m_id(reinterpret_cast<quintptr>(this))
, m_callbackId(0)
, m_window(0)
diff --git a/src/webview/qwebview_android_p.h b/src/plugins/android/qandroidwebview_p.h
index 9290289..9c1d364 100644
--- a/src/webview/qwebview_android_p.h
+++ b/src/plugins/android/qandroidwebview_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QWEBVIEW_ANDROID_P_H
-#define QWEBVIEW_ANDROID_P_H
+#ifndef QANDROIDWEBVIEW_P_H
+#define QANDROIDWEBVIEW_P_H
//
// W A R N I N G
@@ -53,11 +53,11 @@
#include <QtGui/qwindow.h>
#include <QtCore/private/qjni_p.h>
-#include "qwebview_p_p.h"
+#include <private/qabstractwebview_p.h>
QT_BEGIN_NAMESPACE
-class QAndroidWebViewPrivate : public QWebViewPrivate
+class QAndroidWebViewPrivate : public QAbstractWebView
{
Q_OBJECT
public:
@@ -102,4 +102,4 @@ private:
QT_END_NAMESPACE
-#endif // QWEBVIEW_ANDROID_P_H
+#endif // QANDROIDWEBVIEW_P_H
diff --git a/src/plugins/android/qandroidwebviewplugin.cpp b/src/plugins/android/qandroidwebviewplugin.cpp
new file mode 100644
index 0000000..1d9f1b4
--- /dev/null
+++ b/src/plugins/android/qandroidwebviewplugin.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qandroidwebview_p.h"
+#include <private/qwebviewplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAndroidWebViewPlugin : public QWebViewPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "android.json")
+
+public:
+ QAbstractWebView *create(const QString &key) const override
+ {
+ return (key == QLatin1String("webview")) ? new QAndroidWebViewPrivate() : nullptr;
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "qandroidwebviewplugin.moc"
diff --git a/src/plugins/darwin/darwin.json b/src/plugins/darwin/darwin.json
new file mode 100644
index 0000000..daa9d6f
--- /dev/null
+++ b/src/plugins/darwin/darwin.json
@@ -0,0 +1,4 @@
+{
+ "Keys": ["native"],
+ "RequiresInit": true
+}
diff --git a/src/plugins/darwin/darwin.pro b/src/plugins/darwin/darwin.pro
new file mode 100644
index 0000000..9723eb2
--- /dev/null
+++ b/src/plugins/darwin/darwin.pro
@@ -0,0 +1,21 @@
+TARGET = qtwebview_darwin
+
+PLUGIN_TYPE = webview
+PLUGIN_CLASS_NAME = QDarwinWebViewPlugin
+load(qt_plugin)
+
+QT += core gui webview-private
+LIBS_PRIVATE += -framework Foundation -framework AppKit -framework WebKit
+ios: LIBS_PRIVATE += -framework UIKit
+
+HEADERS += \
+ qdarwinwebview_p.h
+
+SOURCES += \
+ qdarwinwebviewplugin.cpp
+
+OBJECTIVE_SOURCES += \
+ qdarwinwebview.mm
+
+DISTFILES += \
+ darwin.json
diff --git a/src/webview/qwebview_darwin.mm b/src/plugins/darwin/qdarwinwebview.mm
index 90f6551..b31bdaf 100644
--- a/src/webview/qwebview_darwin.mm
+++ b/src/plugins/darwin/qdarwinwebview.mm
@@ -34,11 +34,10 @@
**
****************************************************************************/
-#include "qwebview_darwin_p.h"
-#include "qwebview_p.h"
-#include "qwebviewloadrequest_p.h"
+#include "qdarwinwebview_p.h"
+#include <private/qwebview_p.h>
+#include <private/qwebviewloadrequest_p.h>
#include "qtwebviewfunctions.h"
-#include "qtwebviewfunctions_p.h"
#include <QtCore/private/qglobal_p.h>
#include <QtCore/qdatetime.h>
@@ -54,8 +53,6 @@
#endif
#ifdef Q_OS_MACOS
-#include "qwebview_webengine_p.h"
-
#include <AppKit/AppKit.h>
typedef NSView UIView;
@@ -63,15 +60,6 @@ typedef NSView UIView;
QT_BEGIN_NAMESPACE
-QWebViewPrivate *QWebViewPrivate::create(QWebView *q)
-{
-#ifdef Q_OS_MACOS
- if (!QtWebViewPrivate::useNativeWebView())
- return new QWebEngineWebViewPrivate(q);
-#endif
- return new QDarwinWebViewPrivate(q);
-}
-
static inline CGRect toCGRect(const QRectF &rect)
{
return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
@@ -257,7 +245,7 @@ decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
QT_BEGIN_NAMESPACE
QDarwinWebViewPrivate::QDarwinWebViewPrivate(QObject *p)
- : QWebViewPrivate(p)
+ : QAbstractWebView(p)
, wkWebView(nil)
#ifdef Q_OS_IOS
, m_recognizer(0)
diff --git a/src/webview/qwebview_darwin_p.h b/src/plugins/darwin/qdarwinwebview_p.h
index 2b188e8..8bc9c13 100644
--- a/src/webview/qwebview_darwin_p.h
+++ b/src/plugins/darwin/qdarwinwebview_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QWEBVIEW_DARWIN_P_H
-#define QWEBVIEW_DARWIN_P_H
+#ifndef QDARWINWEBVIEW_P_H
+#define QDARWINWEBVIEW_P_H
//
// W A R N I N G
@@ -52,7 +52,7 @@
#include <QtCore/qurl.h>
#include <QtGui/qwindow.h>
-#include "qwebview_p_p.h"
+#include <private/qabstractwebview_p.h>
#if defined(Q_OS_IOS) && defined(__OBJC__)
#include <UIKit/UIGestureRecognizer.h>
@@ -74,7 +74,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(UIGestureRecognizer);
QT_BEGIN_NAMESPACE
-class QDarwinWebViewPrivate : public QWebViewPrivate
+class QDarwinWebViewPrivate : public QAbstractWebView
{
Q_OBJECT
public:
@@ -118,4 +118,4 @@ public:
QT_END_NAMESPACE
-#endif // QWEBVIEW_DARWIN_P_H
+#endif // QDARWINWEBVIEW_P_H
diff --git a/src/plugins/darwin/qdarwinwebviewplugin.cpp b/src/plugins/darwin/qdarwinwebviewplugin.cpp
new file mode 100644
index 0000000..9c03989
--- /dev/null
+++ b/src/plugins/darwin/qdarwinwebviewplugin.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdarwinwebview_p.h"
+#include <private/qwebviewplugin_p.h>
+#include <QtCore/qbytearray.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDarwinWebViewPlugin : public QWebViewPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "darwin.json")
+
+public:
+ QAbstractWebView *create(const QString &key) const override
+ {
+ return (key == QLatin1String("webview")) ? new QDarwinWebViewPrivate() : nullptr;
+ }
+
+ void prepare() const override
+ {
+#ifdef Q_OS_MACOS
+ // On macOS, correct WebView / QtQuick compositing and stacking requires running
+ // Qt in layer-backed mode, which again resuires rendering on the Gui thread.
+ qWarning("Setting QT_MAC_WANTS_LAYER=1 and QSG_RENDER_LOOP=basic");
+ qputenv("QT_MAC_WANTS_LAYER", "1");
+ qputenv("QSG_RENDER_LOOP", "basic");
+#endif // Q_OS_MACOS
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "qdarwinwebviewplugin.moc"
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
new file mode 100644
index 0000000..60c5078
--- /dev/null
+++ b/src/plugins/plugins.pro
@@ -0,0 +1,13 @@
+TEMPLATE = subdirs
+
+android {
+ SUBDIRS += android
+} else:if(ios|macos) {
+ SUBDIRS += darwin
+} else:winrt {
+ SUBDIRS += winrt
+}
+
+qtHaveModule(webengine) {
+ SUBDIRS += webengine
+}
diff --git a/src/webview/qwebview_webengine.cpp b/src/plugins/webengine/qwebenginewebview.cpp
index dd2e56d..d083b8d 100644
--- a/src/webview/qwebview_webengine.cpp
+++ b/src/plugins/webengine/qwebenginewebview.cpp
@@ -34,9 +34,9 @@
**
****************************************************************************/
-#include "qwebview_webengine_p.h"
-#include "qwebview_p.h"
-#include "qwebviewloadrequest_p.h"
+#include "qwebenginewebview_p.h"
+#include <private/qwebview_p.h>
+#include <private/qwebviewloadrequest_p.h>
#include <QtWebView/private/qquickwebview_p.h>
@@ -64,15 +64,8 @@ static QByteArray qmlSource()
"}\n");
}
-#ifndef Q_OS_MACOS
-QWebViewPrivate *QWebViewPrivate::create(QWebView *q)
-{
- return new QWebEngineWebViewPrivate(q);
-}
-#endif
-
QWebEngineWebViewPrivate::QWebEngineWebViewPrivate(QObject *p)
- : QWebViewPrivate(p)
+ : QAbstractWebView(p)
{
m_webEngineView.m_parent = this;
}
diff --git a/src/webview/qwebview_webengine_p.h b/src/plugins/webengine/qwebenginewebview_p.h
index 16dd773..88d6284 100644
--- a/src/webview/qwebview_webengine_p.h
+++ b/src/plugins/webengine/qwebenginewebview_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QWEBVIEW_ANDROID_P_H
-#define QWEBVIEW_ANDROID_P_H
+#ifndef QWEBENGINEWEBVIEW_P_H
+#define QWEBENGINEWEBVIEW_P_H
//
// W A R N I N G
@@ -54,14 +54,14 @@
#include <QtQml/qqmlcomponent.h>
-#include "qwebview_p_p.h"
+#include <private/qabstractwebview_p.h>
QT_BEGIN_NAMESPACE
class QQuickWebEngineView;
class QQuickWebEngineLoadRequest;
-class QWebEngineWebViewPrivate : public QWebViewPrivate
+class QWebEngineWebViewPrivate : public QAbstractWebView
{
Q_OBJECT
public:
@@ -118,4 +118,4 @@ private:
QT_END_NAMESPACE
-#endif // QWEBVIEW_ANDROID_P_H
+#endif // QWEBENGINEWEBVIEW_P_H
diff --git a/src/plugins/webengine/qwebenginewebviewplugin.cpp b/src/plugins/webengine/qwebenginewebviewplugin.cpp
new file mode 100644
index 0000000..0765b49
--- /dev/null
+++ b/src/plugins/webengine/qwebenginewebviewplugin.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginewebview_p.h"
+#include <private/qwebviewplugin_p.h>
+
+#include <QtWebEngine/qtwebengineglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineWebViewPlugin : public QWebViewPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "webengine.json")
+
+public:
+ QAbstractWebView *create(const QString &key) const override
+ {
+ return (key == QLatin1String("webview")) ? new QWebEngineWebViewPrivate() : nullptr;
+ }
+
+ void prepare() const override
+ {
+ QtWebEngine::initialize();
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "qwebenginewebviewplugin.moc"
diff --git a/src/plugins/webengine/webengine.json b/src/plugins/webengine/webengine.json
new file mode 100644
index 0000000..67049d4
--- /dev/null
+++ b/src/plugins/webengine/webengine.json
@@ -0,0 +1,4 @@
+{
+ "Keys": ["webengine"],
+ "RequiresInit": true
+}
diff --git a/src/plugins/webengine/webengine.pro b/src/plugins/webengine/webengine.pro
new file mode 100644
index 0000000..b0a03ac
--- /dev/null
+++ b/src/plugins/webengine/webengine.pro
@@ -0,0 +1,19 @@
+TARGET = qtwebview_webengine
+
+PLUGIN_TYPE = webview
+PLUGIN_CLASS_NAME = QWebEngineWebViewPlugin
+load(qt_plugin)
+
+QT += core gui webengine-private webview-private
+
+HEADERS += \
+ qwebenginewebview_p.h
+
+SOURCES += \
+ qwebenginewebview.cpp \
+ qwebenginewebviewplugin.cpp
+
+OTHER_FILES +=
+
+DISTFILES += \
+ webengine.json
diff --git a/src/webview/qwebview_winrt.cpp b/src/plugins/winrt/qwinrtwebview.cpp
index fc999d2..a9ae659 100644
--- a/src/webview/qwebview_winrt.cpp
+++ b/src/plugins/winrt/qwinrtwebview.cpp
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#include "qwebview_winrt_p.h"
-#include "qwebviewloadrequest_p.h"
+#include "qwinrtwebview_p.h"
+#include <private/qwebviewloadrequest_p.h>
#include <functional>
@@ -263,11 +263,6 @@ static QString webErrorStatusString(WebErrorStatus status)
return QString();
}
-QWebViewPrivate *QWebViewPrivate::create(QWebView *q)
-{
- return new QWinRTWebViewPrivate(q);
-}
-
struct WinRTWebView
{
ComPtr<IWebView> base;
@@ -293,7 +288,7 @@ static const wchar_t webviewXaml[] = LSTRING(
);
QWinRTWebViewPrivate::QWinRTWebViewPrivate(QObject *parent)
- : QWebViewPrivate(parent), d(new WinRTWebView)
+ : QAbstractWebView(parent), d(new WinRTWebView)
{
d->isLoading = false;
diff --git a/src/webview/qwebview_winrt_p.h b/src/plugins/winrt/qwinrtwebview_p.h
index 5dc9f40..2b7d937 100644
--- a/src/webview/qwebview_winrt_p.h
+++ b/src/plugins/winrt/qwinrtwebview_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QWEBVIEW_WINRT_P_H
-#define QWEBVIEW_WINRT_P_H
+#ifndef QWINRTWEBVIEW_P_H
+#define QWINRTWEBVIEW_P_H
//
// W A R N I N G
@@ -48,7 +48,7 @@
// We mean it.
//
-#include "qwebview_p.h"
+#include <private/qabstractwebview_p.h>
namespace ABI {
namespace Windows {
@@ -67,7 +67,7 @@ namespace ABI {
QT_BEGIN_NAMESPACE
struct WinRTWebView;
-class QWinRTWebViewPrivate : public QWebViewPrivate
+class QWinRTWebViewPrivate : public QAbstractWebView
{
Q_OBJECT
public:
@@ -106,4 +106,4 @@ private:
QT_END_NAMESPACE
-#endif // QWEBVIEW_WINRT_P_H
+#endif // QWINRTWEBVIEW_P_H
diff --git a/src/plugins/winrt/qwinrtwebviewplugin.cpp b/src/plugins/winrt/qwinrtwebviewplugin.cpp
new file mode 100644
index 0000000..30138e1
--- /dev/null
+++ b/src/plugins/winrt/qwinrtwebviewplugin.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwinrtwebview_p.h"
+#include <QtWebView/private/qwebviewplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWinRtWebViewPlugin : public QWebViewPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "winrt.json")
+
+public:
+ QAbstractWebView *create(const QString &key) const override
+ {
+ return (key == QLatin1String("webview")) ? new QWinRTWebViewPrivate() : nullptr;
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "qwinrtwebviewplugin.moc"
diff --git a/src/plugins/winrt/winrt.json b/src/plugins/winrt/winrt.json
new file mode 100644
index 0000000..9f65fd4
--- /dev/null
+++ b/src/plugins/winrt/winrt.json
@@ -0,0 +1,3 @@
+{
+ "Keys": ["native"]
+}
diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro
new file mode 100644
index 0000000..dabcbfd
--- /dev/null
+++ b/src/plugins/winrt/winrt.pro
@@ -0,0 +1,21 @@
+TARGET = qtwebview_winrt
+QT += core gui webview-private
+
+PLUGIN_TYPE = webview
+PLUGIN_CLASS_NAME = QWinrtWebViewPlugin
+
+load(qt_plugin)
+
+NO_PCH_SOURCES += \
+ qwinrtwebview.cpp
+
+SOURCES += \
+ qwinrtwebviewplugin.cpp
+
+HEADERS += \
+ qwinrtwebview_p.h
+
+OTHER_FILES +=
+
+DISTFILES += \
+ winrt.json
diff --git a/src/src.pro b/src/src.pro
index c0420f5..7bc2ef7 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,8 +1,7 @@
TEMPLATE = subdirs
-android|ios|macos|winrt|qtHaveModule(webengine) {
- SUBDIRS += webview imports
- imports.depends = webview
-}
+SUBDIRS += webview imports plugins
+plugins.depends = webview
+imports.depends = webview
android: SUBDIRS += jar
diff --git a/src/webview/qwebview_p_p.h b/src/webview/qabstractwebview_p.h
index 45a352b..d2eec30 100644
--- a/src/webview/qwebview_p_p.h
+++ b/src/webview/qabstractwebview_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QWEBVIEW_P_P_H
-#define QWEBVIEW_P_P_H
+#ifndef QABSTRACTWEBVIEW_P_H
+#define QABSTRACTWEBVIEW_P_H
//
// W A R N I N G
@@ -56,14 +56,12 @@ QT_BEGIN_NAMESPACE
class QWebView;
class QWebViewLoadRequestPrivate;
-class Q_WEBVIEW_EXPORT QWebViewPrivate
+class Q_WEBVIEW_EXPORT QAbstractWebView
: public QObject
, public QWebViewInterface
, public QNativeViewController
{
Q_OBJECT
-public:
- static QWebViewPrivate *create(QWebView *q);
Q_SIGNALS:
void titleChanged(const QString &title);
@@ -74,10 +72,10 @@ Q_SIGNALS:
void requestFocus(bool focus);
protected:
- explicit QWebViewPrivate(QObject *p = 0) : QObject(p) { }
+ explicit QAbstractWebView(QObject *p = 0) : QObject(p) { }
};
QT_END_NAMESPACE
-#endif // QWEBVIEW_P_P_H
+#endif // QABSTRACTWEBVIEW_P_H
diff --git a/src/webview/qtwebviewfunctions.cpp b/src/webview/qtwebviewfunctions.cpp
index 7509f21..975bb17 100644
--- a/src/webview/qtwebviewfunctions.cpp
+++ b/src/webview/qtwebviewfunctions.cpp
@@ -35,15 +35,9 @@
****************************************************************************/
#include "qtwebviewfunctions.h"
-#include "qtwebviewfunctions_p.h"
-#ifdef QT_WEBVIEW_WEBENGINE_BACKEND
-#include <QtWebEngine/qtwebengineglobal.h>
-#endif // QT_WEBVIEW_WEBENGINE_BACKEND
-
-#ifdef Q_OS_MACOS
-#include <QtCore/qbytearray.h>
-#endif
+#include "qwebviewfactory_p.h"
+#include "qwebviewplugin_p.h"
QT_BEGIN_NAMESPACE
@@ -66,32 +60,11 @@ QT_BEGIN_NAMESPACE
void QtWebView::initialize()
{
-#if defined(Q_OS_MACOS)
- if (QtWebViewPrivate::useNativeWebView()) {
- // On macOS, correct WebView / QtQuick compositing and stacking requires running
- // Qt in layer-backed mode, which again resuires rendering on the Gui thread.
- qWarning("Setting QT_MAC_WANTS_LAYER=1 and QSG_RENDER_LOOP=basic");
- qputenv("QT_MAC_WANTS_LAYER", "1");
- qputenv("QSG_RENDER_LOOP", "basic");
- } else
-#endif
-#if defined(QT_WEBVIEW_WEBENGINE_BACKEND)
- QtWebEngine::initialize();
-#endif
-}
-
-/*!
- * \fn QtWebView::useNativeWebView()
- * \internal
- */
-
-bool QtWebViewPrivate::useNativeWebView()
-{
-#ifdef Q_OS_MACOS
- return qEnvironmentVariableIsSet("QT_MAC_USE_NATIVE_WEBVIEW");
-#else
- return true;
-#endif
+ if (QWebViewFactory::requiresExtraInitializationSteps()) {
+ QWebViewPlugin *plugin = QWebViewFactory::getPlugin();
+ Q_ASSERT(plugin);
+ plugin->prepare();
+ }
}
QT_END_NAMESPACE
diff --git a/src/webview/qwebview.cpp b/src/webview/qwebview.cpp
index 507d38a..7e457be 100644
--- a/src/webview/qwebview.cpp
+++ b/src/webview/qwebview.cpp
@@ -35,24 +35,27 @@
****************************************************************************/
#include "qwebview_p.h"
-#include <QtCore/QVariant>
-#include <QtWebView/private/qwebviewloadrequest_p.h>
+#include "qwebviewplugin_p.h"
+#include "qwebviewloadrequest_p.h"
+#include "qwebviewfactory_p.h"
+
QT_BEGIN_NAMESPACE
QWebView::QWebView(QObject *p)
- : QObject(p),
- d_ptr(QWebViewPrivate::create(this))
+ : QObject(p)
+ , d(QWebViewFactory::createWebView())
, m_progress(0)
{
+ d->setParent(this);
qRegisterMetaType<QWebViewLoadRequestPrivate>();
- Q_D(QWebView);
- connect(d, &QWebViewPrivate::titleChanged, this, &QWebView::onTitleChanged);
- connect(d, &QWebViewPrivate::urlChanged, this, &QWebView::onUrlChanged);
- connect(d, &QWebViewPrivate::loadingChanged, this, &QWebView::onLoadingChanged);
- connect(d, &QWebViewPrivate::loadProgressChanged, this, &QWebView::onLoadProgressChanged);
- connect(d, &QWebViewPrivate::requestFocus, this, &QWebView::requestFocus);
- connect(d, &QWebViewPrivate::javaScriptResult,
+
+ connect(d, &QAbstractWebView::titleChanged, this, &QWebView::onTitleChanged);
+ connect(d, &QAbstractWebView::urlChanged, this, &QWebView::onUrlChanged);
+ connect(d, &QAbstractWebView::loadingChanged, this, &QWebView::onLoadingChanged);
+ connect(d, &QAbstractWebView::loadProgressChanged, this, &QWebView::onLoadProgressChanged);
+ connect(d, &QAbstractWebView::requestFocus, this, &QWebView::requestFocus);
+ connect(d, &QAbstractWebView::javaScriptResult,
this, &QWebView::javaScriptResult);
}
@@ -67,43 +70,36 @@ QUrl QWebView::url() const
void QWebView::setUrl(const QUrl &url)
{
- Q_D(QWebView);
d->setUrl(url);
}
bool QWebView::canGoBack() const
{
- Q_D(const QWebView);
return d->canGoBack();
}
void QWebView::goBack()
{
- Q_D(QWebView);
d->goBack();
}
bool QWebView::canGoForward() const
{
- Q_D(const QWebView);
return d->canGoForward();
}
void QWebView::goForward()
{
- Q_D(QWebView);
d->goForward();
}
void QWebView::reload()
{
- Q_D(QWebView);
d->reload();
}
void QWebView::stop()
{
- Q_D(QWebView);
d->stop();
}
@@ -119,56 +115,47 @@ int QWebView::loadProgress() const
bool QWebView::isLoading() const
{
- Q_D(const QWebView);
return d->isLoading();
}
void QWebView::setParentView(QObject *view)
{
- Q_D(QWebView);
d->setParentView(view);
}
QObject *QWebView::parentView() const
{
- Q_D(const QWebView);
return d->parentView();
}
void QWebView::setGeometry(const QRect &geometry)
{
- Q_D(QWebView);
d->setGeometry(geometry);
}
void QWebView::setVisibility(QWindow::Visibility visibility)
{
- Q_D(QWebView);
d->setVisibility(visibility);
}
void QWebView::setVisible(bool visible)
{
- Q_D(QWebView);
d->setVisible(visible);
}
void QWebView::setFocus(bool focus)
{
- Q_D(QWebView);
d->setFocus(focus);
}
void QWebView::loadHtml(const QString &html, const QUrl &baseUrl)
{
- Q_D(QWebView);
d->loadHtml(html, baseUrl);
}
void QWebView::runJavaScriptPrivate(const QString &script,
int callbackId)
{
- Q_D(QWebView);
d->runJavaScriptPrivate(script, callbackId);
}
@@ -211,7 +198,6 @@ void QWebView::onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest)
void QWebView::init()
{
- Q_D(QWebView);
d->init();
}
diff --git a/src/webview/qwebview_p.h b/src/webview/qwebview_p.h
index abc8bbf..aa09f03 100644
--- a/src/webview/qwebview_p.h
+++ b/src/webview/qwebview_p.h
@@ -48,7 +48,7 @@
// We mean it.
//
-#include "qwebview_p_p.h"
+#include "qabstractwebview_p.h"
#include "qwebviewinterface_p.h"
#include "qnativeviewcontroller_p.h"
#include <QtCore/qobject.h>
@@ -122,8 +122,7 @@ private:
friend class QQuickViewController;
friend class QQuickWebView;
- Q_DECLARE_PRIVATE(QWebView)
- QWebViewPrivate *d_ptr;
+ QAbstractWebView *d;
// provisional data
int m_progress;
diff --git a/src/webview/qwebviewfactory.cpp b/src/webview/qwebviewfactory.cpp
new file mode 100644
index 0000000..7a22fd1
--- /dev/null
+++ b/src/webview/qwebviewfactory.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebviewfactory_p.h"
+#include "qwebviewplugin_p.h"
+#include <private/qfactoryloader_p.h>
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QWebViewPluginInterface_iid, QLatin1String("/webview")))
+
+static QString getPluginName()
+{
+ static const QString name = !qEnvironmentVariableIsEmpty("QT_WEBVIEW_PLUGIN")
+ ? QString::fromLatin1(qgetenv("QT_WEBVIEW_PLUGIN"))
+#ifdef Q_OS_MACOS
+ : QStringLiteral("webengine");
+#else
+ : QStringLiteral("native");
+#endif // Q_OS_MACOS
+ return name;
+}
+
+class QNullWebView : public QAbstractWebView
+{
+public:
+ void setParentView(QObject *view) override { Q_UNUSED(view); }
+ QObject *parentView() const override { return nullptr; }
+ void setGeometry(const QRect &geometry) override { Q_UNUSED(geometry); }
+ void setVisibility(QWindow::Visibility visibility) override { Q_UNUSED(visibility); }
+ void setVisible(bool visible) override { Q_UNUSED(visible); }
+
+ QUrl url() const override { return QUrl(); }
+ void setUrl(const QUrl &url) override { Q_UNUSED(url); }
+ bool canGoBack() const override { return false; }
+ bool canGoForward() const override { return false; }
+ QString title() const override { return QString(); }
+ int loadProgress() const override { return 0; }
+ bool isLoading() const override { return false; }
+ void goBack() override { }
+ void goForward() override { }
+ void stop() override { }
+ void reload() override { }
+ void loadHtml(const QString &html, const QUrl &baseUrl) override
+ { Q_UNUSED(html); Q_UNUSED(baseUrl); }
+ void runJavaScriptPrivate(const QString &script, int callbackId) override
+ { Q_UNUSED(script); Q_UNUSED(callbackId); }
+};
+
+QAbstractWebView *QWebViewFactory::createWebView()
+{
+ QAbstractWebView *wv = nullptr;
+ QWebViewPlugin *plugin = getPlugin();
+ if (plugin)
+ wv = plugin->create(QStringLiteral("webview"));
+
+ if (!wv || !plugin) {
+ qWarning("No WebView plug-in found!");
+ wv = new QNullWebView;
+ }
+
+ return wv;
+}
+
+bool QWebViewFactory::requiresExtraInitializationSteps()
+{
+ const QString pluginName = getPluginName();
+ const int index = pluginName.isEmpty() ? 0 : qMax<int>(0, loader->indexOf(pluginName));
+
+ const auto metaDataList = loader->metaData();
+ if (metaDataList.isEmpty())
+ return false;
+
+ const auto &pluginMetaData = metaDataList.at(index);
+ const auto iid = pluginMetaData.value(QLatin1String("IID"));
+ Q_ASSERT(iid == QJsonValue(QLatin1String(QWebViewPluginInterface_iid)));
+ const auto metaDataObject = pluginMetaData.value(QLatin1String("MetaData")).toObject();
+ const auto it = metaDataObject.find(QLatin1String("RequiresInit"));
+ if (it != pluginMetaData.constEnd())
+ return it->isBool() ? it->toBool() : false;
+
+ return false;
+}
+
+QWebViewPlugin *QWebViewFactory::getPlugin()
+{
+ // Plugin loading logic:
+ // 1. Get plugin name - plugin name is either user specified or "native"
+ // - Exception: macOS, which will default to using "webengine" until the native plugin is matured.
+ // 2. If neither a user specified or "default" plugin exists, then the first available is used.
+ const QString pluginName = getPluginName();
+ const int index = pluginName.isEmpty() ? 0 : qMax<int>(0, loader->indexOf(pluginName));
+ return qobject_cast<QWebViewPlugin *>(loader->instance(index));
+}
+
+QT_END_NAMESPACE
diff --git a/src/webview/qtwebviewfunctions_p.h b/src/webview/qwebviewfactory_p.h
index afc7abc..0914b8a 100644
--- a/src/webview/qtwebviewfunctions_p.h
+++ b/src/webview/qwebviewfactory_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWebView module of the Qt Toolkit.
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QTWEBVIEWFUNCTIONS_P_H
-#define QTWEBVIEWFUNCTIONS_P_H
+#ifndef QWEBVIEWFACTORY_H
+#define QWEBVIEWFACTORY_H
//
// W A R N I N G
@@ -48,15 +48,19 @@
// We mean it.
//
-#include <QtWebView/qwebview_global.h>
+#include "qabstractwebview_p.h"
QT_BEGIN_NAMESPACE
-namespace QtWebViewPrivate
+class QWebViewPlugin;
+
+namespace QWebViewFactory
{
- bool useNativeWebView();
-}
+ QWebViewPlugin *getPlugin();
+ QAbstractWebView *createWebView();
+ bool requiresExtraInitializationSteps();
+};
QT_END_NAMESPACE
-#endif // QTWEBVIEWFUNCTIONS_P_H
+#endif // QWEBVIEWFACTORY_H
diff --git a/src/webview/qwebviewplugin.cpp b/src/webview/qwebviewplugin.cpp
new file mode 100644
index 0000000..9771480
--- /dev/null
+++ b/src/webview/qwebviewplugin.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebviewplugin_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWebViewPlugin::QWebViewPlugin(QObject *parent) : QObject(parent)
+{
+
+}
+
+QWebViewPlugin::~QWebViewPlugin()
+{
+
+}
+
+void QWebViewPlugin::prepare() const
+{
+ // Only called for plugins that has "RequiresInit" set to true in their plugin metadata.
+}
+
+QT_END_NAMESPACE
diff --git a/src/webview/qwebviewplugin_p.h b/src/webview/qwebviewplugin_p.h
new file mode 100644
index 0000000..aeba38f
--- /dev/null
+++ b/src/webview/qwebviewplugin_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebView module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBVIEWPLUGIN_H
+#define QWEBVIEWPLUGIN_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 "qwebview_global.h"
+#include "qabstractwebview_p.h"
+
+#include <QtCore/qobject.h>
+
+#define QWebViewPluginInterface_iid "org.qt-project.Qt.QWebViewPluginInterface"
+
+QT_BEGIN_NAMESPACE
+
+class Q_WEBVIEW_EXPORT QWebViewPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QWebViewPlugin(QObject *parent = 0);
+ virtual ~QWebViewPlugin();
+
+ virtual QAbstractWebView *create(const QString &key) const = 0;
+
+ virtual void prepare() const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBVIEWPLUGIN_H
diff --git a/src/webview/webview-lib.pri b/src/webview/webview-lib.pri
deleted file mode 100644
index 6630fd4..0000000
--- a/src/webview/webview-lib.pri
+++ /dev/null
@@ -1,75 +0,0 @@
-ANDROID_BUNDLED_JAR_DEPENDENCIES = \
- jar/QtAndroidWebView.jar
-ANDROID_PERMISSIONS = \
- android.permission.ACCESS_FINE_LOCATION
-
-INCLUDEPATH += $$PWD
-
-PUBLIC_HEADERS += \
- qwebview_global.h \
- qtwebviewfunctions.h \
- qtwebviewfunctions_p.h
-
-SOURCES += \
- qtwebviewfunctions.cpp
-
-COMMON_HEADERS += \
- qwebview_p.h \
- qwebviewinterface_p.h \
- qquickwebview_p.h \
- qnativeviewcontroller_p.h \
- qwebview_p_p.h \
- qquickviewcontroller_p.h \
- qwebviewloadrequest_p.h \
- qquickwebviewloadrequest_p.h
-
-COMMON_SOURCES += \
- qwebview.cpp \
- qquickwebview.cpp \
- qquickviewcontroller.cpp \
- qquickwebviewloadrequest.cpp \
- qwebviewloadrequest.cpp
-
-android {
- QT_FOR_PRIVATE += core-private
- LIBS_PRIVATE += -ljnigraphics
- SOURCES += \
- $$COMMON_SOURCES \
- qwebview_android.cpp
- PRIVATE_HEADERS += \
- $$COMMON_HEADERS \
- qwebview_android_p.h
-
-} else:if(ios|macos) {
- SOURCES += \
- $$COMMON_SOURCES
- OBJECTIVE_SOURCES += \
- qwebview_darwin.mm
- PRIVATE_HEADERS += \
- $$COMMON_HEADERS \
- qwebview_darwin_p.h
- LIBS_PRIVATE += -framework Foundation -framework WebKit
- macos: LIBS_PRIVATE += -framework AppKit
- ios: LIBS_PRIVATE += -framework UIKit
-
- macos: CONFIG += use_webengine_backend
-} else: winrt {
- NO_PCH_SOURCES += qwebview_winrt.cpp
- SOURCES += $$COMMON_SOURCES
- PRIVATE_HEADERS += \
- $$COMMON_HEADERS \
- qwebview_winrt_p.h
-} else:qtHaveModule(webengine) {
- CONFIG += use_webengine_backend
-}
-
-use_webengine_backend {
- QT_PRIVATE += webengine-private
- SOURCES *= $$COMMON_SOURCES
- SOURCES += qwebview_webengine.cpp
- PRIVATE_HEADERS *= $$COMMON_HEADERS
- PRIVATE_HEADERS += qwebview_webengine_p.h
- DEFINES += QT_WEBVIEW_WEBENGINE_BACKEND
-}
-
-HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/webview/webview.pro b/src/webview/webview.pro
index af1286e..a1ba017 100644
--- a/src/webview/webview.pro
+++ b/src/webview/webview.pro
@@ -1,11 +1,47 @@
+load(qt_build_config)
+
TARGET = QtWebView
-QT =
QT_FOR_PRIVATE = quick-private core-private gui-private
-include($$PWD/webview-lib.pri)
+MODULE_PLUGIN_TYPES = webview
+
+PUBLIC_HEADERS += \
+ qwebview_global.h \
+ qtwebviewfunctions.h
+
+PRIVATE_HEADERS += \
+ qwebview_p.h \
+ qwebviewinterface_p.h \
+ qquickwebview_p.h \
+ qnativeviewcontroller_p.h \
+ qabstractwebview_p.h \
+ qquickviewcontroller_p.h \
+ qwebviewloadrequest_p.h \
+ qquickwebviewloadrequest_p.h \
+ qwebviewplugin_p.h \
+ qwebviewfactory_p.h
+
+SOURCES += \
+ qtwebviewfunctions.cpp \
+ qwebview.cpp \
+ qquickwebview.cpp \
+ qquickviewcontroller.cpp \
+ qquickwebviewloadrequest.cpp \
+ qwebviewloadrequest.cpp \
+ qwebviewplugin.cpp \
+ qwebviewfactory.cpp
QMAKE_DOCS = \
$$PWD/doc/qtwebview.qdocconf
+ANDROID_BUNDLED_JAR_DEPENDENCIES = \
+ jar/QtAndroidWebView.jar
+ANDROID_PERMISSIONS = \
+ android.permission.ACCESS_FINE_LOCATION
+ANDROID_LIB_DEPENDENCIES = \
+ plugins/webview/libqtwebview_android.so
+
+HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
+
load(qt_module)