summaryrefslogtreecommitdiff
path: root/src/webtab
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-02-24 18:25:01 +0100
committerAndrea Diamantini <adjam7@gmail.com>2013-02-24 18:25:54 +0100
commit90eab081fa7f46961cd1597a7cb98c1dc32bd0b8 (patch)
tree34ab4d91018b1cc37bb0caa0a8fd72c99703ef65 /src/webtab
parentremove consecutive duplicate word >a< (diff)
downloadrekonq-90eab081fa7f46961cd1597a7cb98c1dc32bd0b8.tar.xz
AdBlock Improvement
Hiding rules support (at least the easy ones, the most ones, against hiding id && classes) :D To test it, take a look (in example) at the url: http://simple-adblock.com/faq/testing-your-adblocker/
Diffstat (limited to 'src/webtab')
-rw-r--r--src/webtab/networkaccessmanager.cpp6
-rw-r--r--src/webtab/networkaccessmanager.h4
-rw-r--r--src/webtab/webpage.cpp7
3 files changed, 10 insertions, 7 deletions
diff --git a/src/webtab/networkaccessmanager.cpp b/src/webtab/networkaccessmanager.cpp
index 95bfa47d..8e1394ca 100644
--- a/src/webtab/networkaccessmanager.cpp
+++ b/src/webtab/networkaccessmanager.cpp
@@ -149,7 +149,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR
if (frame)
{
if (!m_blockedRequests.contains(frame))
- connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(slotFinished(bool)));
+ connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(applyHidingBlockedElements(bool)));
m_blockedRequests.insert(frame, req.url());
}
@@ -157,7 +157,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR
}
-void NetworkAccessManager::slotFinished(bool ok)
+void NetworkAccessManager::applyHidingBlockedElements(bool ok)
{
if (!ok)
return;
@@ -181,5 +181,5 @@ void NetworkAccessManager::slotFinished(bool ok)
collection += frame->parentFrame()->findAllElements(HIDABLE_ELEMENTS);
Q_FOREACH(const QUrl & url, urls)
- hideBlockedElements(url, collection);
+ hideBlockedElements(url, collection);
}
diff --git a/src/webtab/networkaccessmanager.h b/src/webtab/networkaccessmanager.h
index d839bdda..3bf45e18 100644
--- a/src/webtab/networkaccessmanager.h
+++ b/src/webtab/networkaccessmanager.h
@@ -53,8 +53,8 @@ protected:
virtual QNetworkReply *createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData = 0);
private Q_SLOTS:
- void slotFinished(bool);
-
+ void applyHidingBlockedElements(bool);
+
private:
QMultiHash<QWebFrame*, QUrl> m_blockedRequests;
QByteArray _acceptLanguage;
diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp
index 958dc5c1..b61f66cf 100644
--- a/src/webtab/webpage.cpp
+++ b/src/webtab/webpage.cpp
@@ -38,6 +38,7 @@
#include "rekonq.h"
// Local Includes
+#include "adblockmanager.h"
#include "downloadmanager.h"
#include "historymanager.h"
#include "iconmanager.h"
@@ -175,6 +176,8 @@ WebPage::WebPage(QWidget *parent, bool isPrivateBrowsing)
connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
+ connect(this, SIGNAL(frameCreated(QWebFrame *)), AdBlockManager::self(), SLOT(applyHidingRules(QWebFrame *)));
+
// protocol handler signals
connect(&_protHandler, SIGNAL(downloadUrl(KUrl)), this, SLOT(downloadUrl(KUrl)));
}
@@ -292,7 +295,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
if (!settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
// Get the SSL information sent, if any...
- KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
+ NetworkAccessManager *manager = qobject_cast<NetworkAccessManager *>(networkAccessManager());
KIO::MetaData metaData = manager->requestMetaData();
if (metaData.contains(QL1S("ssl_in_use")))
{
@@ -502,7 +505,7 @@ void WebPage::loadStarted()
int value = val.toInt();
if (value != 10)
- mainFrame()->setZoomFactor(QVariant(value).toReal() / 10); // Don't allox max +1 values
+ mainFrame()->setZoomFactor(QVariant(value).toReal() / 10); // Don't allox max +1 values
}