OLD | NEW |
1 #ifndef _PLUGIN_DOM_TRAVERSER_BASE_H_ | 1 #ifndef _PLUGIN_DOM_TRAVERSER_BASE_H_ |
2 #define _PLUGIN_DOM_TRAVERSER_BASE_H_ | 2 #define _PLUGIN_DOM_TRAVERSER_BASE_H_ |
3 | 3 |
4 | 4 |
5 #include "PluginTypedef.h" | 5 #include "PluginTypedef.h" |
6 #include "PluginTab.h" | 6 #include "PluginTab.h" |
7 | 7 |
8 | 8 |
9 class CPluginDomTraverserCacheBase | 9 class CPluginDomTraverserCacheBase |
10 { | 10 { |
11 public: | 11 public: |
12 | 12 |
13 long m_elements; | 13 long m_elements; |
14 | 14 |
15 CPluginDomTraverserCacheBase() : m_elements(0) {}; | 15 CPluginDomTraverserCacheBase() : m_elements(0) {}; |
16 void Init() { m_elements=0; } | 16 void Init() { m_elements=0; } |
17 }; | 17 }; |
18 | 18 |
19 template <class T> | 19 template <class T> |
20 class CPluginDomTraverserBase | 20 class CPluginDomTraverserBase |
21 { | 21 { |
22 | 22 |
23 public: | 23 public: |
24 | 24 |
25 CPluginDomTraverserBase(CPluginTab* tab); | 25 CPluginDomTraverserBase(CPluginTab* tab); |
26 ~CPluginDomTraverserBase(); | 26 ~CPluginDomTraverserBase(); |
27 | 27 |
28 void TraverseHeader(bool isHeaderTraversed); | 28 void TraverseHeader(bool isHeaderTraversed); |
29 | 29 |
30 void TraverseDocument(IWebBrowser2* pBrowser, const CString& domain, const CSt
ring& documentName); | 30 void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, cons
t CString& documentName); |
31 void TraverseSubdocument(IWebBrowser2* pBrowser, const CString& domain, const
CString& documentName); | 31 void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring& domain, c
onst CString& documentName); |
32 | 32 |
33 virtual void ClearCache(); | 33 virtual void ClearCache(); |
34 | 34 |
35 void ShowNotification(CPluginTab* tab); | 35 void ShowNotification(CPluginTab* tab); |
36 | 36 |
37 protected: | 37 protected: |
38 | 38 |
39 virtual bool OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent)
{ return true; } | 39 virtual bool OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent)
{ return true; } |
40 virtual bool OnElement(IHTMLElement* pEl, const CString& tag, T* cache, bool i
sDebug, CString& indent) { return true; } | 40 virtual bool OnElement(IHTMLElement* pEl, const CString& tag, T* cache, bool i
sDebug, CString& indent) { return true; } |
41 | 41 |
42 virtual bool IsEnabled(); | 42 virtual bool IsEnabled(); |
43 | 43 |
44 protected: | 44 protected: |
45 | 45 |
46 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, CString indent); | 46 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, CString indent); |
47 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, CString& indent,
bool isCached=true); | 47 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, CString& indent,
bool isCached=true); |
48 | 48 |
49 CComAutoCriticalSection m_criticalSection; | 49 CComAutoCriticalSection m_criticalSection; |
50 | 50 |
51 CString m_domain; | 51 std::wstring m_domain; |
52 CString m_documentName; | 52 CString m_documentName; |
53 | 53 |
54 bool m_isHeaderTraversed; | 54 bool m_isHeaderTraversed; |
55 | 55 |
56 // Caching | 56 // Caching |
57 long m_cacheDomElementCount; | 57 long m_cacheDomElementCount; |
58 | 58 |
59 int m_cacheIndexLast; | 59 int m_cacheIndexLast; |
60 int m_cacheElementsMax; | 60 int m_cacheElementsMax; |
61 std::set<CString> m_cacheDocumentHasFrames; | 61 std::set<CString> m_cacheDocumentHasFrames; |
(...skipping 19 matching lines...) Expand all Loading... |
81 delete [] m_cacheElements; | 81 delete [] m_cacheElements; |
82 } | 82 } |
83 | 83 |
84 template <class T> | 84 template <class T> |
85 void CPluginDomTraverserBase<T>::TraverseHeader(bool isHeaderTraversed) | 85 void CPluginDomTraverserBase<T>::TraverseHeader(bool isHeaderTraversed) |
86 { | 86 { |
87 m_isHeaderTraversed = isHeaderTraversed; | 87 m_isHeaderTraversed = isHeaderTraversed; |
88 } | 88 } |
89 | 89 |
90 template <class T> | 90 template <class T> |
91 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const
CString& domain, const CString& documentName) | 91 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const
std::wstring& domain, const CString& documentName) |
92 { | 92 { |
93 m_domain = domain; | 93 m_domain = domain; |
94 | 94 |
95 TraverseDocument(pBrowser, true, ""); | 95 TraverseDocument(pBrowser, true, ""); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 template <class T> | 99 template <class T> |
100 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con
st CString& domain, const CString& documentName) | 100 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con
st std::wstring& domain, const CString& documentName) |
101 { | 101 { |
102 m_domain = domain; | 102 m_domain = domain; |
103 | 103 |
104 TraverseDocument(pBrowser, false, ""); | 104 TraverseDocument(pBrowser, false, ""); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 template <class T> | 108 template <class T> |
109 bool CPluginDomTraverserBase<T>::IsEnabled() | 109 bool CPluginDomTraverserBase<T>::IsEnabled() |
110 { | 110 { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Some times, domain is missing. Should this be added on image src'
s as well?'' | 271 // Some times, domain is missing. Should this be added on image src'
s as well?'' |
272 | 272 |
273 // eg. gadgetzone.com.au | 273 // eg. gadgetzone.com.au |
274 if (src.Left(2) == L"//") | 274 if (src.Left(2) == L"//") |
275 { | 275 { |
276 src = L"http:" + src; | 276 src = L"http:" + src; |
277 } | 277 } |
278 // eg. http://w3schools.com/html/html_examples.asp | 278 // eg. http://w3schools.com/html/html_examples.asp |
279 else if (src.Left(4) != L"http" && src.Left(6) != L"res://") | 279 else if (src.Left(4) != L"http" && src.Left(6) != L"res://") |
280 { | 280 { |
281 src = L"http://" + m_domain + src; | 281 src = L"http://" + to_CString(m_domain) + src; |
282 } | 282 } |
283 | 283 |
284 CPluginClient::UnescapeUrl(src); | 284 CPluginClient::UnescapeUrl(src); |
285 | 285 |
286 // Check if Iframe should be traversed | 286 // Check if Iframe should be traversed |
287 if (OnIFrame(pFrameEl, src, indent)) | 287 if (OnIFrame(pFrameEl, src, indent)) |
288 { | 288 { |
289 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; | 289 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; |
290 if (pFrameBrowser) | 290 if (pFrameBrowser) |
291 { | 291 { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 if (tab->m_plugin->GetTabHWND() == NULL) | 460 if (tab->m_plugin->GetTabHWND() == NULL) |
461 { | 461 { |
462 return; | 462 return; |
463 } | 463 } |
464 | 464 |
465 | 465 |
466 } | 466 } |
467 | 467 |
468 | 468 |
469 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ | 469 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ |
OLD | NEW |