OLD | NEW |
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 CComVariant vRetIndex; | 230 CComVariant vRetIndex; |
231 CComPtr<IDispatch> pFrameDispatch; | 231 CComPtr<IDispatch> pFrameDispatch; |
232 | 232 |
233 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch))
&& pFrameDispatch) | 233 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch))
&& pFrameDispatch) |
234 { | 234 { |
235 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; | 235 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; |
236 if (pFrameBrowser) | 236 if (pFrameBrowser) |
237 { | 237 { |
238 std::wstring src; | 238 std::wstring src; |
239 CComBSTR bstrSrc; | 239 CComBSTR bstrSrc; |
240 if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc)) && bstrSrc) | 240 if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc))) |
241 { | 241 { |
242 src = std::wstring(bstrSrc,SysStringLen(bstrSrc)); | 242 src = ToWstring(bstrSrc); |
243 } | 243 } |
244 if (!src.empty()) | 244 if (!src.empty()) |
245 { | 245 { |
246 TraverseDocument(pFrameBrowser, false, indent); | 246 TraverseDocument(pFrameBrowser, false, indent); |
247 } | 247 } |
248 } | 248 } |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
(...skipping 14 matching lines...) Expand all Loading... |
267 CComVariant vRetIndex; | 267 CComVariant vRetIndex; |
268 CComPtr<IDispatch> pFrameDispatch; | 268 CComPtr<IDispatch> pFrameDispatch; |
269 | 269 |
270 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch))
&& pFrameDispatch) | 270 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch))
&& pFrameDispatch) |
271 { | 271 { |
272 CComQIPtr<IHTMLElement> pFrameEl = pFrameDispatch; | 272 CComQIPtr<IHTMLElement> pFrameEl = pFrameDispatch; |
273 if (pFrameEl) | 273 if (pFrameEl) |
274 { | 274 { |
275 CComVariant vAttr; | 275 CComVariant vAttr; |
276 | 276 |
277 if (SUCCEEDED(pFrameEl->getAttribute(ATL::CComBSTR(L"src"), 0, &vAttr)
) && vAttr.vt == VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0) | 277 if (SUCCEEDED(pFrameEl->getAttribute(ATL::CComBSTR(L"src"), 0, &vAttr)
) && vAttr.vt == VT_BSTR) |
278 { | 278 { |
279 std::wstring src(vAttr.bstrVal, SysStringLen(vAttr.bstrVal)); | 279 std::wstring src = ToWstring(vAttr.bstrVal); |
| 280 if (!src.empty()) |
| 281 { |
| 282 // Some times, domain is missing. Should this be added on image sr
c's as well?'' |
| 283 // eg. gadgetzone.com.au |
| 284 if (BeginsWith(src, L"//")) |
| 285 { |
| 286 src = L"http:" + src; |
| 287 } |
| 288 // eg. http://w3schools.com/html/html_examples.asp |
| 289 else if (!(BeginsWith(src, L"http") || BeginsWith(src, L"res://"))
) |
| 290 { |
| 291 src = L"http://" + m_domain + src; |
| 292 } |
280 | 293 |
281 // Some times, domain is missing. Should this be added on image src'
s as well?'' | 294 // Check if Iframe should be traversed |
282 // eg. gadgetzone.com.au | 295 if (OnIFrame(pFrameEl, src, indent)) |
283 if (BeginsWith(src, L"//")) | |
284 { | |
285 src = L"http:" + src; | |
286 } | |
287 // eg. http://w3schools.com/html/html_examples.asp | |
288 else if (!(BeginsWith(src, L"http") || BeginsWith(src, L"res://"))) | |
289 { | |
290 src = L"http://" + m_domain + src; | |
291 } | |
292 | |
293 // Check if Iframe should be traversed | |
294 if (OnIFrame(pFrameEl, src, indent)) | |
295 { | |
296 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; | |
297 if (pFrameBrowser) | |
298 { | 296 { |
299 TraverseDocument(pFrameBrowser, false, indent); | 297 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; |
| 298 if (pFrameBrowser) |
| 299 { |
| 300 TraverseDocument(pFrameBrowser, false, indent); |
| 301 } |
300 } | 302 } |
301 } | 303 } |
302 } | 304 } |
303 } | 305 } |
304 } | 306 } |
305 } | 307 } |
306 } | 308 } |
307 } | 309 } |
308 | 310 |
309 template <class T> | 311 template <class T> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 { | 456 { |
455 m_cacheIndexLast = 0; | 457 m_cacheIndexLast = 0; |
456 m_cacheDocumentHasFrames.clear(); | 458 m_cacheDocumentHasFrames.clear(); |
457 m_cacheDocumentHasIframes.clear(); | 459 m_cacheDocumentHasIframes.clear(); |
458 } | 460 } |
459 m_criticalSection.Unlock(); | 461 m_criticalSection.Unlock(); |
460 } | 462 } |
461 | 463 |
462 | 464 |
463 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ | 465 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ |
OLD | NEW |