Index: src/plugin/PluginFilter.cpp |
diff --git a/src/plugin/PluginFilter.cpp b/src/plugin/PluginFilter.cpp |
index 7bbd8fa461428d66ae94029091fc359e0b66615c..4f110a3fdabb400ef1cdf38e409233ec067bca5e 100644 |
--- a/src/plugin/PluginFilter.cpp |
+++ b/src/plugin/PluginFilter.cpp |
@@ -12,6 +12,7 @@ |
#include "..\shared\CriticalSection.h" |
#include "..\shared\Utils.h" |
+#include "..\shared\ContentType.h" |
// The filters are described at http://adblockplus.org/en/filters |
@@ -271,7 +272,8 @@ CFilter::CFilter(const CFilter& filter) |
} |
-CFilter::CFilter() : m_isMatchCase(false), m_isFirstParty(false), m_isThirdParty(false), m_contentType(CFilter::contentTypeAny), |
+CFilter::CFilter() : m_isMatchCase(false), m_isFirstParty(false), |
+ m_isThirdParty(false), m_contentType(AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_OTHER), |
m_isFromStart(false), m_isFromEnd(false), m_hitCount(0) |
{ |
} |
@@ -455,18 +457,7 @@ bool CFilterElementHide::IsMatchFilterElementHide(IHTMLElement* pEl) const |
CPluginFilter::CPluginFilter(const CString& dataPath) : m_dataPath(dataPath) |
{ |
- m_contentMapText[CFilter::contentTypeDocument] = "DOCUMENT"; |
- m_contentMapText[CFilter::contentTypeObject] = "OBJECT"; |
- m_contentMapText[CFilter::contentTypeObjectSubrequest] = "OBJECT_SUBREQUEST"; |
- m_contentMapText[CFilter::contentTypeImage] = "IMAGE"; |
- m_contentMapText[CFilter::contentTypeScript] = "SCRIPT"; |
- m_contentMapText[CFilter::contentTypeOther] = "OTHER"; |
- m_contentMapText[CFilter::contentTypeUnknown] = "OTHER"; |
- m_contentMapText[CFilter::contentTypeSubdocument] = "SUBDOCUMENT"; |
- m_contentMapText[CFilter::contentTypeStyleSheet] = "STYLESHEET"; |
- m_contentMapText[CFilter::contentTypeXmlHttpRequest] = "XMLHTTPREQUEST"; |
- |
- ClearFilters(); |
+ ClearFilters(); |
} |
@@ -536,7 +527,7 @@ bool CPluginFilter::AddFilterElementHide(CString filterText) |
bool CPluginFilter::IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::wstring& domain, const std::wstring& indent) const |
{ |
- CString tagCString = to_CString(tag); |
+ CString tagCString = ToCString(tag); |
CString id; |
CComBSTR bstrId; |
@@ -703,9 +694,9 @@ void CPluginFilter::ClearFilters() |
} |
} |
-bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug) const |
+bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentType contentType, const std::wstring& domain, bool addDebug) const |
{ |
- CString srcCString = to_CString(src); |
+ CString srcCString = ToCString(src); |
// We should not block the empty string, so all filtering does not make sense |
// Therefore we just return |
@@ -716,33 +707,23 @@ bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const |
CPluginSettings* settings = CPluginSettings::GetInstance(); |
- CString type; |
+ CPluginClient* client = CPluginClient::GetInstance(); |
+ bool result = client->Matches(ToWstring(srcCString), contentType, domain); |
+ |
+#ifdef ENABLE_DEBUG_RESULT |
if (addDebug) |
{ |
- type = "OTHER"; |
- |
- std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType); |
- if (it != m_contentMapText.end()) |
+ std::wstring type = ToUtf16String(ContentTypeToString(contentType)); |
+ if (result) |
{ |
- type = it->second; |
+ DEBUG_FILTER("Filter::ShouldBlock " + type + " YES"); |
+ CPluginDebug::DebugResultBlocking(ToCString(type), srcCString, domain); |
} |
- } |
- |
- CPluginClient* client = CPluginClient::GetInstance(); |
- if (client->Matches(to_wstring(srcCString), to_wstring(type), domain)) |
- { |
- if (addDebug) |
+ else |
{ |
- DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") |
- |
-#ifdef ENABLE_DEBUG_RESULT |
- CPluginDebug::DebugResultBlocking(type, srcCString, domain); |
-#endif |
+ CPluginDebug::DebugResultIgnoring(ToCString(type), srcCString, domain); |
} |
- return true; |
} |
-#ifdef ENABLE_DEBUG_RESULT |
- CPluginDebug::DebugResultIgnoring(type, srcCString, domain); |
#endif |
- return false; |
+ return result; |
} |