diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-09-29 17:28:18 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-09-29 17:28:18 +0200 |
commit | 0b1564dd34e2b9baf2d981e47abcd4cd7ebcc0f2 (patch) | |
tree | 8f4787ee4dc417209dec1f0ecae974257131d940 /src/adblock | |
parent | HACK: fix Chinese sites encoding, as suggested by Weng Xuetian in bug #251264 (diff) | |
download | rekonq-0b1564dd34e2b9baf2d981e47abcd4cd7ebcc0f2.tar.xz |
Implement a sort of debugging informations for adblock
Diffstat (limited to 'src/adblock')
-rw-r--r-- | src/adblock/adblockrule.h | 6 | ||||
-rw-r--r-- | src/adblock/adblockrulefallbackimpl.cpp | 12 | ||||
-rw-r--r-- | src/adblock/adblockrulefallbackimpl.h | 3 | ||||
-rw-r--r-- | src/adblock/adblockruleimpl.h | 4 | ||||
-rw-r--r-- | src/adblock/adblockruletextmatchimpl.cpp | 12 | ||||
-rw-r--r-- | src/adblock/adblockruletextmatchimpl.h | 3 |
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; |