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

Side by Side Diff: src/plugin/PluginClass.cpp

Issue 29333350: Issue #3562 - Use 'ToWstring()' to convert BSTR values (Closed)
Patch Set: fix up error log message Created Jan. 11, 2016, 3:57 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
« no previous file with comments | « src/plugin/AdblockPlusDomTraverser.cpp ('k') | src/plugin/PluginDomTraverserBase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 return browser; 164 return browser;
165 } 165 }
166 166
167 std::wstring CPluginClass::GetBrowserUrl() const 167 std::wstring CPluginClass::GetBrowserUrl() const
168 { 168 {
169 std::wstring url; 169 std::wstring url;
170 if (m_webBrowser2) 170 if (m_webBrowser2)
171 { 171 {
172 CComBSTR bstrURL; 172 CComBSTR bstrURL;
173 if (SUCCEEDED(m_webBrowser2->get_LocationURL(&bstrURL)) && bstrURL) 173 if (SUCCEEDED(m_webBrowser2->get_LocationURL(&bstrURL)))
174 { 174 {
175 url = std::wstring(bstrURL, SysStringLen(bstrURL)); 175 url = ToWstring(bstrURL);
176 } 176 }
177 } 177 }
178 else 178 else
179 { 179 {
180 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr owser2 == nullptr"); 180 DEBUG_GENERAL(L"CPluginClass::GetBrowserUrl - Reached with m_webBrowser2 == nullptr (probable invariant violation)");
181 }
182 if (url.empty())
183 {
181 url = m_tab->GetDocumentUrl(); 184 url = m_tab->GetDocumentUrl();
182 } 185 }
183 return url; 186 return url;
184 } 187 }
185 188
186 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) 189 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr)
187 { 190 {
188 if (thisPtr == NULL) 191 if (thisPtr == NULL)
189 return 0; 192 return 0;
190 if (!((CPluginClass*)thisPtr)->InitObject()) 193 if (!((CPluginClass*)thisPtr)->InitObject())
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 { 470 {
468 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; 471 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp;
469 if (!webBrowser) 472 if (!webBrowser)
470 { 473 {
471 return; 474 return;
472 } 475 }
473 if (!urlVariant || urlVariant->vt != VT_BSTR) 476 if (!urlVariant || urlVariant->vt != VT_BSTR)
474 { 477 {
475 return; 478 return;
476 } 479 }
477 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); 480 std::wstring url = ToWstring(urlVariant->bstrVal);
478 481
479 // If webbrowser2 is equal to top level browser (as set in SetSite), we are 482 // If webbrowser2 is equal to top level browser (as set in SetSite), we are
480 // navigating new page 483 // navigating new page
481 CPluginClient* client = CPluginClient::GetInstance(); 484 CPluginClient* client = CPluginClient::GetInstance();
482 if (url.find(L"javascript") == 0) 485 if (url.find(L"javascript") == 0)
483 { 486 {
484 } 487 }
485 else if (IsRootBrowser(webBrowser)) 488 else if (IsRootBrowser(webBrowser))
486 { 489 {
487 m_tab->OnNavigate(url); 490 m_tab->OnNavigate(url);
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 s_criticalSectionLocal.Unlock(); 1699 s_criticalSectionLocal.Unlock();
1697 1700
1698 return icon; 1701 return icon;
1699 } 1702 }
1700 1703
1701 ATOM CPluginClass::GetAtomPaneClass() 1704 ATOM CPluginClass::GetAtomPaneClass()
1702 { 1705 {
1703 return s_atomPaneClass; 1706 return s_atomPaneClass;
1704 } 1707 }
1705 1708
OLDNEW
« no previous file with comments | « src/plugin/AdblockPlusDomTraverser.cpp ('k') | src/plugin/PluginDomTraverserBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld