summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/adblock/adblockmanager.cpp6
-rw-r--r--src/urlbar/urlbar.cpp10
-rw-r--r--src/urlbar/urlbar.h3
-rw-r--r--src/webpage.cpp1
-rw-r--r--src/webpage.h11
-rw-r--r--src/webtab.cpp6
-rw-r--r--src/webtab.h2
7 files changed, 38 insertions, 1 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 0c0a66db..b435d437 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -226,6 +226,8 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
{
kDebug() << "ADBLOCK: BLACK RULE Matched by string: " << urlString;
AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this);
+ // TODO: add it to blocked list
+ page->setHasAdBlockedElements(true);
return reply;
}
@@ -253,6 +255,8 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
}
AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this);
+ // TODO: add it to blocked list
+ page->setHasAdBlockedElements(true);
return reply;
}
}
@@ -287,6 +291,8 @@ void AdBlockManager::applyHidingRules(WebPage *page)
kDebug() << "Hide element: " << el.localName();
el.setStyleProperty(QL1S("visibility"), QL1S("hidden"));
el.removeFromDocument();
+ // TODO: add it to hided list
+ page->setHasAdBlockedElements(true);
}
}
}
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 43109db3..9ef51f47 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -402,6 +402,12 @@ void UrlBar::loadFinished()
connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showSearchEngine(QPoint)));
}
+ if (_tab->hasAdBlockedElements())
+ {
+ IconButton *bt = addRightIcon(UrlBar::AdBlock);
+ connect(bt, SIGNAL(clicked(QPoint)), (QObject *) rApp->adblockManager(), SLOT(showBlockedItems()));
+ }
+
// we need to update urlbar after the right icon settings
// removing this code (where setStyleSheet automatically calls update) needs adding again
// an update call
@@ -599,6 +605,10 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
rightIcon->setIcon(KIcon("emblem-favorite"));
rightIcon->setToolTip(i18n("Remove from favorite"));
break;
+ case UrlBar::AdBlock:
+ rightIcon->setIcon(KIcon("preferences-web-browser-adblock"));
+ rightIcon->setToolTip(i18n("There are elements blocked by AdBlock"));
+ break;
default:
ASSERT_NOT_REACHED("ERROR.. default non extant case!!");
break;
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index fb7bcb2b..7cd79853 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -83,7 +83,8 @@ public:
SSL = 0x00000100,
BK = 0x00001000,
SearchEngine = 0x00010000,
- Favorite = 0x00100000
+ Favorite = 0x00100000,
+ AdBlock = 0x01000000
};
explicit UrlBar(QWidget *parent = 0);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index a60b0651..7ae7420d 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -444,6 +444,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
void WebPage::loadStarted()
{
+ _hasAdBlockedElements = false;
}
diff --git a/src/webpage.h b/src/webpage.h
index 31f42184..abc9f64c 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -62,6 +62,16 @@ public:
QString suggestedFileName();
+ inline bool hasAdBlockedElements() const
+ {
+ return _hasAdBlockedElements;
+ };
+
+ inline void setHasAdBlockedElements(bool b)
+ {
+ _hasAdBlockedElements = b;
+ };
+
bool hasSslValid() const;
public Q_SLOTS:
@@ -98,6 +108,7 @@ private:
bool _networkAnalyzer;
bool _isOnRekonqPage;
+ bool _hasAdBlockedElements;
};
#endif
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 57f46ea4..8db44dd8 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -347,3 +347,9 @@ void WebTab::showMessageBar()
connect(msgBar, SIGNAL(accepted()), rApp->sessionManager(), SLOT(restoreCrashedSession()));
}
+
+
+bool WebTab::hasAdBlockedElements()
+{
+ return page()->hasAdBlockedElements();
+}
diff --git a/src/webtab.h b/src/webtab.h
index 5c04b683..b0c849ef 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -89,6 +89,8 @@ public:
void setPart(KParts::ReadOnlyPart *p, const KUrl &u);
+ bool hasAdBlockedElements();
+
private Q_SLOTS:
void updateProgress(int progress);
void resetProgress();