2
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
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.
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.
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.
22
#include "QtPlatformPlugin.h"
24
#include "qwebkitplatformplugin.h"
26
#include <QCoreApplication>
28
#include <QPluginLoader>
32
bool QtPlatformPlugin::load(const QString& file)
34
m_loader.setFileName(file);
38
QObject* obj = m_loader.instance();
40
m_plugin = qobject_cast<QWebKitPlatformPlugin*>(obj);
49
bool QtPlatformPlugin::load()
51
const QLatin1String suffix("/webkit/");
52
const QStringList paths = QCoreApplication::libraryPaths();
54
for (int i = 0; i < paths.count(); ++i) {
55
const QDir dir(paths[i] + suffix);
58
const QStringList files = dir.entryList(QDir::Files);
59
for (int j = 0; j < files.count(); ++j) {
60
if (load(dir.absoluteFilePath(files.at(j))))
67
QtPlatformPlugin::~QtPlatformPlugin()
72
bool QtPlatformPlugin::loadStaticallyLinkedPlugin()
74
QObjectList objs = QPluginLoader::staticInstances();
75
for (int i = 0; i < objs.size(); ++i) {
76
m_plugin = qobject_cast<QWebKitPlatformPlugin*>(objs[i]);
83
QWebKitPlatformPlugin* QtPlatformPlugin::plugin()
89
if (loadStaticallyLinkedPlugin())
92
// Plugin path is stored in a static variable to avoid searching for the plugin
94
static QString pluginPath;
96
if (pluginPath.isNull()) {
98
pluginPath = m_loader.fileName();
105
PassOwnPtr<QWebSelectMethod> QtPlatformPlugin::createSelectInputMethod()
107
QWebKitPlatformPlugin* p = plugin();
108
return adoptPtr(p ? static_cast<QWebSelectMethod*>(p->createExtension(QWebKitPlatformPlugin::MultipleSelections)) : 0);
111
PassOwnPtr<QWebNotificationPresenter> QtPlatformPlugin::createNotificationPresenter()
113
QWebKitPlatformPlugin* p = plugin();
114
return adoptPtr(p ? static_cast<QWebNotificationPresenter*>(p->createExtension(QWebKitPlatformPlugin::Notifications)) : 0);
117
PassOwnPtr<QWebHapticFeedbackPlayer> QtPlatformPlugin::createHapticFeedbackPlayer()
119
QWebKitPlatformPlugin* p = plugin();
120
return adoptPtr(p ? static_cast<QWebHapticFeedbackPlayer*>(p->createExtension(QWebKitPlatformPlugin::Haptics)) : 0);
123
PassOwnPtr<QWebTouchModifier> QtPlatformPlugin::createTouchModifier()
125
QWebKitPlatformPlugin* p = plugin();
126
return adoptPtr(p ? static_cast<QWebTouchModifier*>(p->createExtension(QWebKitPlatformPlugin::TouchInteraction)) : 0);
129
#if ENABLE(VIDEO) && USE(QT_MULTIMEDIA)
130
PassOwnPtr<QWebFullScreenVideoHandler> QtPlatformPlugin::createFullScreenVideoHandler()
132
QWebKitPlatformPlugin* p = plugin();
133
return adoptPtr(p ? static_cast<QWebFullScreenVideoHandler*>(p->createExtension(QWebKitPlatformPlugin::FullScreenVideoPlayer)) : 0);
137
PassOwnPtr<QWebSpellChecker> QtPlatformPlugin::createSpellChecker()
139
QWebKitPlatformPlugin* p = plugin();
140
return adoptPtr(p ? static_cast<QWebSpellChecker*>(p->createExtension(QWebKitPlatformPlugin::SpellChecker)) : 0);