| Index: src/plugin/PluginFilter.cpp |
| =================================================================== |
| --- 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 |
| @@ -274,7 +275,8 @@ |
| } |
| -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) |
| { |
| } |
| @@ -459,18 +461,7 @@ |
| 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(); |
| } |
| @@ -707,7 +698,7 @@ |
| } |
| } |
| -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); |
| @@ -720,33 +711,23 @@ |
| CPluginSettings* settings = CPluginSettings::GetInstance(); |
| - CString type; |
| + CPluginClient* client = CPluginClient::GetInstance(); |
| + bool result = client->Matches(to_wstring(srcCString), contentType, domain); |
|
Eric
2014/12/30 16:56:08
ToWstring
|
| + |
| +#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(to_CString(type), srcCString, domain); |
|
Eric
2014/12/30 16:56:08
ToCString
|
| + } |
| + else |
| + { |
| + CPluginDebug::DebugResultIgnoring(to_CString(type), srcCString, domain); |
|
Eric
2014/12/30 16:56:08
ToCString
|
| } |
| } |
| - |
| - CPluginClient* client = CPluginClient::GetInstance(); |
| - if (client->Matches(to_wstring(srcCString), to_wstring(type), domain)) |
| - { |
| - if (addDebug) |
| - { |
| - DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") |
| - |
| -#ifdef ENABLE_DEBUG_RESULT |
| - CPluginDebug::DebugResultBlocking(type, srcCString, domain); |
| #endif |
| - } |
| - return true; |
| - } |
| -#ifdef ENABLE_DEBUG_RESULT |
| - CPluginDebug::DebugResultIgnoring(type, srcCString, domain); |
| -#endif |
| - return false; |
| + return result; |
| } |