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: Created Jan. 11, 2016, 2:32 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 if (url.empty())
179 { 179 {
180 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr owser2 == nullptr"); 180 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr owser2 == nullptr");
sergei 2016/01/11 15:39:07 The comment is slightly inconsistent now with the
Eric 2016/01/11 15:59:33 Yeah. I'll fix that. That's an invariant violation
181 url = m_tab->GetDocumentUrl(); 181 url = m_tab->GetDocumentUrl();
182 } 182 }
183 return url; 183 return url;
184 } 184 }
185 185
186 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) 186 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr)
187 { 187 {
188 if (thisPtr == NULL) 188 if (thisPtr == NULL)
189 return 0; 189 return 0;
190 if (!((CPluginClass*)thisPtr)->InitObject()) 190 if (!((CPluginClass*)thisPtr)->InitObject())
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 { 467 {
468 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; 468 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp;
469 if (!webBrowser) 469 if (!webBrowser)
470 { 470 {
471 return; 471 return;
472 } 472 }
473 if (!urlVariant || urlVariant->vt != VT_BSTR) 473 if (!urlVariant || urlVariant->vt != VT_BSTR)
474 { 474 {
475 return; 475 return;
476 } 476 }
477 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); 477 std::wstring url = ToWstring(urlVariant->bstrVal);
478 478
479 // If webbrowser2 is equal to top level browser (as set in SetSite), we are 479 // If webbrowser2 is equal to top level browser (as set in SetSite), we are
480 // navigating new page 480 // navigating new page
481 CPluginClient* client = CPluginClient::GetInstance(); 481 CPluginClient* client = CPluginClient::GetInstance();
482 if (url.find(L"javascript") == 0) 482 if (url.find(L"javascript") == 0)
483 { 483 {
484 } 484 }
485 else if (IsRootBrowser(webBrowser)) 485 else if (IsRootBrowser(webBrowser))
486 { 486 {
487 m_tab->OnNavigate(url); 487 m_tab->OnNavigate(url);
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 s_criticalSectionLocal.Unlock(); 1696 s_criticalSectionLocal.Unlock();
1697 1697
1698 return icon; 1698 return icon;
1699 } 1699 }
1700 1700
1701 ATOM CPluginClass::GetAtomPaneClass() 1701 ATOM CPluginClass::GetAtomPaneClass()
1702 { 1702 {
1703 return s_atomPaneClass; 1703 return s_atomPaneClass;
1704 } 1704 }
1705 1705
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