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: Proper exception rule handling Created Nov. 3, 2013, 3:46 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
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, documentUrls.back());
Wladimir Palant 2013/11/04 07:17:28 Nit: use lastDocumentUrl instead of documentUrls.b
Felix Dahlke 2013/11/15 08:18:19 Done.
+}
+
+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') | test/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld