diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clicktoflash.cpp | 54 | ||||
-rw-r--r-- | src/clicktoflash.h | 3 | ||||
-rw-r--r-- | src/webpluginfactory.cpp | 2 |
3 files changed, 38 insertions, 21 deletions
diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp index 24f8740e..3c284b3f 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -31,6 +31,7 @@ // KDE Includes #include <KLocalizedString> +#include <KDebug> // Qt Includes #include <QWebFrame> @@ -89,28 +90,11 @@ void ClickToFlash::load() elements.append(docElement.findAll(selector.arg(QLatin1String("object")))); elements.append(docElement.findAll(selector.arg(QLatin1String("embed")))); - bool isRightElement = false; foreach (QWebElement element, elements) { - // TODO : find a proper solution to compare a QWebElement with a plugin - // With this "manual" test, it's probably not working everywhere - if(QUrl(element.attribute("data")) == m_url - || QUrl(element.attribute("src")) == m_url) - isRightElement = true; - else - { - QWebElementCollection collec = element.findAll("param"); - int i = 0; - while(i < collec.count() && isRightElement == false) - { - if(QUrl(collec.at(i).attribute("value")) == m_url) - isRightElement = true; - i++; - } - } - - if(isRightElement) + if( checkElement(element) ) { + kDebug() << "RETURNED TRUE ..........................."; QWebElement substitute = element.clone(); emit signalLoadClickToFlash(true); element.replace(substitute); @@ -118,9 +102,39 @@ void ClickToFlash::load() return; } } - frames += frame->childFrames(); } } +bool ClickToFlash::checkElement(QWebElement el) +{ + kDebug() << "src: " << QUrl(el.attribute("src")); + kDebug() << "url: " << m_url; + + QString checkString; + QString urlString; + + checkString = QUrl(el.attribute("src")).toString( QUrl::RemoveQuery ); + urlString = m_url.toString( QUrl::RemoveQuery ); + + if( urlString.contains( checkString ) ) + return true; + + QWebElementCollection collec = el.findAll("*"); + int i = 0; + while( i < collec.count() ) + { + QWebElement el = collec.at(i); + + checkString = QUrl(el.attribute("src")).toString( QUrl::RemoveQuery ); + urlString = m_url.toString( QUrl::RemoveQuery ); + + if( urlString.contains( checkString ) ) + return true; + + i++; + } + + return false; +} diff --git a/src/clicktoflash.h b/src/clicktoflash.h index 2284ec7e..7d6c4e05 100644 --- a/src/clicktoflash.h +++ b/src/clicktoflash.h @@ -35,6 +35,7 @@ // Qt Includes #include <QWidget> #include <QUrl> +#include <QWebElement> // Forward Declarations class WebPluginFactory; @@ -54,6 +55,8 @@ private slots: void load(); private: + bool checkElement(QWebElement el); + /** used to find the right QWebElement between the ones of the different plugins */ diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index c8060969..9e4b8ba3 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -79,7 +79,7 @@ QObject *WebPluginFactory::create(const QString &mimeType, if( _loadClickToFlash ) { emit signalLoadClickToFlash(false); - return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); + return 0; //KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); } else { |