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

64 lines
2.7 KiB
C++
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
2011-10-17 09:57:07 +02:00
* Copyright (C) 2010-2011 David Rosca
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"
2011-03-17 17:03:04 +01:00
WebPluginFactory::WebPluginFactory(QObject* parent)
2011-03-02 16:57:41 +01:00
: QWebPluginFactory(parent)
{
}
QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues) const
{
if (mimeType.isEmpty())
return 0;
2011-03-02 16:57:41 +01:00
if (mimeType != "application/x-shockwave-flash") {
if (mimeType != "application/futuresplash")
qDebug() << "missing mimeType handler for: " << mimeType;
2011-03-02 16:57:41 +01:00
return 0;
}
2011-03-04 13:59:07 +01:00
if (!mApp->plugins()->c2f_isEnabled())
2011-03-02 16:57:41 +01:00
return 0;
//Click2Flash whitelist
2011-03-04 13:59:07 +01:00
QStringList whitelist = mApp->plugins()->c2f_getWhiteList();
2011-03-02 16:57:41 +01:00
if (whitelist.contains(url.host()) || whitelist.contains("www."+url.host()) || whitelist.contains(url.host().remove("www.")))
return 0;
ClickToFlash* ctf = new ClickToFlash(url, argumentNames, argumentValues);
return ctf;
2011-03-02 16:57:41 +01:00
}
QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
{
QList<QWebPluginFactory::Plugin> plugins;
return plugins;
// QWebPluginFactory::Plugin plugin;
// plugin.name = QLatin1String("ClickToFlashPlugin"); // Mmmm, it should return this,
// QWebPluginFactory::MimeType mimeType; // but with WebKit 533.3, click2flash
// mimeType.fileExtensions << QLatin1String("swf"); // fails on some pages, like youtube.com
// mimeType.name = QLatin1String("application/x-shockwave-flash"); // so we will return empty QList
// plugin.mimeTypes.append(mimeType); // On some pages it also force to load non-flash
// plugins.append(plugin); // content -> in most cases advertisements.
// return plugins; // Not bad to have it hidden :-)
}