1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 17:42:10 +01:00
falkonOfficial/src/plugins/webpluginfactory.cpp

80 lines
2.6 KiB
C++
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
2011-03-03 18:29:20 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
2011-03-02 16:57:41 +01:00
#include "webpluginfactory.h"
#include "clicktoflash.h"
#include "mainapplication.h"
#include "pluginproxy.h"
#include "webpage.h"
2011-03-02 16:57:41 +01:00
WebPluginFactory::WebPluginFactory(WebPage* page)
: QWebPluginFactory(page)
, m_page(page)
2011-03-02 16:57:41 +01:00
{
}
QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues) const
{
QString mime = mimeType.trimmed(); //Fixing bad behaviour when mimeType contains spaces
if (mime.isEmpty()) {
return 0;
}
if (mime != "application/x-shockwave-flash") {
if (mime != "application/futuresplash" && mime != "application/x-java-applet") {
qDebug() << "WebPluginFactory::create missing mimeType handler for: " << mime;
}
2011-03-02 16:57:41 +01:00
return 0;
}
if (!mApp->plugins()->c2f_isEnabled()) {
2011-03-02 16:57:41 +01:00
return 0;
}
2011-03-02 16:57:41 +01:00
// Click2Flash whitelist
2011-03-04 13:59:07 +01:00
QStringList whitelist = mApp->plugins()->c2f_getWhiteList();
if (whitelist.contains(url.host()) || whitelist.contains("www." + url.host()) || whitelist.contains(url.host().remove("www."))) {
2011-03-02 16:57:41 +01:00
return 0;
}
// Click2Flash already accepted
if (ClickToFlash::isAlreadyAccepted(url, argumentNames, argumentValues)) {
return 0;
}
2011-03-02 16:57:41 +01:00
ClickToFlash* ctf = new ClickToFlash(url, argumentNames, argumentValues, m_page);
return ctf;
2011-03-02 16:57:41 +01:00
}
QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
{
QList<Plugin> plugins;
return plugins;
// QList<QWebPluginFactory::Plugin> plugins;
2011-03-02 16:57:41 +01:00
// QWebPluginFactory::Plugin plugin;
// QWebPluginFactory::MimeType mimeType;
// mimeType.fileExtensions << "swf";
// mimeType.name = "application/x-shockwave-flash";
// plugin.name = "ClickToFlashPlugin";
// plugin.mimeTypes.append(mimeType);
// plugins.append(plugin);
// return plugins;
2011-03-02 16:57:41 +01:00
}