| 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-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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 416 | 416 | 
| 417   return true; | 417   return true; | 
| 418 } | 418 } | 
| 419 | 419 | 
| 420 | 420 | 
| 421 | 421 | 
| 422 // ============================================================================ | 422 // ============================================================================ | 
| 423 // CPluginFilter | 423 // CPluginFilter | 
| 424 // ============================================================================ | 424 // ============================================================================ | 
| 425 | 425 | 
| 426 CPluginFilter::CPluginFilter(const CString& dataPath) : m_dataPath(dataPath) |  | 
| 427 { |  | 
| 428   ClearFilters(); |  | 
| 429 } |  | 
| 430 |  | 
| 431 |  | 
| 432 bool CPluginFilter::AddFilterElementHide(CString filterText) | 426 bool CPluginFilter::AddFilterElementHide(CString filterText) | 
| 433 { | 427 { | 
| 434   DEBUG_FILTER("Input: " + filterText + " filterFile" + filterFile); | 428   DEBUG_FILTER("Input: " + filterText + " filterFile" + filterFile); | 
| 435   CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 429   CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 
| 436   { | 430   { | 
| 437     CString filterString  = filterText; | 431     CString filterString  = filterText; | 
| 438     // Create filter descriptor | 432     // Create filter descriptor | 
| 439     std::auto_ptr<CFilterElementHide> filter; | 433     std::auto_ptr<CFilterElementHide> filter; | 
| 440 | 434 | 
| 441     CString wholeFilterString = filterString; | 435     CString wholeFilterString = filterString; | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 598           CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f
     ilterText)); | 592           CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f
     ilterText)); | 
| 599 #endif | 593 #endif | 
| 600         return true; | 594         return true; | 
| 601       } | 595       } | 
| 602     } | 596     } | 
| 603   } | 597   } | 
| 604 | 598 | 
| 605   return false; | 599   return false; | 
| 606 } | 600 } | 
| 607 | 601 | 
| 608 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) | 602 CPluginFilter::CPluginFilter(const std::vector<std::wstring>& filters) | 
| 609 { | 603 { | 
| 610   ClearFilters(); | 604   m_hideFilters = filters; | 
| 611   bool isRead = false; |  | 
| 612   CPluginClient* client = CPluginClient::GetInstance(); | 605   CPluginClient* client = CPluginClient::GetInstance(); | 
| 613 | 606 | 
| 614   // Parse hide string | 607   // Parse hide string | 
| 615   int pos = 0; | 608   int pos = 0; | 
| 616   CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 609   CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 
| 617   { | 610   { | 
| 618     for (std::vector<std::wstring>::iterator it = filters.begin(); it < filters.
     end(); ++it) | 611     for (auto it = filters.begin(); it < filters.end(); ++it) | 
| 619     { | 612     { | 
| 620       CString filter((*it).c_str()); | 613       CString filter((*it).c_str()); | 
| 621       // If the line is not commented out | 614       // If the line is not commented out | 
| 622       if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) 
     != '[') | 615       if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0) 
     != '[') | 
| 623       { | 616       { | 
| 624         int filterType = 0; | 617         int filterType = 0; | 
| 625 | 618 | 
| 626         // See http://adblockplus.org/en/filters for further documentation | 619         // See http://adblockplus.org/en/filters for further documentation | 
| 627 | 620 | 
| 628         try | 621         try | 
| 629         { | 622         { | 
| 630           AddFilterElementHide(filter); | 623           AddFilterElementHide(filter); | 
| 631         } | 624         } | 
| 632         catch(...) | 625         catch(...) | 
| 633         { | 626         { | 
| 634 #ifdef ENABLE_DEBUG_RESULT | 627 #ifdef ENABLE_DEBUG_RESULT | 
| 635           CPluginDebug::DebugResult(L"Error loading hide filter: " + ToWstring(f
     ilter)); | 628           CPluginDebug::DebugResult(L"Error loading hide filter: " + ToWstring(f
     ilter)); | 
| 636 #endif | 629 #endif | 
| 637         } | 630         } | 
| 638       } | 631       } | 
| 639     } | 632     } | 
| 640   } | 633   } | 
| 641 | 634 } | 
| 642   return isRead; |  | 
| 643 } |  | 
| 644 |  | 
| 645 void CPluginFilter::ClearFilters() |  | 
| 646 { |  | 
| 647   // Clear filter maps |  | 
| 648   CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |  | 
| 649   m_elementHideTags.clear(); |  | 
| 650   m_elementHideTagsId.clear(); |  | 
| 651   m_elementHideTagsClass.clear(); |  | 
| 652 } |  | 
| 653 |  | 
| OLD | NEW | 
|---|