Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FilterEngine.cpp

Issue 23127017: Consider the frame structure in Matches() (Closed)
Patch Set: Better test coverage Created Nov. 15, 2013, 8:15 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -215,6 +215,36 @@
const std::string& contentType,
const std::string& documentUrl) const
{
+ std::vector<std::string> documentUrls;
+ documentUrls.push_back(documentUrl);
+ return Matches(url, contentType, documentUrls);
+}
+
+AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url,
+ const std::string& contentType,
+ const std::vector<std::string>& documentUrls) const
+{
+ if (documentUrls.empty())
+ return CheckFilterMatch(url, contentType, "");
+
+ std::string lastDocumentUrl = documentUrls.front();
+ for (std::vector<std::string>::const_iterator it = documentUrls.begin();
+ it != documentUrls.end(); it++) {
+ const std::string documentUrl = *it;
+ AdblockPlus::FilterPtr match = CheckFilterMatch(documentUrl, "DOCUMENT",
+ lastDocumentUrl);
+ if (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION)
+ return match;
+ lastDocumentUrl = documentUrl;
+ }
+
+ return CheckFilterMatch(url, contentType, lastDocumentUrl);
+}
+
+AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url,
+ const std::string& contentType,
+ const std::string& documentUrl) const
+{
JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch");
JsValueList params;
params.push_back(jsEngine->NewValue(url));
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld