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

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

Issue 4912420225024000: Issue #1234 - Convert strings associated with URL's (Closed)
Patch Set: Created Oct. 14, 2014, 10:17 p.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 #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 std::wstring& domain, cons t CString& documentName); 30 void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, cons t std::wstring& documentName);
31 void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring& domain, c onst 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 std::wstring& url, CString& ind ent) { 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;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::wstring& domain, const CString& documentName) 91 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& 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 std::wstring& domain, const CString& documentName) 100 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con st std::wstring& domain, const CString& documentName)
101 { 101 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 { 215 {
216 CComVariant vIndex(i); 216 CComVariant vIndex(i);
217 CComVariant vRetIndex; 217 CComVariant vRetIndex;
218 CComPtr<IDispatch> pFrameDispatch; 218 CComPtr<IDispatch> pFrameDispatch;
219 219
220 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch)) && pFrameDispatch) 220 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch)) && pFrameDispatch)
221 { 221 {
222 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; 222 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch;
223 if (pFrameBrowser) 223 if (pFrameBrowser)
224 { 224 {
225 CComBSTR bstrSrc; 225 BSTR bstrSrc;
sergei 2014/10/17 10:10:12 Again CComBSTR is replaced by BSTR.
226 CString src; 226 std::wstring src;
227
228 if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc))) 227 if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc)))
229 { 228 {
230 src = bstrSrc; 229 src = std::wstring(bstrSrc,SysStringLen(bstrSrc));
231 CPluginClient::UnescapeUrl(src); 230 SysFreeString(bstrSrc);
231 UnescapeUrl(src);
232 } 232 }
233 233 if (!src.empty())
234 if (!src.IsEmpty())
235 { 234 {
236 TraverseDocument(pFrameBrowser, false, indent); 235 TraverseDocument(pFrameBrowser, false, indent);
237 } 236 }
238 } 237 }
239 } 238 }
240 } 239 }
241 } 240 }
242 241
243 // Iframes 242 // Iframes
244 if (hasIframes) 243 if (hasIframes)
(...skipping 14 matching lines...) Expand all
259 258
260 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch)) && pFrameDispatch) 259 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch)) && pFrameDispatch)
261 { 260 {
262 CComQIPtr<IHTMLElement> pFrameEl = pFrameDispatch; 261 CComQIPtr<IHTMLElement> pFrameEl = pFrameDispatch;
263 if (pFrameEl) 262 if (pFrameEl)
264 { 263 {
265 CComVariant vAttr; 264 CComVariant vAttr;
266 265
267 if (SUCCEEDED(pFrameEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt = = VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0) 266 if (SUCCEEDED(pFrameEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt = = VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0)
268 { 267 {
269 CString src = vAttr.bstrVal; 268 CString srcLegacy = vAttr.bstrVal;
270 269
271 // Some times, domain is missing. Should this be added on image src' s as well?'' 270 // Some times, domain is missing. Should this be added on image src' s as well?''
272 271
273 // eg. gadgetzone.com.au 272 // eg. gadgetzone.com.au
274 if (src.Left(2) == L"//") 273 if (srcLegacy.Left(2) == L"//")
275 { 274 {
276 src = L"http:" + src; 275 srcLegacy = L"http:" + srcLegacy;
277 } 276 }
278 // eg. http://w3schools.com/html/html_examples.asp 277 // eg. http://w3schools.com/html/html_examples.asp
279 else if (src.Left(4) != L"http" && src.Left(6) != L"res://") 278 else if (srcLegacy.Left(4) != L"http" && srcLegacy.Left(6) != L"res: //")
280 { 279 {
281 src = L"http://" + to_CString(m_domain) + src; 280 srcLegacy = L"http://" + to_CString(m_domain) + srcLegacy;
282 } 281 }
283 282 std::wstring src(ToWstring(srcLegacy));
284 CPluginClient::UnescapeUrl(src); 283 UnescapeUrl(src);
285 284
286 // Check if Iframe should be traversed 285 // Check if Iframe should be traversed
287 if (OnIFrame(pFrameEl, src, indent)) 286 if (OnIFrame(pFrameEl, src, indent))
288 { 287 {
289 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; 288 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch;
290 if (pFrameBrowser) 289 if (pFrameBrowser)
291 { 290 {
292 TraverseDocument(pFrameBrowser, false, indent); 291 TraverseDocument(pFrameBrowser, false, indent);
293 } 292 }
294 } 293 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 if (tab->m_plugin->GetTabHWND() == NULL) 459 if (tab->m_plugin->GetTabHWND() == NULL)
461 { 460 {
462 return; 461 return;
463 } 462 }
464 463
465 464
466 } 465 }
467 466
468 467
469 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ 468 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld