| Index: src/FilterEngine.cpp |
| diff --git a/src/FilterEngine.cpp b/src/FilterEngine.cpp |
| index 95ef0c4c37ff2ee111551879f0790a7e01cf4fb6..11b5a6ef5d05e105b36d61d25065edb0a0c6de29 100644 |
| --- a/src/FilterEngine.cpp |
| +++ b/src/FilterEngine.cpp |
| @@ -325,6 +325,18 @@ AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, |
| return CheckFilterMatch(url, contentType, lastDocumentUrl); |
| } |
| +bool FilterEngine::IsDocumentWhitelisted(const std::string& url, |
| + const std::vector<std::string>& documentUrls) const |
| +{ |
| + return GetWhitelistingFilter(url, CONTENT_TYPE_DOCUMENT, documentUrls) != 0; |
|
Felix Dahlke
2015/12/02 18:02:03
Nit: != 0 is redundant, according to the Mozilla c
René Jeschke
2015/12/02 18:09:42
I know, and I wouldn't normally do this (as you kn
sergei
2015/12/02 18:21:57
Let me take a part, I would compare with `nullptr`
Felix Dahlke
2015/12/02 18:50:26
Yeah, !! is pretty idiomatic for coercing an arbit
René Jeschke
2015/12/03 11:31:20
Yep, fine with me. Went with !! in the end.
|
| +} |
| + |
| +bool FilterEngine::IsElemhideWhitelisted(const std::string& url, |
| + const std::vector<std::string>& documentUrls) const |
| +{ |
| + return GetWhitelistingFilter(url, CONTENT_TYPE_ELEMHIDE, documentUrls) != 0; |
| +} |
| + |
| AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, |
| ContentType contentType, |
| const std::string& documentUrl) const |
| @@ -462,3 +474,41 @@ int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) |
| JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); |
| return func->Call(params)->AsInt(); |
| } |
| + |
| +FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url, |
| + ContentType contentType, const std::string& documentUrl) const |
| +{ |
| + FilterPtr match = Matches(url, contentType, documentUrl); |
| + |
|
Felix Dahlke
2015/12/02 18:02:03
Micro nit: Superfluous whitespace? Can't tell if i
René Jeschke
2015/12/02 18:09:42
Done.
|
| + if (match && match->GetType() == Filter::TYPE_EXCEPTION) |
| + { |
| + return match; |
| + } |
| + return FilterPtr(); |
| +} |
| + |
| +FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url, |
| + ContentType contentType, |
| + const std::vector<std::string>& documentUrls) const |
| +{ |
| + if (documentUrls.empty()) |
| + { |
| + return GetWhitelistingFilter(url, contentType, ""); |
| + } |
| + |
| + std::vector<std::string>::const_iterator urlIterator = documentUrls.begin(); |
| + std::string currentUrl = url; |
| + do |
| + { |
| + std::string parentUrl = *urlIterator++; |
| + FilterPtr filter = GetWhitelistingFilter( |
| + currentUrl, contentType, parentUrl); |
| + if (filter) |
| + { |
| + return filter; |
| + } |
| + currentUrl = parentUrl; |
| + } |
| + while (urlIterator != documentUrls.end()); |
| + return FilterPtr(); |
| +} |