OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 644 |
645 void CPluginFilter::ClearFilters() | 645 void CPluginFilter::ClearFilters() |
646 { | 646 { |
647 // Clear filter maps | 647 // Clear filter maps |
648 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 648 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |
649 m_elementHideTags.clear(); | 649 m_elementHideTags.clear(); |
650 m_elementHideTagsId.clear(); | 650 m_elementHideTagsId.clear(); |
651 m_elementHideTagsClass.clear(); | 651 m_elementHideTagsClass.clear(); |
652 } | 652 } |
653 | 653 |
654 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi
ne::ContentType contentType, const std::wstring& domain, bool addDebug) const | |
655 { | |
656 std::wstring srcTrimmed = TrimString(src); | |
657 | |
658 // We should not block the empty string, so all filtering does not make sense | |
659 // Therefore we just return | |
660 if (srcTrimmed.empty()) | |
661 { | |
662 return false; | |
663 } | |
664 | |
665 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
666 | |
667 CPluginClient* client = CPluginClient::GetInstance(); | |
668 bool result = client->Matches(srcTrimmed, contentType, domain); | |
669 | |
670 #ifdef ENABLE_DEBUG_RESULT | |
671 if (addDebug) | |
672 { | |
673 std::wstring type = ToUtf16String(AdblockPlus::FilterEngine::ContentTypeToSt
ring(contentType)); | |
674 if (result) | |
675 { | |
676 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); | |
677 } | |
678 else | |
679 { | |
680 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain); | |
681 } | |
682 } | |
683 #endif | |
684 return result; | |
685 } | |
OLD | NEW |