summaryrefslogtreecommitdiff
path: root/src/adblock
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-09-30 23:20:46 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-09-30 23:20:46 +0200
commitb92ab57a7a65c4c438fe0ff9d35ea6234cd0f1db (patch)
tree07a4d692f131114f52be7262e3121f02a1c0d421 /src/adblock
parentrekonq 0.6.50 (diff)
parentImplement a sort of debugging informations for adblock (diff)
downloadrekonq-b92ab57a7a65c4c438fe0ff9d35ea6234cd0f1db.tar.xz
Merge branch 'AdBlockImprovements'
Diffstat (limited to 'src/adblock')
-rw-r--r--src/adblock/adblockrule.h6
-rw-r--r--src/adblock/adblockrulefallbackimpl.cpp12
-rw-r--r--src/adblock/adblockrulefallbackimpl.h3
-rw-r--r--src/adblock/adblockruleimpl.h4
-rw-r--r--src/adblock/adblockruletextmatchimpl.cpp12
-rw-r--r--src/adblock/adblockruletextmatchimpl.h3
6 files changed, 39 insertions, 1 deletions
diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h
index 701a9fe1..81110054 100644
--- a/src/adblock/adblockrule.h
+++ b/src/adblock/adblockrule.h
@@ -74,7 +74,11 @@ public:
bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const
{
Q_ASSERT(encodedUrl.toLower() == encodedUrlLowerCase);
- return m_implementation->match(request, encodedUrl, encodedUrlLowerCase);
+ bool b = m_implementation->match(request, encodedUrl, encodedUrlLowerCase);
+ if(b) {
+ kDebug() << m_implementation->ruleType() << ": rule string = " << m_implementation->ruleString();
+ }
+ return b;
}
private:
diff --git a/src/adblock/adblockrulefallbackimpl.cpp b/src/adblock/adblockrulefallbackimpl.cpp
index 959050da..127421fc 100644
--- a/src/adblock/adblockrulefallbackimpl.cpp
+++ b/src/adblock/adblockrulefallbackimpl.cpp
@@ -139,3 +139,15 @@ QString AdBlockRuleFallbackImpl::convertPatternToRegExp(const QString &wildcardP
// Finally, return...
return pattern;
}
+
+
+QString AdBlockRuleFallbackImpl::ruleString() const
+{
+ return m_regExp.pattern();
+}
+
+
+QString AdBlockRuleFallbackImpl::ruleType() const
+{
+ return QL1S("AdBlockRuleFallbackImpl");
+} \ No newline at end of file
diff --git a/src/adblock/adblockrulefallbackimpl.h b/src/adblock/adblockrulefallbackimpl.h
index 8cb02e10..ec10ee51 100644
--- a/src/adblock/adblockrulefallbackimpl.h
+++ b/src/adblock/adblockrulefallbackimpl.h
@@ -39,6 +39,9 @@ public:
AdBlockRuleFallbackImpl(const QString &filter);
bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const;
+ QString ruleString() const;
+ QString ruleType() const;
+
private:
QString convertPatternToRegExp(const QString &wildcardPattern);
diff --git a/src/adblock/adblockruleimpl.h b/src/adblock/adblockruleimpl.h
index 7702217b..d7f51c19 100644
--- a/src/adblock/adblockruleimpl.h
+++ b/src/adblock/adblockruleimpl.h
@@ -35,6 +35,10 @@ public:
AdBlockRuleImpl(const QString &) {}
virtual ~AdBlockRuleImpl() {}
virtual bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const = 0;
+
+ // This are added just for debugging purposes
+ virtual QString ruleString() const = 0;
+ virtual QString ruleType() const = 0;
};
#endif // ADBLOCKRULEIMPL_H
diff --git a/src/adblock/adblockruletextmatchimpl.cpp b/src/adblock/adblockruletextmatchimpl.cpp
index 2d534a3a..7296d837 100644
--- a/src/adblock/adblockruletextmatchimpl.cpp
+++ b/src/adblock/adblockruletextmatchimpl.cpp
@@ -72,3 +72,15 @@ bool AdBlockRuleTextMatchImpl::isTextMatchFilter(const QString &filter)
}
return true;
}
+
+
+QString AdBlockRuleTextMatchImpl::ruleString() const
+{
+ return m_textToMatch;
+}
+
+
+QString AdBlockRuleTextMatchImpl::ruleType() const
+{
+ return QL1S("AdBlockRuleTextMatchImpl");
+}
diff --git a/src/adblock/adblockruletextmatchimpl.h b/src/adblock/adblockruletextmatchimpl.h
index b2c6e239..eefea625 100644
--- a/src/adblock/adblockruletextmatchimpl.h
+++ b/src/adblock/adblockruletextmatchimpl.h
@@ -39,6 +39,9 @@ public:
bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const;
static bool isTextMatchFilter(const QString &filter);
+
+ QString ruleString() const;
+ QString ruleType() const;
private:
QString m_textToMatch;