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: address comments Created Nov. 17, 2015, 8:14 p.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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
209 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser) 209 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser)
Eric 2015/11/17 22:30:22 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/17 22:30:22 ATL::CComQIPtr<IWebBrowser2> parent = parentDispat
sergei 2015/11/18 10:07:50 Yes, this is just an assumption and it does not wo
Eric 2015/11/18 14:24:02 What do you mean "because `parent` is always nullp
sergei 2015/11/18 14:28:17 In your snippet
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 }
Eric 2015/11/18 15:25:22 Except after the call to IsEqualObject(), many of
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;
243 while(frame = GetParent(*frame)) 243 while(frame = GetParent(*frame))
(...skipping 188 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