1/* 2 Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18*/ 19 20#include "config.h" 21 22#include "private/qquicknetworkreply_p.h" 23#include "private/qquicknetworkrequest_p.h" 24#include "private/qquickwebpage_p.h" 25#include "private/qquickwebview_p.h" 26#include "private/qtwebsecurityorigin_p.h" 27#include "private/qwebdownloaditem_p.h" 28#include "private/qwebkittest_p.h" 29#include "private/qwebnavigationhistory_p.h" 30#include "private/qwebpermissionrequest_p.h" 31#include "private/qwebpreferences_p.h" 32 33#include <QtQml/qqml.h> 34#include <QtQml/qqmlextensionplugin.h> 35 36QT_BEGIN_NAMESPACE 37 38class QQuickWebViewExperimentalExtension : public QObject { 39 Q_OBJECT 40 Q_PROPERTY(QQuickWebViewExperimental* experimental READ experimental CONSTANT FINAL) 41public: 42 QQuickWebViewExperimentalExtension(QObject *parent = 0) : QObject(parent) { } 43 QQuickWebViewExperimental* experimental() { return static_cast<QQuickWebView*>(parent())->experimental(); } 44}; 45 46class WebKitQmlExperimentalExtensionPlugin: public QQmlExtensionPlugin { 47 Q_OBJECT 48 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") 49public: 50 virtual void registerTypes(const char* uri) 51 { 52 qWarning("\nWARNING: This project is using the experimental QML API extensions for QtWebKit and is therefore tied to a specific QtWebKit release.\n" 53 "WARNING: The experimental API will change from version to version, or even be removed. You have been warned!\n"); 54 55 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit.experimental")); 56 57 qmlRegisterUncreatableType<QWebDownloadItem>(uri, 1, 0, "DownloadItem", QObject::tr("Cannot create separate instance of DownloadItem")); 58 qmlRegisterUncreatableType<QWebNavigationListModel>(uri, 1, 0, "NavigationListModel", QObject::tr("Cannot create separate instance of NavigationListModel")); 59 qmlRegisterUncreatableType<QWebNavigationHistory>(uri, 1, 0, "NavigationHistory", QObject::tr("Cannot create separate instance of NavigationHistory")); 60 qmlRegisterUncreatableType<QWebPreferences>(uri, 1, 0, "WebPreferences", QObject::tr("Cannot create separate instance of WebPreferences")); 61 qmlRegisterUncreatableType<QWebPermissionRequest>(uri, 1, 0, "PermissionRequest", QObject::tr("Cannot create separate instance of PermissionRequest")); 62 qmlRegisterUncreatableType<QtWebSecurityOrigin>(uri, 1, 0, "SecurityOrigin", QObject::tr("Cannot create separate instance of SecurityOrigin")); 63 64 qmlRegisterExtendedType<QQuickWebView, QQuickWebViewExperimentalExtension>(uri, 1, 0, "WebView"); 65 qmlRegisterUncreatableType<QQuickWebViewExperimental>(uri, 1, 0, "WebViewExperimental", 66 QObject::tr("Cannot create separate instance of WebViewExperimental")); 67 qmlRegisterUncreatableType<QWebKitTest>(uri, 1, 0, "QWebKitTest", 68 QObject::tr("Cannot create separate instance of QWebKitTest")); 69 qmlRegisterType<QQuickUrlSchemeDelegate>(uri, 1, 0, "UrlSchemeDelegate"); 70 qmlRegisterUncreatableType<QQuickNetworkRequest>(uri, 1, 0, "NetworkRequest", 71 QObject::tr("NetworkRequest should not be created from QML")); 72 qmlRegisterUncreatableType<QQuickNetworkReply>(uri, 1, 0, "NetworkReply", 73 QObject::tr("NetworkReply should not be created from QML")); 74 } 75}; 76 77QT_END_NAMESPACE 78 79#include "plugin.moc" 80