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

Delta Between Two Patch Sets: src/plugin/PluginFilter.cpp

Issue 6505394822184960: Issue 1109 - Support notifications (Closed)
Left Patch Set: Created May 11, 2015, 10:01 a.m.
Right Patch Set: fix obtaining of DPI value of content (NotificationWindow) of NotificationBorderWindow Created Aug. 18, 2015, 9:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "PluginStdAfx.h" 18 #include "PluginStdAfx.h"
19 19 #include "AdblockPlusClient.h"
20 #include "PluginFilter.h" 20 #include "PluginFilter.h"
21 #include "PluginSettings.h" 21 #include "PluginSettings.h"
22 #include "PluginClient.h"
23 #include "PluginClientFactory.h"
24 #include "PluginMutex.h" 22 #include "PluginMutex.h"
25 #include "PluginSettings.h" 23 #include "PluginSettings.h"
26 #include "PluginSystem.h" 24 #include "PluginSystem.h"
27 #include "PluginClass.h" 25 #include "PluginClass.h"
28 #include "mlang.h" 26 #include "mlang.h"
29
30 #include "..\shared\CriticalSection.h" 27 #include "..\shared\CriticalSection.h"
31 #include "..\shared\Utils.h" 28 #include "..\shared\Utils.h"
32 #include "..\shared\MsHTMLUtils.h" 29 #include "..\shared\MsHTMLUtils.h"
33 30
34 // The filters are described at http://adblockplus.org/en/filters 31 // The filters are described at http://adblockplus.org/en/filters
35 32
36 static CriticalSection s_criticalSectionFilterMap; 33 static CriticalSection s_criticalSectionFilterMap;
37 34
38 // ============================================================================ 35 // ============================================================================
39 // CFilterElementHideAttrSelector 36 // CFilterElementHideAttrSelector
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f ilterText)); 598 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f ilterText));
602 #endif 599 #endif
603 return true; 600 return true;
604 } 601 }
605 } 602 }
606 } 603 }
607 604
608 return false; 605 return false;
609 } 606 }
610 607
611 bool CPluginFilter::LoadHideFilters(const std::vector<std::wstring>& filters) 608 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters)
612 { 609 {
613 ClearFilters(); 610 ClearFilters();
614 m_hideFilters = filters;
615 bool isRead = false; 611 bool isRead = false;
616 CPluginClient* client = CPluginClient::GetInstance(); 612 CPluginClient* client = CPluginClient::GetInstance();
617 613
618 // Parse hide string 614 // Parse hide string
619 int pos = 0; 615 int pos = 0;
620 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 616 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
621 { 617 {
622 for (auto it = filters.begin(); it < filters.end(); ++it) 618 for (std::vector<std::wstring>::iterator it = filters.begin(); it < filters. end(); ++it)
623 { 619 {
624 CString filter((*it).c_str()); 620 CString filter((*it).c_str());
625 // If the line is not commented out 621 // If the line is not commented out
626 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) != '[') 622 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) != '[')
627 { 623 {
628 int filterType = 0; 624 int filterType = 0;
629 625
630 // See http://adblockplus.org/en/filters for further documentation 626 // See http://adblockplus.org/en/filters for further documentation
631 627
632 try 628 try
(...skipping 13 matching lines...) Expand all
646 return isRead; 642 return isRead;
647 } 643 }
648 644
649 void CPluginFilter::ClearFilters() 645 void CPluginFilter::ClearFilters()
650 { 646 {
651 // Clear filter maps 647 // Clear filter maps
652 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 648 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
653 m_elementHideTags.clear(); 649 m_elementHideTags.clear();
654 m_elementHideTagsId.clear(); 650 m_elementHideTagsId.clear();
655 m_elementHideTagsClass.clear(); 651 m_elementHideTagsClass.clear();
656 m_hideFilters.clear();
657 } 652 }
658 653
659 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi ne::ContentType contentType, const std::wstring& domain, bool addDebug) const 654 bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngi ne::ContentType contentType, const std::wstring& domain, bool addDebug) const
660 { 655 {
661 std::wstring srcTrimmed = TrimString(src); 656 std::wstring srcTrimmed = TrimString(src);
662 657
663 // We should not block the empty string, so all filtering does not make sense 658 // We should not block the empty string, so all filtering does not make sense
664 // Therefore we just return 659 // Therefore we just return
665 if (srcTrimmed.empty()) 660 if (srcTrimmed.empty())
666 { 661 {
(...skipping 14 matching lines...) Expand all
681 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); 676 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain);
682 } 677 }
683 else 678 else
684 { 679 {
685 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain); 680 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain);
686 } 681 }
687 } 682 }
688 #endif 683 #endif
689 return result; 684 return result;
690 } 685 }
691
692 const std::vector<std::wstring>& CPluginFilter::GetHideFilters() const
693 {
694 DWORD res = WaitForSingleObject(hideFiltersLoadedEvent, ENGINE_STARTUP_TIMEOUT );
695 return m_hideFilters;
696 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld