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

Side by Side Diff: src/plugin/PluginFilter.cpp

Issue 6567422169448448: Issue 119 - Switch to injecting CSS for element hiding (Closed)
Patch Set: Created Dec. 10, 2014, 5:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginFilter.h" 3 #include "PluginFilter.h"
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginClient.h" 5 #include "PluginClient.h"
6 #include "PluginClientFactory.h" 6 #include "PluginClientFactory.h"
7 #include "PluginMutex.h" 7 #include "PluginMutex.h"
8 #include "PluginSettings.h" 8 #include "PluginSettings.h"
9 #include "PluginSystem.h" 9 #include "PluginSystem.h"
10 #include "PluginClass.h" 10 #include "PluginClass.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 CPluginDebug::DebugResultHiding(tagCString, "-", tagIt->second.m_filte rText); 639 CPluginDebug::DebugResultHiding(tagCString, "-", tagIt->second.m_filte rText);
640 #endif 640 #endif
641 return true; 641 return true;
642 } 642 }
643 } 643 }
644 } 644 }
645 645
646 return false; 646 return false;
647 } 647 }
648 648
649 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) 649 bool CPluginFilter::LoadHideFilters(const std::vector<std::wstring>& filters)
650 { 650 {
651 ClearFilters(); 651 ClearFilters();
652 m_hideFilters = filters;
652 bool isRead = false; 653 bool isRead = false;
653 CPluginClient* client = CPluginClient::GetInstance(); 654 CPluginClient* client = CPluginClient::GetInstance();
654 655
655 // Parse hide string 656 // Parse hide string
656 int pos = 0; 657 int pos = 0;
657 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 658 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
658 { 659 {
659 for (std::vector<std::wstring>::iterator it = filters.begin(); it < filters. end(); ++it) 660 for (std::vector<std::wstring>::const_iterator it = filters.begin(); it < fi lters.end(); ++it)
660 { 661 {
661 CString filter((*it).c_str()); 662 CString filter((*it).c_str());
662 // If the line is not commented out 663 // If the line is not commented out
663 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) != '[') 664 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) != '[')
664 { 665 {
665 int filterType = 0; 666 int filterType = 0;
666 667
667 // See http://adblockplus.org/en/filters for further documentation 668 // See http://adblockplus.org/en/filters for further documentation
668 669
669 try 670 try
(...skipping 23 matching lines...) Expand all
693 for (int j = 0; j < 2; j++) 694 for (int j = 0; j < 2; j++)
694 { 695 {
695 m_filterMap[i][j].clear(); 696 m_filterMap[i][j].clear();
696 } 697 }
697 m_filterMapDefault[i].clear(); 698 m_filterMapDefault[i].clear();
698 } 699 }
699 700
700 m_elementHideTags.clear(); 701 m_elementHideTags.clear();
701 m_elementHideTagsId.clear(); 702 m_elementHideTagsId.clear();
702 m_elementHideTagsClass.clear(); 703 m_elementHideTagsClass.clear();
704 m_hideFilters.clear();
703 } 705 }
704 } 706 }
705 707
706 bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug) const 708 bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug) const
707 { 709 {
708 CString srcCString = to_CString(src); 710 CString srcCString = to_CString(src);
709 711
710 // We should not block the empty string, so all filtering does not make sense 712 // We should not block the empty string, so all filtering does not make sense
711 // Therefore we just return 713 // Therefore we just return
712 if (srcCString.Trim().IsEmpty()) 714 if (srcCString.Trim().IsEmpty())
(...skipping 26 matching lines...) Expand all
739 CPluginDebug::DebugResultBlocking(type, srcCString, domain); 741 CPluginDebug::DebugResultBlocking(type, srcCString, domain);
740 #endif 742 #endif
741 } 743 }
742 return true; 744 return true;
743 } 745 }
744 #ifdef ENABLE_DEBUG_RESULT 746 #ifdef ENABLE_DEBUG_RESULT
745 CPluginDebug::DebugResultIgnoring(type, srcCString, domain); 747 CPluginDebug::DebugResultIgnoring(type, srcCString, domain);
746 #endif 748 #endif
747 return false; 749 return false;
748 } 750 }
751
752 const std::vector<std::wstring>& CPluginFilter::getHideFilters() const
753 {
754 DWORD res = WaitForSingleObject(hideFiltersLoadedEvent, ENGINE_STARTUP_TIMEOUT );
Oleksandr 2015/02/04 20:59:57 It's hard to understand this from the scattered re
sergei 2015/04/13 08:06:58 `hideFiltersLoadedEvent` is not introduced in thes
755 return m_hideFilters;
756 }
OLDNEW

Powered by Google App Engine
This is Rietveld