1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

AdBlock now hides blocked flash content (fixing crash with click2flash

while trying to show blocked flash)
This commit is contained in:
nowrep 2011-04-04 21:28:15 +02:00
parent 2943c0ca93
commit 65ff7932e3
2 changed files with 45 additions and 2 deletions

View File

@ -42,11 +42,55 @@
#include "clickablelabel.h"
#include "mainapplication.h"
#include "pluginproxy.h"
#include "adblockmanager.h"
#include "adblocksubscription.h"
ClickToFlash::ClickToFlash(const QUrl &pluginUrl, QWidget* parent)
: QWidget(parent)
, m_url(pluginUrl)
{
//AdBlock
AdBlockManager* manager = AdBlockManager::instance();
if (manager->isEnabled()) {
QString urlString = pluginUrl.toEncoded();
AdBlockSubscription* subscription = manager->subscription();
if (!subscription->allow(urlString) && subscription->block(urlString)) {
QWidget* parent = parentWidget();
QWebView* view = 0;
while (parent) {
if (QWebView* aView = qobject_cast<QWebView*>(parent)) {
view = aView;
break;
}
parent = parent->parentWidget();
}
if (!view)
return;
const QString selector = "%1[type=\"application/x-shockwave-flash\"]";
QList<QWebFrame*> frames;
frames.append(view->page()->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;
elements.append(docElement.findAll(selector.arg("object")));
elements.append(docElement.findAll(selector.arg("embed")));
foreach(QWebElement element, elements) {
if (checkElement(element)) {
element.setAttribute("style", "visible:none;");
deleteLater();
return;
}
}
frames += frame->childFrames();
}
}
}
QHBoxLayout* horizontalLayout;
QFrame* frame;
QHBoxLayout* horizontalLayout_2;
@ -93,7 +137,7 @@ void ClickToFlash::toWhitelist()
}
void ClickToFlash::load()
{
{
QWidget* parent = parentWidget();
QWebView* view = 0;
while (parent) {

View File

@ -36,7 +36,6 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons
qDebug() << mimeType;
return 0;
}
if (!mApp->plugins()->c2f_isEnabled())
return 0;