1/*
2    Copyright (C) 2009 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 "qglobal.h"
23
24#include <QtQml/qqml.h>
25#include <QtQml/qqmlextensionplugin.h>
26
27#if defined(HAVE_WEBKIT2)
28#include "private/qquickwebpage_p.h"
29#include "private/qquickwebview_p.h"
30#include "private/qwebiconimageprovider_p.h"
31#include "private/qwebloadrequest_p.h"
32#include "private/qwebnavigationrequest_p.h"
33
34#include <QtNetwork/qnetworkreply.h>
35#include <QtQml/qqmlengine.h>
36#endif
37
38QT_BEGIN_NAMESPACE
39
40class WebKitQmlPlugin : public QQmlExtensionPlugin {
41    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json")
42    Q_OBJECT
43public:
44#if defined(HAVE_WEBKIT2)
45    virtual void initializeEngine(QQmlEngine* engine, const char* uri)
46    {
47        Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit"));
48        engine->addImageProvider(QLatin1String("webicon"), new QWebIconImageProvider);
49    }
50#endif
51
52    virtual void registerTypes(const char* uri)
53    {
54        Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit"));
55
56#if defined(HAVE_WEBKIT2)
57        qmlRegisterType<QQuickWebView>(uri, 3, 0, "WebView");
58        qmlRegisterUncreatableType<QQuickWebPage>(uri, 3, 0, "WebPage", QObject::tr("Cannot create separate instance of WebPage, use WebView"));
59        qmlRegisterUncreatableType<QNetworkReply>(uri, 3, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
60        qmlRegisterUncreatableType<QWebNavigationRequest>(uri, 3, 0, "NavigationRequest", QObject::tr("Cannot create separate instance of NavigationRequest"));
61        qmlRegisterUncreatableType<QWebLoadRequest>(uri, 3, 0, "WebLoadRequest", QObject::tr("Cannot create separate instance of WebLoadRequest"));
62#endif
63    }
64};
65
66QT_END_NAMESPACE
67
68#include "plugin.moc"
69