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: rebase and address comments Created April 13, 2015, 8:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginFilter.h ('k') | src/plugin/PluginTabBase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
644 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f ilterText)); 644 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f ilterText));
645 #endif 645 #endif
646 return true; 646 return true;
647 } 647 }
648 } 648 }
649 } 649 }
650 650
651 return false; 651 return false;
652 } 652 }
653 653
654 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) 654 bool CPluginFilter::LoadHideFilters(const std::vector<std::wstring>& filters)
655 { 655 {
656 ClearFilters(); 656 ClearFilters();
657 m_hideFilters = filters;
657 bool isRead = false; 658 bool isRead = false;
658 CPluginClient* client = CPluginClient::GetInstance(); 659 CPluginClient* client = CPluginClient::GetInstance();
659 660
660 // Parse hide string 661 // Parse hide string
661 int pos = 0; 662 int pos = 0;
662 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 663 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
663 { 664 {
664 for (std::vector<std::wstring>::iterator it = filters.begin(); it < filters. end(); ++it) 665 for (auto it = filters.begin(); it < filters.end(); ++it)
665 { 666 {
666 CString filter((*it).c_str()); 667 CString filter((*it).c_str());
667 // If the line is not commented out 668 // If the line is not commented out
668 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) != '[') 669 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) != '[')
669 { 670 {
670 int filterType = 0; 671 int filterType = 0;
671 672
672 // See http://adblockplus.org/en/filters for further documentation 673 // See http://adblockplus.org/en/filters for further documentation
673 674
674 try 675 try
(...skipping 13 matching lines...) Expand all
688 return isRead; 689 return isRead;
689 } 690 }
690 691
691 void CPluginFilter::ClearFilters() 692 void CPluginFilter::ClearFilters()
692 { 693 {
693 // Clear filter maps 694 // Clear filter maps
694 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 695 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
695 m_elementHideTags.clear(); 696 m_elementHideTags.clear();
696 m_elementHideTagsId.clear(); 697 m_elementHideTagsId.clear();
697 m_elementHideTagsClass.clear(); 698 m_elementHideTagsClass.clear();
699 m_hideFilters.clear();
698 } 700 }
699 701
700 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi ne::ContentType contentType, const std::wstring& domain, bool addDebug) const 702 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi ne::ContentType contentType, const std::wstring& domain, bool addDebug) const
701 { 703 {
702 std::wstring srcTrimmed = TrimString(src); 704 std::wstring srcTrimmed = TrimString(src);
703 705
704 // We should not block the empty string, so all filtering does not make sense 706 // We should not block the empty string, so all filtering does not make sense
705 // Therefore we just return 707 // Therefore we just return
706 if (srcTrimmed.empty()) 708 if (srcTrimmed.empty())
707 { 709 {
(...skipping 14 matching lines...) Expand all
722 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); 724 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain);
723 } 725 }
724 else 726 else
725 { 727 {
726 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain); 728 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain);
727 } 729 }
728 } 730 }
729 #endif 731 #endif
730 return result; 732 return result;
731 } 733 }
734
735 const std::vector<std::wstring>& CPluginFilter::GetHideFilters() const
736 {
737 DWORD res = WaitForSingleObject(hideFiltersLoadedEvent, ENGINE_STARTUP_TIMEOUT );
738 return m_hideFilters;
739 }
OLDNEW
« no previous file with comments | « src/plugin/PluginFilter.h ('k') | src/plugin/PluginTabBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld