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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f
ilterText)); | 598 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f
ilterText)); |
599 #endif | 599 #endif |
600 return true; | 600 return true; |
601 } | 601 } |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) | 608 bool CPluginFilter::LoadHideFilters(const std::vector<std::wstring>& filters) |
609 { | 609 { |
610 ClearFilters(); | 610 ClearFilters(); |
| 611 m_hideFilters = filters; |
611 bool isRead = false; | 612 bool isRead = false; |
612 CPluginClient* client = CPluginClient::GetInstance(); | 613 CPluginClient* client = CPluginClient::GetInstance(); |
613 | 614 |
614 // Parse hide string | 615 // Parse hide string |
615 int pos = 0; | 616 int pos = 0; |
616 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 617 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |
617 { | 618 { |
618 for (std::vector<std::wstring>::iterator it = filters.begin(); it < filters.
end(); ++it) | 619 for (auto it = filters.begin(); it < filters.end(); ++it) |
619 { | 620 { |
620 CString filter((*it).c_str()); | 621 CString filter((*it).c_str()); |
621 // If the line is not commented out | 622 // If the line is not commented out |
622 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0)
!= '[') | 623 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0)
!= '[') |
623 { | 624 { |
624 int filterType = 0; | 625 int filterType = 0; |
625 | 626 |
626 // See http://adblockplus.org/en/filters for further documentation | 627 // See http://adblockplus.org/en/filters for further documentation |
627 | 628 |
628 try | 629 try |
(...skipping 13 matching lines...) Expand all Loading... |
642 return isRead; | 643 return isRead; |
643 } | 644 } |
644 | 645 |
645 void CPluginFilter::ClearFilters() | 646 void CPluginFilter::ClearFilters() |
646 { | 647 { |
647 // Clear filter maps | 648 // Clear filter maps |
648 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 649 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |
649 m_elementHideTags.clear(); | 650 m_elementHideTags.clear(); |
650 m_elementHideTagsId.clear(); | 651 m_elementHideTagsId.clear(); |
651 m_elementHideTagsClass.clear(); | 652 m_elementHideTagsClass.clear(); |
| 653 m_hideFilters.clear(); |
652 } | 654 } |
653 | 655 |
654 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi
ne::ContentType contentType, const std::wstring& domain, bool addDebug) const | 656 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi
ne::ContentType contentType, const std::wstring& domain, bool addDebug) const |
655 { | 657 { |
656 std::wstring srcTrimmed = TrimString(src); | 658 std::wstring srcTrimmed = TrimString(src); |
657 | 659 |
658 // We should not block the empty string, so all filtering does not make sense | 660 // We should not block the empty string, so all filtering does not make sense |
659 // Therefore we just return | 661 // Therefore we just return |
660 if (srcTrimmed.empty()) | 662 if (srcTrimmed.empty()) |
661 { | 663 { |
(...skipping 14 matching lines...) Expand all Loading... |
676 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); | 678 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); |
677 } | 679 } |
678 else | 680 else |
679 { | 681 { |
680 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain); | 682 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain); |
681 } | 683 } |
682 } | 684 } |
683 #endif | 685 #endif |
684 return result; | 686 return result; |
685 } | 687 } |
| 688 |
| 689 const std::vector<std::wstring>& CPluginFilter::GetHideFilters() const |
| 690 { |
| 691 DWORD res = WaitForSingleObject(hideFiltersLoadedEvent, ENGINE_STARTUP_TIMEOUT
); |
| 692 return m_hideFilters; |
| 693 } |
OLD | NEW |