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

Delta Between Two Patch Sets: src/plugin/PluginTabBase.cpp

Issue 5447868882092032: Issue 1793 - check whether the frame is whitelisted before injecting CSS (Closed)
Left Patch Set: add link Created Oct. 28, 2015, 10:32 a.m.
Right Patch Set: rebase and rename webBrowser to parentBrowser Created Nov. 30, 2015, 3:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/AdblockPlusClient.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 params.rgdispidNamedArgs = 0; 198 params.rgdispidNamedArgs = 0;
199 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU T | DISPATCH_PROPERTYPUTREF, &params, 0, 0, 0); 199 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU T | DISPATCH_PROPERTYPUTREF, &params, 0, 0, 0);
200 DEBUG_GENERAL("Invoke"); 200 DEBUG_GENERAL("Invoke");
201 if (FAILED(hr)) 201 if (FAILED(hr))
202 { 202 {
203 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to create S ettings in JavaScript"); 203 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to create S ettings in JavaScript");
204 } 204 }
205 } 205 }
206 206
207 namespace 207 namespace
208 { 208 {
Eric 2015/11/14 20:28:13 I don't believe that any of the pointers in the fu
209 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser) 209 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser)
210 { 210 {
211 ATL::CComPtr<IDispatch> parentDispatch; 211 ATL::CComPtr<IDispatch> parentDispatch;
212 if (FAILED(browser.get_Parent(&parentDispatch)) || !parentDispatch) 212 if (FAILED(browser.get_Parent(&parentDispatch)) || !parentDispatch)
213 { 213 {
214 return nullptr; 214 return nullptr;
215 } 215 }
216 // The InternetExplorer application always returns a pointer to itself. 216 // The InternetExplorer application always returns a pointer to itself.
217 // https://msdn.microsoft.com/en-us/library/aa752136(v=vs.85).aspx 217 // https://msdn.microsoft.com/en-us/library/aa752136(v=vs.85).aspx
218 if (parentDispatch.IsEqualObject(&browser)) 218 if (parentDispatch.IsEqualObject(&browser))
219 { 219 {
220 return nullptr; 220 return nullptr;
221 } 221 }
Eric 2015/11/14 20:28:13 I don't see the need for any of the code in the fu
sergei 2015/11/17 20:16:00 Smart pointers are used to avoid manual calls of R
Eric 2015/11/17 21:00:16 I know what smart pointers for COM objects do. My
sergei 2015/11/17 21:05:23 We should call Release on pointers obtained either
Eric 2015/11/17 22:30:22 This is the real reason. We don't need to manage t
sergei 2015/11/18 10:07:50 I see the point. You are talking that the lifetime
Eric 2015/11/18 15:25:22 I'll concede the point that this is purely defensi
222 ATL::CComQIPtr<IServiceProvider> parentDocumentServiceProvider = parentDispa tch; 222 ATL::CComQIPtr<IServiceProvider> parentDocumentServiceProvider = parentDispa tch;
223 if (!parentDocumentServiceProvider) 223 if (!parentDocumentServiceProvider)
224 { 224 {
225 return nullptr; 225 return nullptr;
226 } 226 }
227 ATL::CComPtr<IWebBrowserApp> webBrowserApp; 227 ATL::CComPtr<IWebBrowser2> parentBrowser;
228 if (FAILED(parentDocumentServiceProvider->QueryService(IID_IWebBrowserApp, & webBrowserApp)) || !webBrowserApp) 228 if (FAILED(parentDocumentServiceProvider->QueryService(SID_SWebBrowserApp, & parentBrowser)))
229 { 229 {
230 return nullptr; 230 return nullptr;
231 } 231 }
232 return ATL::CComQIPtr<IWebBrowser2>(webBrowserApp); 232 return parentBrowser;
233 } 233 }
234 234
235 bool IsFrameWhiteListed(ATL::CComPtr<IWebBrowser2> frame) 235 bool IsFrameWhiteListed(ATL::CComPtr<IWebBrowser2> frame)
236 { 236 {
237 if (!frame) 237 if (!frame)
238 { 238 {
239 return false; 239 return false;
240 } 240 }
241 auto url = GetLocationUrl(*frame); 241 auto url = GetLocationUrl(*frame);
242 std::vector<std::string> frameHierarchy; 242 std::vector<std::string> frameHierarchy;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId()); 432 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId());
433 } 433 }
434 434
435 // Non-hanging sleep 435 // Non-hanging sleep
436 Sleep(50); 436 Sleep(50);
437 } 437 }
438 438
439 tabLoopIteration++; 439 tabLoopIteration++;
440 } 440 }
441 } 441 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld