summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/webview/minibrowser/main.cpp3
-rw-r--r--qtwebview.pro2
-rw-r--r--src/jar/bundledjar.pro3
-rw-r--r--src/jar/distributedjar.pro2
-rw-r--r--src/jar/jar.pri11
-rw-r--r--src/jar/jar.pro14
-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)32
-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)17
-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)48
-rw-r--r--src/plugins/winrt/qwinrtwebview_p.h (renamed from src/webview/qwebview_winrt_p.h)15
-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.pri77
-rw-r--r--src/webview/webview.pro40
39 files changed, 785 insertions, 262 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 52f1d69..7dccd20 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,4 +2,4 @@ load(qt_build_config)
DEFINES += QT_NO_FOREACH
-MODULE_VERSION = 5.10.1
+MODULE_VERSION = 5.11.0
diff --git a/examples/webview/minibrowser/main.cpp b/examples/webview/minibrowser/main.cpp
index 4eb02a4..ae7c321 100644
--- a/examples/webview/minibrowser/main.cpp
+++ b/examples/webview/minibrowser/main.cpp
@@ -91,9 +91,6 @@ int main(int argc, char *argv[])
parser.addVersionOption();
parser.addPositionalArgument("url", "The initial URL to open.");
QStringList arguments = app.arguments();
-#ifdef Q_OS_WINRT
- arguments.removeAt(1); // The launcher always passes in the -ServerName parameter, breaking the command line parser
-#endif
parser.process(arguments);
const QString initialUrl = parser.positionalArguments().isEmpty() ?
QStringLiteral("qt.io") : parser.positionalArguments().first();
diff --git a/qtwebview.pro b/qtwebview.pro
index 66de876..58c33f2 100644
--- a/qtwebview.pro
+++ b/qtwebview.pro
@@ -1,3 +1 @@
-requires(android|ios|winrt|qtHaveModule(webengine))
-
load(qt_parts)
diff --git a/src/jar/bundledjar.pro b/src/jar/bundledjar.pro
deleted file mode 100644
index abe173b..0000000
--- a/src/jar/bundledjar.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TARGET = QtAndroidWebView-bundled
-CONFIG += bundled_jar_file
-include(jar.pri)
diff --git a/src/jar/distributedjar.pro b/src/jar/distributedjar.pro
deleted file mode 100644
index 710983e..0000000
--- a/src/jar/distributedjar.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TARGET = QtAndroidWebView
-include(jar.pri)
diff --git a/src/jar/jar.pri b/src/jar/jar.pri
deleted file mode 100644
index 0c4f499..0000000
--- a/src/jar/jar.pri
+++ /dev/null
@@ -1,11 +0,0 @@
-load(qt_build_paths)
-CONFIG += java
-DESTDIR = $$MODULE_BASE_OUTDIR/jar
-
-JAVACLASSPATH += $$PWD/src
-
-JAVASOURCES += $$PWD/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
-
-# install
-target.path = $$[QT_INSTALL_PREFIX]/jar
-INSTALLS += target
diff --git a/src/jar/jar.pro b/src/jar/jar.pro
index 6a4fcd3..c432dc0 100644
--- a/src/jar/jar.pro
+++ b/src/jar/jar.pro
@@ -1,3 +1,13 @@
-TEMPLATE=subdirs
-SUBDIRS += distributedjar.pro bundledjar.pro
+TARGET = QtAndroidWebView
+load(qt_build_paths)
+CONFIG += java
+DESTDIR = $$MODULE_BASE_OUTDIR/jar
+
+JAVACLASSPATH += $$PWD/src
+
+JAVASOURCES += $$PWD/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
+
+# install
+target.path = $$[QT_INSTALL_PREFIX]/jar
+INSTALLS += target
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..9cf7b93 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)
@@ -299,18 +287,14 @@ void QDarwinWebViewPrivate::setUrl(const QUrl &url)
if (url.isValid()) {
requestFrameCount = 0;
-#if QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(101100, 90000)
if (url.isLocalFile()) {
// We need to pass local files via loadFileURL and the read access should cover
// the directory that the file is in, to facilitate loading referenced images etc
- if (__builtin_available(macOS 10.11, iOS 9, *)) {
- [wkWebView loadFileURL:url.toNSURL()
- allowingReadAccessToURL:QUrl(url.toString(QUrl::RemoveFilename)).toNSURL()];
- return;
- }
+ [wkWebView loadFileURL:url.toNSURL()
+ allowingReadAccessToURL:QUrl(url.toString(QUrl::RemoveFilename)).toNSURL()];
+ } else {
+ [wkWebView loadRequest:[NSURLRequest requestWithURL:url.toNSURL()]];
}
-#endif
- [wkWebView loadRequest:[NSURLRequest requestWithURL:url.toNSURL()]];
}
}
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 6ea9872..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;
}
@@ -206,7 +199,7 @@ void QWebEngineWebViewPrivate::QQuickWebEngineViewPtr::init() const
{
Q_ASSERT(!m_webEngineView);
QObject *p = qobject_cast<QObject *>(m_parent);
- QQuickItem *parentItem = Q_NULLPTR;
+ QQuickItem *parentItem = nullptr;
while (p) {
p = p->parent();
parentItem = qobject_cast<QQuickWebView *>(p);
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 88b5ddf..0faf7d1 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>
@@ -49,6 +49,7 @@
#include <wrl.h>
#include <windows.graphics.display.h>
+#include <windows.system.h>
#include <windows.ui.xaml.h>
#include <windows.ui.xaml.controls.h>
#include <windows.ui.xaml.markup.h>
@@ -59,6 +60,7 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections;
using namespace ABI::Windows::Graphics::Display;
+using namespace ABI::Windows::System;
using namespace ABI::Windows::UI;
using namespace ABI::Windows::UI::Xaml;
using namespace ABI::Windows::UI::Xaml::Controls;
@@ -261,11 +263,6 @@ static QString webErrorStatusString(WebErrorStatus status)
return QString();
}
-QWebViewPrivate *QWebViewPrivate::create(QWebView *q)
-{
- return new QWinRTWebViewPrivate(q);
-}
-
struct WinRTWebView
{
ComPtr<IWebView> base;
@@ -275,12 +272,14 @@ struct WinRTWebView
ComPtr<ICanvasStatics> canvas;
ComPtr<IUriRuntimeClassFactory> uriFactory;
ComPtr<IDisplayInformation> displayInformation;
+ ComPtr<ILauncherStatics> launcherStatics;
QPointer<QWindow> window;
QHash<IAsyncOperation<HSTRING> *, int> callbacks;
EventRegistrationToken navigationStartingToken;
EventRegistrationToken navigationCompletedToken;
+ EventRegistrationToken unviewableContentToken;
bool isLoading : 1;
};
@@ -290,7 +289,7 @@ static const wchar_t webviewXaml[] = LSTRING(
);
QWinRTWebViewPrivate::QWinRTWebViewPrivate(QObject *parent)
- : QWebViewPrivate(parent), d(new WinRTWebView)
+ : QAbstractWebView(parent), d(new WinRTWebView)
{
d->isLoading = false;
@@ -310,15 +309,22 @@ QWinRTWebViewPrivate::QWinRTWebViewPrivate(QObject *parent)
Q_ASSERT_SUCCEEDED(hr);
hr = d->base.As(&d->ext);
Q_ASSERT_SUCCEEDED(hr);
+ hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Launcher).Get(),
+ IID_PPV_ARGS(&d->launcherStatics));
+ Q_ASSERT_SUCCEEDED(hr);
hr = d->ext->add_NavigationStarting(
Callback<ITypedEventHandler<WebView *, WebViewNavigationStartingEventArgs *>>(this, &QWinRTWebViewPrivate::onNavigationStarted).Get(),
&d->navigationStartingToken);
Q_ASSERT_SUCCEEDED(hr);
- d->ext->add_NavigationCompleted(
+ hr = d->ext->add_NavigationCompleted(
Callback<ITypedEventHandler<WebView *, WebViewNavigationCompletedEventArgs *>>(this, &QWinRTWebViewPrivate::onNavigationCompleted).Get(),
&d->navigationCompletedToken);
Q_ASSERT_SUCCEEDED(hr);
+ hr = d->ext->add_UnviewableContentIdentified(
+ Callback<ITypedEventHandler<WebView *, WebViewUnviewableContentIdentifiedEventArgs *>>(this, &QWinRTWebViewPrivate::onUnviewableContent).Get(),
+ &d->unviewableContentToken);
+ Q_ASSERT_SUCCEEDED(hr);
ComPtr<IDisplayInformationStatics> displayInformationStatics;
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(),
@@ -342,6 +348,13 @@ QWinRTWebViewPrivate::~QWinRTWebViewPrivate()
{
QEventDispatcherWinRT::runOnXamlThread([this]() {
HRESULT hr;
+ hr = d->ext->remove_NavigationStarting(d->navigationStartingToken);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = d->ext->remove_NavigationCompleted(d->navigationCompletedToken);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = d->ext->remove_UnviewableContentIdentified(d->unviewableContentToken);
+ Q_ASSERT_SUCCEEDED(hr);
+
ComPtr<IVector<UIElement *>> children;
hr = d->host->get_Children(&children);
Q_ASSERT_SUCCEEDED(hr);
@@ -383,6 +396,11 @@ void QWinRTWebViewPrivate::setUrl(const QUrl &url)
hr = d->uriFactory->CreateUri(uriString.Get(), &uri);
Q_ASSERT_SUCCEEDED(hr);
hr = d->base->Navigate(uri.Get());
+ // Directly running into an abort means, that the URI is not supported. Ask the user what to do
+ if (hr == E_ABORT) {
+ ComPtr<IAsyncOperation<bool>> op;
+ hr = d->launcherStatics->LaunchUriAsync(uri.Get(), &op);
+ }
Q_ASSERT_SUCCEEDED(hr);
return hr;
});
@@ -670,3 +688,15 @@ HRESULT QWinRTWebViewPrivate::onNavigationCompleted(IWebView *, IWebViewNavigati
emit loadProgressChanged(100);
return S_OK;
}
+
+HRESULT QWinRTWebViewPrivate::onUnviewableContent(IWebView *, IWebViewUnviewableContentIdentifiedEventArgs *args)
+{
+ HRESULT hr;
+ ComPtr<IUriRuntimeClass> uri;
+ hr = args->get_Uri(&uri);
+ Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<IAsyncOperation<bool>> op;
+ hr = d->launcherStatics->LaunchUriAsync(uri.Get(), &op);
+ Q_ASSERT_SUCCEEDED(hr);
+ return S_OK;
+}
diff --git a/src/webview/qwebview_winrt_p.h b/src/plugins/winrt/qwinrtwebview_p.h
index dfff58e..3756b7d 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 {
@@ -58,6 +58,7 @@ namespace ABI {
struct IWebView;
struct IWebViewNavigationStartingEventArgs;
struct IWebViewNavigationCompletedEventArgs;
+ struct IWebViewUnviewableContentIdentifiedEventArgs;
}
}
}
@@ -67,11 +68,11 @@ namespace ABI {
QT_BEGIN_NAMESPACE
struct WinRTWebView;
-class QWinRTWebViewPrivate : public QWebViewPrivate
+class QWinRTWebViewPrivate : public QAbstractWebView
{
Q_OBJECT
public:
- explicit QWinRTWebViewPrivate(QObject *parent = Q_NULLPTR);
+ explicit QWinRTWebViewPrivate(QObject *parent = nullptr);
~QWinRTWebViewPrivate() Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
@@ -101,9 +102,11 @@ protected:
private:
HRESULT onNavigationStarted(ABI::Windows::UI::Xaml::Controls::IWebView *, ABI::Windows::UI::Xaml::Controls::IWebViewNavigationStartingEventArgs *);
HRESULT onNavigationCompleted(ABI::Windows::UI::Xaml::Controls::IWebView *, ABI::Windows::UI::Xaml::Controls::IWebViewNavigationCompletedEventArgs *);
+ HRESULT onUnviewableContent(ABI::Windows::UI::Xaml::Controls::IWebView *,
+ ABI::Windows::UI::Xaml::Controls::IWebViewUnviewableContentIdentifiedEventArgs *);
QScopedPointer<WinRTWebView> d;
};
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 1af6dcf..0000000
--- a/src/webview/webview-lib.pri
+++ /dev/null
@@ -1,77 +0,0 @@
-ANDROID_BUNDLED_JAR_DEPENDENCIES = \
- jar/QtAndroidWebView-bundled.jar
-ANDROID_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)