Index: src/FilterEngine.cpp |
diff --git a/src/FilterEngine.cpp b/src/FilterEngine.cpp |
index 95ef0c4c37ff2ee111551879f0790a7e01cf4fb6..ac999a3e56377321f5f33a016ae98a15a20c9088 100644 |
--- a/src/FilterEngine.cpp |
+++ b/src/FilterEngine.cpp |
@@ -134,7 +134,7 @@ bool Subscription::operator==(const Subscription& subscription) const |
return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsString(); |
} |
-FilterEngine::FilterEngine(JsEnginePtr jsEngine, |
Felix Dahlke
2015/12/03 20:34:18
Nit: Entirely unrelated, separate noissue commit p
René Jeschke
2015/12/03 20:39:59
Done.
|
+FilterEngine::FilterEngine(JsEnginePtr jsEngine, |
const FilterEngine::Prefs& preconfiguredPrefs) |
: jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) |
{ |
@@ -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); |
+} |
+ |
+bool FilterEngine::IsElemhideWhitelisted(const std::string& url, |
+ const std::vector<std::string>& documentUrls) const |
+{ |
+ return !!GetWhitelistingFilter(url, CONTENT_TYPE_ELEMHIDE, documentUrls); |
+} |
+ |
AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, |
ContentType contentType, |
const std::string& documentUrl) const |
@@ -462,3 +474,40 @@ 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); |
+ 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(); |
+} |