diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-03-04 15:37:18 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-03-04 15:37:18 +0100 |
commit | c9813c11a0c8a928d8fac4eb63efd29eec50047d (patch) | |
tree | d46e841c88f75adf0e519975320f48821acaec64 /src/clicktoflash.cpp | |
parent | delete clicktoflash object just when detection doesn't fail. (diff) | |
download | rekonq-c9813c11a0c8a928d8fac4eb63efd29eec50047d.tar.xz |
Fix Click to Flash.
In my tests it doesn't crash anymore and works ever well :)
(Please, don't wake up me if this is just aa dream..)
Diffstat (limited to 'src/clicktoflash.cpp')
-rw-r--r-- | src/clicktoflash.cpp | 54 |
1 files changed, 34 insertions, 20 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; +} |