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

Unified Diff: src/plugin/AdblockPlusDomTraverser.cpp

Issue 4912420225024000: Issue #1234 - Convert strings associated with URL's (Closed)
Patch Set: Created Oct. 14, 2014, 10:17 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/AdblockPlusDomTraverser.cpp
===================================================================
--- a/src/plugin/AdblockPlusDomTraverser.cpp
+++ b/src/plugin/AdblockPlusDomTraverser.cpp
@@ -12,12 +12,12 @@
}
-bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent)
+bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const std::wstring& url, CString& indent)
{
CPluginClient* client = CPluginClient::GetInstance();
// If src should be blocked, set style display:none on iframe
- bool isBlocked = client->ShouldBlock(to_wstring(url), CFilter::contentTypeSubdocument, m_domain);
+ bool isBlocked = client->ShouldBlock(url, CFilter::contentTypeSubdocument, m_domain);
if (isBlocked)
{
HideElement(pEl, "iframe", url, true, indent);
@@ -40,7 +40,7 @@
cache->m_isHidden = client->IsElementHidden(to_wstring(tag), pEl, m_domain, to_wstring(indent), m_tab->m_filter.get());
if (cache->m_isHidden)
{
- HideElement(pEl, tag, "", false, indent);
+ HideElement(pEl, tag, L"", false, indent);
return false;
}
@@ -51,11 +51,12 @@
if (SUCCEEDED(pEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt == VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0)
{
- CString src = vAttr.bstrVal;
- CPluginClient::UnescapeUrl(src);
+ std::wstring src(vAttr.bstrVal, SysStringLen(vAttr.bstrVal));
+ SysFreeString(vAttr.bstrVal);
sergei 2014/10/17 10:10:12 It's not necessary to call SysFreeString here beca
Eric 2014/10/20 02:36:01 True. Removed it.
sergei 2014/10/21 09:45:17 But it's still here.
Eric 2014/10/21 17:19:52 I _thought_ I had removed it. It's gone now.
+ UnescapeUrl(src);
// If src should be blocked, set style display:none on image
- cache->m_isHidden = client->ShouldBlock(to_wstring(src), CFilter::contentTypeImage, m_domain);
+ cache->m_isHidden = client->ShouldBlock(src, CFilter::contentTypeImage, m_domain);
if (cache->m_isHidden)
{
HideElement(pEl, "image", src, true, indent);
@@ -92,7 +93,7 @@
{
if (cache->m_isHidden)
{
- HideElement(pEl, "object", src, true, indent);
+ HideElement(pEl, "object", ToWstring(src), true, indent);
return false;
}
}
@@ -115,7 +116,7 @@
}
-void CPluginDomTraverser::HideElement(IHTMLElement* pEl, const CString& type, const CString& url, bool isDebug, CString& indent)
+void CPluginDomTraverser::HideElement(IHTMLElement* pEl, const CString& type, const std::wstring& url, bool isDebug, CString& indent)
{
CComPtr<IHTMLStyle> pStyle;
@@ -132,12 +133,12 @@
if (SUCCEEDED(pStyle->put_display(sbstrNone)))
{
- DEBUG_HIDE_EL(indent + L"HideEl::Hiding " + type + L" url:" + url)
+ DEBUG_HIDE_EL(indent + L"HideEl::Hiding " + type + L" url:" + ToCString(url))
#ifdef ENABLE_DEBUG_RESULT
if (isDebug)
{
- CPluginDebug::DebugResultHiding(type, url, "-");
+ CPluginDebug::DebugResultHiding(type, ToCString(url), "-");
}
#endif // ENABLE_DEBUG_RESULT
}

Powered by Google App Engine
This is Rietveld