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

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

Issue 29334397: Issue #2230, #3391 - Load filters on "download begin" event
Patch Set: address comments Created Feb. 3, 2016, 6:04 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
« 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return m_predecessor->IsMatchFilterElementHide(pDomPredecessor); 438 return m_predecessor->IsMatchFilterElementHide(pDomPredecessor);
439 } 439 }
440 440
441 return true; 441 return true;
442 } 442 }
443 443
444 // ============================================================================ 444 // ============================================================================
445 // CPluginFilter 445 // CPluginFilter
446 // ============================================================================ 446 // ============================================================================
447 447
448 CPluginFilter::CPluginFilter()
449 {
450 ClearFilters();
451 }
452
453 bool CPluginFilter::AddFilterElementHide(std::wstring filterText) 448 bool CPluginFilter::AddFilterElementHide(std::wstring filterText)
454 { 449 {
455 DEBUG_FILTER(L"Input: " + filterText + L" filterFile" + filterFile); 450 DEBUG_FILTER(L"Input: " + filterText + L" filterFile" + filterFile);
456 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 451 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
457 { 452 {
458 // Create filter descriptor 453 // Create filter descriptor
459 std::auto_ptr<CFilterElementHide> filter; 454 std::auto_ptr<CFilterElementHide> filter;
460 wchar_t separatorChar; 455 wchar_t separatorChar;
461 do 456 do
462 { 457 {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 CPluginDebug::DebugResultHiding(tag, L"-", tagIt->second.m_filterText); 597 CPluginDebug::DebugResultHiding(tag, L"-", tagIt->second.m_filterText);
603 #endif 598 #endif
604 return true; 599 return true;
605 } 600 }
606 } 601 }
607 } 602 }
608 603
609 return false; 604 return false;
610 } 605 }
611 606
612 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) 607 bool CPluginFilter::LoadHideFilters()
613 { 608 {
614 ClearFilters(); 609 auto filters = CPluginClient::GetInstance()->GetElementHidingSelectors(domain) ;
615 bool isRead = false; 610 bool isRead = false;
616 CPluginClient* client = CPluginClient::GetInstance(); 611 CPluginClient* client = CPluginClient::GetInstance();
617 612
618 // Parse hide string 613 // Parse hide string
619 int pos = 0; 614 int pos = 0;
620 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); 615 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
621 { 616 {
622 for (auto it = filters.begin(); it < filters.end(); ++it) 617 for (auto it = filters.begin(); it < filters.end(); ++it)
623 { 618 {
624 std::wstring filter(TrimString(*it)); 619 std::wstring filter(TrimString(*it));
(...skipping 13 matching lines...) Expand all
638 #ifdef ENABLE_DEBUG_RESULT 633 #ifdef ENABLE_DEBUG_RESULT
639 CPluginDebug::DebugResult(L"Error loading hide filter: " + filter); 634 CPluginDebug::DebugResult(L"Error loading hide filter: " + filter);
640 #endif 635 #endif
641 } 636 }
642 } 637 }
643 } 638 }
644 } 639 }
645 640
646 return isRead; 641 return isRead;
647 } 642 }
648
649 void CPluginFilter::ClearFilters()
650 {
651 // Clear filter maps
652 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap);
653 m_elementHideTags.clear();
654 m_elementHideTagsId.clear();
655 m_elementHideTagsClass.clear();
656 }
657
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