Left: | ||
Right: |
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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 std::pair<CString, CFilterElementHide> pair = std::make_pair(filter->m _tag, *filter); | 497 std::pair<CString, CFilterElementHide> pair = std::make_pair(filter->m _tag, *filter); |
498 m_elementHideTags.insert(pair); | 498 m_elementHideTags.insert(pair); |
499 } | 499 } |
500 } | 500 } |
501 } while (separatorChar != '\0'); | 501 } while (separatorChar != '\0'); |
502 } | 502 } |
503 | 503 |
504 return true; | 504 return true; |
505 } | 505 } |
506 | 506 |
507 bool CPluginFilter::IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& domain, const CString& indent) const | 507 bool CPluginFilter::IsElementHidden(const std::wstring& tag_wstring, IHTMLElemen t* pEl, const std::wstring& domain, const std::wstring& indent) const |
Felix Dahlke
2014/09/30 13:30:15
Since "CString tag" is temporary and "const std::w
Eric
2014/09/30 17:56:40
I was trying to minimize the number of changed lin
| |
508 { | 508 { |
509 CString tag = to_CString(tag_wstring); | |
510 | |
509 CString id; | 511 CString id; |
510 CComBSTR bstrId; | 512 CComBSTR bstrId; |
511 if (SUCCEEDED(pEl->get_id(&bstrId)) && bstrId) | 513 if (SUCCEEDED(pEl->get_id(&bstrId)) && bstrId) |
512 { | 514 { |
513 id = bstrId; | 515 id = bstrId; |
514 } | 516 } |
515 | 517 |
516 CString classNames; | 518 CString classNames; |
517 CComBSTR bstrClassNames; | 519 CComBSTR bstrClassNames; |
518 if (SUCCEEDED(pEl->get_className(&bstrClassNames)) && bstrClassNames) | 520 if (SUCCEEDED(pEl->get_className(&bstrClassNames)) && bstrClassNames) |
519 { | 521 { |
520 classNames = bstrClassNames; | 522 classNames = bstrClassNames; |
521 } | 523 } |
522 | 524 |
523 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 525 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |
524 { | 526 { |
525 CString domainTest = domain; | 527 CString domainTest = to_CString(domain); |
526 | 528 |
527 // Search tag/id filters | 529 // Search tag/id filters |
528 if (!id.IsEmpty()) | 530 if (!id.IsEmpty()) |
529 { | 531 { |
530 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT agsNamed::const_iterator> idItEnum = | 532 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT agsNamed::const_iterator> idItEnum = |
531 m_elementHideTagsId.equal_range(std::make_pair(tag, id)); | 533 m_elementHideTagsId.equal_range(std::make_pair(tag, id)); |
532 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++) | 534 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++) |
533 { | 535 { |
534 if (idIt->second.IsMatchFilterElementHide(pEl)) | 536 if (idIt->second.IsMatchFilterElementHide(pEl)) |
535 { | 537 { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 } | 674 } |
673 m_filterMapDefault[i].clear(); | 675 m_filterMapDefault[i].clear(); |
674 } | 676 } |
675 | 677 |
676 m_elementHideTags.clear(); | 678 m_elementHideTags.clear(); |
677 m_elementHideTagsId.clear(); | 679 m_elementHideTagsId.clear(); |
678 m_elementHideTagsClass.clear(); | 680 m_elementHideTagsClass.clear(); |
679 } | 681 } |
680 } | 682 } |
681 | 683 |
682 bool CPluginFilter::ShouldBlock(CString src, int contentType, const CString& dom ain, bool addDebug) const | 684 bool CPluginFilter::ShouldBlock(const std::wstring& src_wstring, int contentType , const std::wstring& domain_wstring, bool addDebug) const |
683 { | 685 { |
686 CString src = to_CString(src_wstring); | |
687 CString domain = to_CString(domain_wstring); | |
688 | |
684 // We should not block the empty string, so all filtering does not make sense | 689 // We should not block the empty string, so all filtering does not make sense |
685 // Therefore we just return | 690 // Therefore we just return |
686 if (src.Trim().IsEmpty()) | 691 if (src.Trim().IsEmpty()) |
687 { | 692 { |
688 return false; | 693 return false; |
689 } | 694 } |
690 | 695 |
691 CPluginSettings* settings = CPluginSettings::GetInstance(); | 696 CPluginSettings* settings = CPluginSettings::GetInstance(); |
692 | 697 |
693 CString type; | 698 CString type; |
(...skipping 16 matching lines...) Expand all Loading... | |
710 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") | 715 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") |
711 | 716 |
712 #ifdef ENABLE_DEBUG_RESULT | 717 #ifdef ENABLE_DEBUG_RESULT |
713 CPluginDebug::DebugResultBlocking(type, src, domain); | 718 CPluginDebug::DebugResultBlocking(type, src, domain); |
714 #endif | 719 #endif |
715 } | 720 } |
716 return true; | 721 return true; |
717 } | 722 } |
718 return false; | 723 return false; |
719 } | 724 } |
OLD | NEW |