 Issue 5316782940225536:
  Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later.  (Closed)
    
  
    Issue 5316782940225536:
  Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later.  (Closed) 
  | Index: src/plugin/PluginFilter.cpp | 
| =================================================================== | 
| --- a/src/plugin/PluginFilter.cpp | 
| +++ b/src/plugin/PluginFilter.cpp | 
| @@ -1,20 +1,20 @@ | 
| -/* | 
| - * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| - * Copyright (C) 2006-2015 Eyeo GmbH | 
| - * | 
| - * Adblock Plus is free software: you can redistribute it and/or modify | 
| - * it under the terms of the GNU General Public License version 3 as | 
| - * published by the Free Software Foundation. | 
| - * | 
| - * Adblock Plus is distributed in the hope that it will be useful, | 
| - * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| - * GNU General Public License for more details. | 
| - * | 
| - * You should have received a copy of the GNU General Public License | 
| - * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| - */ | 
| - | 
| +/* | 
| + * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| + * Copyright (C) 2006-2015 Eyeo GmbH | 
| + * | 
| + * Adblock Plus is free software: you can redistribute it and/or modify | 
| + * it under the terms of the GNU General Public License version 3 as | 
| + * published by the Free Software Foundation. | 
| + * | 
| + * Adblock Plus is distributed in the hope that it will be useful, | 
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| + * GNU General Public License for more details. | 
| + * | 
| + * You should have received a copy of the GNU General Public License | 
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| + */ | 
| + | 
| #include "PluginStdAfx.h" | 
| #include "PluginFilter.h" | 
| @@ -30,7 +30,6 @@ | 
| #include "..\shared\CriticalSection.h" | 
| #include "..\shared\Utils.h" | 
| - | 
| // The filters are described at http://adblockplus.org/en/filters | 
| static CriticalSection s_criticalSectionFilterMap; | 
| @@ -288,7 +287,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), | 
| 
Eric
2015/02/02 06:58:27
Here it is in the default constructor.
 | 
| m_isFromStart(false), m_isFromEnd(false), m_hitCount(0) | 
| { | 
| } | 
| @@ -472,18 +472,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(); | 
| } | 
| @@ -720,7 +709,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 | 
| { | 
| std::wstring srcTrimmed = TrimString(src); | 
| @@ -730,35 +719,25 @@ | 
| { | 
| return false; | 
| } | 
| + | 
| CPluginSettings* settings = CPluginSettings::GetInstance(); | 
| - CString type; | 
| + CPluginClient* client = CPluginClient::GetInstance(); | 
| + bool result = client->Matches(srcTrimmed, 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(AdblockPlus::FilterEngine::ContentTypeToString(contentType)); | 
| + if (result) | 
| { | 
| - type = it->second; | 
| + CPluginDebug::DebugResultBlocking(ToCString(type), srcTrimmed, domain); | 
| + } | 
| + else | 
| + { | 
| + CPluginDebug::DebugResultIgnoring(ToCString(type), srcTrimmed, domain); | 
| } | 
| } | 
| - | 
| - CPluginClient* client = CPluginClient::GetInstance(); | 
| - if (client->Matches(srcTrimmed, ToWstring(type), domain)) | 
| - { | 
| - if (addDebug) | 
| - { | 
| - DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") | 
| - | 
| -#ifdef ENABLE_DEBUG_RESULT | 
| - CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); | 
| #endif | 
| - } | 
| - return true; | 
| - } | 
| -#ifdef ENABLE_DEBUG_RESULT | 
| - CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain); | 
| -#endif | 
| - return false; | 
| + return result; | 
| } |