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

Unified Diff: src/plugin/PluginFilter.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: Created Nov. 21, 2014, 4:07 p.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 | « src/plugin/PluginFilter.h ('k') | src/plugin/PluginWbPassThrough.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+
+#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);
+ }
+ else
+ {
+ CPluginDebug::DebugResultIgnoring(to_CString(type), srcCString, domain);
}
}
-
- 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;
}
« no previous file with comments | « src/plugin/PluginFilter.h ('k') | src/plugin/PluginWbPassThrough.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld