| OLD | NEW |
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include "PluginFilter.h" | 3 #include "PluginFilter.h" |
| 4 | 4 |
| 5 #if (defined PRODUCT_ADBLOCKPLUS) | 5 #if (defined PRODUCT_ADBLOCKPLUS) |
| 6 #include "PluginSettings.h" | 6 #include "PluginSettings.h" |
| 7 #include "PluginClient.h" | 7 #include "PluginClient.h" |
| 8 #include "PluginClientFactory.h" | 8 #include "PluginClientFactory.h" |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 517 |
| 518 CString classNames; | 518 CString classNames; |
| 519 CComBSTR bstrClassNames; | 519 CComBSTR bstrClassNames; |
| 520 if (SUCCEEDED(pEl->get_className(&bstrClassNames)) && bstrClassNames) | 520 if (SUCCEEDED(pEl->get_className(&bstrClassNames)) && bstrClassNames) |
| 521 { | 521 { |
| 522 classNames = bstrClassNames; | 522 classNames = bstrClassNames; |
| 523 } | 523 } |
| 524 | 524 |
| 525 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 525 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |
| 526 { | 526 { |
| 527 CString domainTest = to_CString(domain); | |
| 528 | |
| 529 // Search tag/id filters | 527 // Search tag/id filters |
| 530 if (!id.IsEmpty()) | 528 if (!id.IsEmpty()) |
| 531 { | 529 { |
| 532 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT
agsNamed::const_iterator> idItEnum = | 530 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT
agsNamed::const_iterator> idItEnum = |
| 533 m_elementHideTagsId.equal_range(std::make_pair(tag, id)); | 531 m_elementHideTagsId.equal_range(std::make_pair(tag, id)); |
| 534 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id
It != idItEnum.second; idIt ++) | 532 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id
It != idItEnum.second; idIt ++) |
| 535 { | 533 { |
| 536 if (idIt->second.IsMatchFilterElementHide(pEl)) | 534 if (idIt->second.IsMatchFilterElementHide(pEl)) |
| 537 { | 535 { |
| 538 #ifdef ENABLE_DEBUG_RESULT | 536 #ifdef ENABLE_DEBUG_RESULT |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 } | 672 } |
| 675 m_filterMapDefault[i].clear(); | 673 m_filterMapDefault[i].clear(); |
| 676 } | 674 } |
| 677 | 675 |
| 678 m_elementHideTags.clear(); | 676 m_elementHideTags.clear(); |
| 679 m_elementHideTagsId.clear(); | 677 m_elementHideTagsId.clear(); |
| 680 m_elementHideTagsClass.clear(); | 678 m_elementHideTagsClass.clear(); |
| 681 } | 679 } |
| 682 } | 680 } |
| 683 | 681 |
| 684 bool CPluginFilter::ShouldBlock(const std::wstring& src_wstring, int contentType
, const std::wstring& domain_wstring, bool addDebug) const | 682 bool CPluginFilter::ShouldBlock(const std::wstring& src_wstring, int contentType
, const std::wstring& domain, bool addDebug) const |
| 685 { | 683 { |
| 686 CString src = to_CString(src_wstring); | 684 CString src = to_CString(src_wstring); |
| 687 CString domain = to_CString(domain_wstring); | |
| 688 | 685 |
| 689 // We should not block the empty string, so all filtering does not make sense | 686 // We should not block the empty string, so all filtering does not make sense |
| 690 // Therefore we just return | 687 // Therefore we just return |
| 691 if (src.Trim().IsEmpty()) | 688 if (src.Trim().IsEmpty()) |
| 692 { | 689 { |
| 693 return false; | 690 return false; |
| 694 } | 691 } |
| 695 | 692 |
| 696 CPluginSettings* settings = CPluginSettings::GetInstance(); | 693 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 697 | 694 |
| 698 CString type; | 695 CString type; |
| 699 if (addDebug) | 696 if (addDebug) |
| 700 { | 697 { |
| 701 type = "OTHER"; | 698 type = "OTHER"; |
| 702 | 699 |
| 703 std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType
); | 700 std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType
); |
| 704 if (it != m_contentMapText.end()) | 701 if (it != m_contentMapText.end()) |
| 705 { | 702 { |
| 706 type = it->second; | 703 type = it->second; |
| 707 } | 704 } |
| 708 } | 705 } |
| 709 | 706 |
| 710 CPluginClient* client = CPluginClient::GetInstance(); | 707 CPluginClient* client = CPluginClient::GetInstance(); |
| 711 if (client->Matches(std::wstring(src), std::wstring(type), std::wstring(domain
))) | 708 if (client->Matches(std::wstring(src), std::wstring(type), domain)) |
| 712 { | 709 { |
| 713 if (addDebug) | 710 if (addDebug) |
| 714 { | 711 { |
| 715 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") | 712 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") |
| 716 | 713 |
| 717 #ifdef ENABLE_DEBUG_RESULT | 714 #ifdef ENABLE_DEBUG_RESULT |
| 718 CPluginDebug::DebugResultBlocking(type, src, domain); | 715 CPluginDebug::DebugResultBlocking(type, src, domain); |
| 719 #endif | 716 #endif |
| 720 } | 717 } |
| 721 return true; | 718 return true; |
| 722 } | 719 } |
| 723 return false; | 720 return false; |
| 724 } | 721 } |
| OLD | NEW |