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

Side by Side Diff: src/plugin/PluginDomTraverserBase.h

Issue 29331669: Issue 3237 - Whitelisted AFS ad is not shown on netzwelt.de (Closed)
Patch Set: Move subdocument detection to the top. Created Dec. 15, 2015, 2:05 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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-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
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 virtual bool IsEnabled(); 55 virtual bool IsEnabled();
56 56
57 protected: 57 protected:
58 58
59 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, const std::wstri ng& indent); 59 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, const std::wstri ng& indent);
60 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, const std::wstri ng& indent, bool isCached=true); 60 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, const std::wstri ng& indent, bool isCached=true);
61 61
62 CComAutoCriticalSection m_criticalSection; 62 CComAutoCriticalSection m_criticalSection;
63 63
64 std::wstring m_domain; 64 std::wstring m_domain;
65 std::wstring m_documentName; 65 std::wstring m_documentUrl;
66 66
67 bool m_isHeaderTraversed; 67 bool m_isHeaderTraversed;
68 68
69 // Caching 69 // Caching
70 long m_cacheDomElementCount; 70 long m_cacheDomElementCount;
71 71
72 int m_cacheIndexLast; 72 int m_cacheIndexLast;
73 int m_cacheElementsMax; 73 int m_cacheElementsMax;
74 std::set<std::wstring> m_cacheDocumentHasFrames; 74 std::set<std::wstring> m_cacheDocumentHasFrames;
75 std::set<std::wstring> m_cacheDocumentHasIframes; 75 std::set<std::wstring> m_cacheDocumentHasIframes;
(...skipping 21 matching lines...) Expand all
97 template <class T> 97 template <class T>
98 void CPluginDomTraverserBase<T>::TraverseHeader(bool isHeaderTraversed) 98 void CPluginDomTraverserBase<T>::TraverseHeader(bool isHeaderTraversed)
99 { 99 {
100 m_isHeaderTraversed = isHeaderTraversed; 100 m_isHeaderTraversed = isHeaderTraversed;
101 } 101 }
102 102
103 template <class T> 103 template <class T>
104 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& documentUrl) 104 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& documentUrl)
105 { 105 {
106 m_domain = domain; 106 m_domain = domain;
107 107 m_documentUrl = documentUrl;
108 TraverseDocument(pBrowser, true, L""); 108 TraverseDocument(pBrowser, true, L"");
109 } 109 }
110 110
111 111
112 template <class T> 112 template <class T>
113 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con st std::wstring& domain, const std::wstring& documentUrl) 113 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con st std::wstring& domain, const std::wstring& documentUrl)
114 { 114 {
115 m_domain = domain; 115 m_domain = domain;
116 116 m_documentUrl = documentUrl;
117 TraverseDocument(pBrowser, false, L""); 117 TraverseDocument(pBrowser, false, L"");
118 } 118 }
119 119
120 120
121 template <class T> 121 template <class T>
122 bool CPluginDomTraverserBase<T>::IsEnabled() 122 bool CPluginDomTraverserBase<T>::IsEnabled()
123 { 123 {
124 return CPluginSettings::GetInstance()->IsPluginEnabled(); 124 return CPluginSettings::GetInstance()->IsPluginEnabled();
125 } 125 }
126 126
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // Hide elements in body part 201 // Hide elements in body part
202 TraverseChild(pBodyEl, pBrowser, indent); 202 TraverseChild(pBodyEl, pBrowser, indent);
203 203
204 // Check frames and iframes 204 // Check frames and iframes
205 bool hasFrames = false; 205 bool hasFrames = false;
206 bool hasIframes = false; 206 bool hasIframes = false;
207 207
208 m_criticalSection.Lock(); 208 m_criticalSection.Lock();
209 { 209 {
210 hasFrames = m_cacheDocumentHasFrames.find(m_documentName) != m_cacheDocument HasFrames.end(); 210 hasFrames = m_cacheDocumentHasFrames.find(m_documentUrl) != m_cacheDocumentH asFrames.end();
211 hasIframes = m_cacheDocumentHasIframes.find(m_documentName) != m_cacheDocume ntHasIframes.end(); 211 hasIframes = m_cacheDocumentHasIframes.find(m_documentUrl) != m_cacheDocumen tHasIframes.end();
212 } 212 }
213 m_criticalSection.Unlock(); 213 m_criticalSection.Unlock();
214 214
215 // Frames 215 // Frames
216 if (hasFrames) 216 if (hasFrames)
217 { 217 {
218 // eg. http://gamecopyworld.com/ 218 // eg. http://gamecopyworld.com/
219 long frameCount = 0; 219 long frameCount = 0;
220 CComPtr<IHTMLElementCollection> pFrameCollection; 220 CComPtr<IHTMLElementCollection> pFrameCollection;
221 if (SUCCEEDED(pDoc->getElementsByTagName(ATL::CComBSTR(L"frame"), &pFrameCol lection)) && pFrameCollection) 221 if (SUCCEEDED(pDoc->getElementsByTagName(ATL::CComBSTR(L"frame"), &pFrameCol lection)) && pFrameCollection)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (!OnElement(pEl, tag, &m_cacheElements[cacheIndex], false, indent)) 389 if (!OnElement(pEl, tag, &m_cacheElements[cacheIndex], false, indent))
390 { 390 {
391 return; 391 return;
392 } 392 }
393 393
394 // Update frame/iframe cache 394 // Update frame/iframe cache
395 if (tag == L"iframe") 395 if (tag == L"iframe")
396 { 396 {
397 m_criticalSection.Lock(); 397 m_criticalSection.Lock();
398 { 398 {
399 m_cacheDocumentHasIframes.insert(m_documentName); 399 m_cacheDocumentHasIframes.insert(m_documentUrl);
400 } 400 }
401 m_criticalSection.Unlock(); 401 m_criticalSection.Unlock();
402 } 402 }
403 else if (tag == L"frame") 403 else if (tag == L"frame")
404 { 404 {
405 m_criticalSection.Lock(); 405 m_criticalSection.Lock();
406 { 406 {
407 m_cacheDocumentHasFrames.insert(m_documentName); 407 m_cacheDocumentHasFrames.insert(m_documentUrl);
408 } 408 }
409 m_criticalSection.Unlock(); 409 m_criticalSection.Unlock();
410 } 410 }
411 411
412 // Iterate through children of this element 412 // Iterate through children of this element
413 if (allElementsCount > 0) 413 if (allElementsCount > 0)
414 { 414 {
415 long childElementsCount = 0; 415 long childElementsCount = 0;
416 416
417 CComPtr<IDispatch> pChildCollectionDisp; 417 CComPtr<IDispatch> pChildCollectionDisp;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 { 454 {
455 m_cacheIndexLast = 0; 455 m_cacheIndexLast = 0;
456 m_cacheDocumentHasFrames.clear(); 456 m_cacheDocumentHasFrames.clear();
457 m_cacheDocumentHasIframes.clear(); 457 m_cacheDocumentHasIframes.clear();
458 } 458 }
459 m_criticalSection.Unlock(); 459 m_criticalSection.Unlock();
460 } 460 }
461 461
462 462
463 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ 463 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld