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

Unified Diff: src/plugin/PluginDomTraverserBase.h

Issue 4912420225024000: Issue #1234 - Convert strings associated with URL's (Closed)
Patch Set: Created Oct. 20, 2014, 2:34 a.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/PluginDomTraverserBase.h
===================================================================
--- a/src/plugin/PluginDomTraverserBase.h
+++ b/src/plugin/PluginDomTraverserBase.h
@@ -27,7 +27,7 @@
void TraverseHeader(bool isHeaderTraversed);
- void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const CString& documentName);
+ void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& documentName);
void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring& domain, const CString& documentName);
virtual void ClearCache();
@@ -36,7 +36,7 @@
protected:
- virtual bool OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent) { return true; }
+ virtual bool OnIFrame(IHTMLElement* pEl, const std::wstring& url, CString& indent) { return true; }
virtual bool OnElement(IHTMLElement* pEl, const CString& tag, T* cache, bool isDebug, CString& indent) { return true; }
virtual bool IsEnabled();
@@ -88,7 +88,7 @@
}
template <class T>
-void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const CString& documentName)
+void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, const std::wstring& documentName)
{
m_domain = domain;
@@ -222,16 +222,15 @@
CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch;
if (pFrameBrowser)
{
- CComBSTR bstrSrc;
- CString src;
-
+ BSTR bstrSrc;
+ std::wstring src;
if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc)))
{
- src = bstrSrc;
- CPluginClient::UnescapeUrl(src);
+ src = std::wstring(bstrSrc,SysStringLen(bstrSrc));
+ SysFreeString(bstrSrc);
+ UnescapeUrl(src);
}
-
- if (!src.IsEmpty())
+ if (!src.empty())
{
TraverseDocument(pFrameBrowser, false, indent);
}
@@ -266,22 +265,22 @@
if (SUCCEEDED(pFrameEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt == VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0)
{
- CString src = vAttr.bstrVal;
+ CString srcLegacy = vAttr.bstrVal;
// Some times, domain is missing. Should this be added on image src's as well?''
// eg. gadgetzone.com.au
- if (src.Left(2) == L"//")
+ if (srcLegacy.Left(2) == L"//")
{
- src = L"http:" + src;
+ srcLegacy = L"http:" + srcLegacy;
}
// eg. http://w3schools.com/html/html_examples.asp
- else if (src.Left(4) != L"http" && src.Left(6) != L"res://")
+ else if (srcLegacy.Left(4) != L"http" && srcLegacy.Left(6) != L"res://")
{
- src = L"http://" + to_CString(m_domain) + src;
+ srcLegacy = L"http://" + to_CString(m_domain) + srcLegacy;
}
-
- CPluginClient::UnescapeUrl(src);
+ std::wstring src(ToWstring(srcLegacy));
+ UnescapeUrl(src);
// Check if Iframe should be traversed
if (OnIFrame(pFrameEl, src, indent))

Powered by Google App Engine
This is Rietveld