Left: | ||
Right: |
OLD | NEW |
---|---|
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
19 #include "AdblockPlusClient.h" | 19 #include "AdblockPlusClient.h" |
20 #include "PluginClientBase.h" | 20 #include "PluginClientBase.h" |
21 #include "PluginSettings.h" | 21 #include "PluginSettings.h" |
22 #include "AdblockPlusDomTraverser.h" | 22 #include "AdblockPlusDomTraverser.h" |
23 #include "PluginTabBase.h" | 23 #include "PluginTabBase.h" |
24 #include "IeVersion.h" | 24 #include "IeVersion.h" |
25 #include "../shared/Utils.h" | |
25 #include <Mshtmhst.h> | 26 #include <Mshtmhst.h> |
26 | 27 |
27 CPluginTabBase::CPluginTabBase(CPluginClass* plugin) | 28 CPluginTabBase::CPluginTabBase(CPluginClass* plugin) |
28 : m_plugin(plugin) | 29 : m_plugin(plugin) |
29 , m_isActivated(false) | 30 , m_isActivated(false) |
30 , m_continueThreadRunning(true) | 31 , m_continueThreadRunning(true) |
31 { | 32 { |
32 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); | 33 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); |
33 m_filter->hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL); | 34 m_filter->hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL); |
34 | 35 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 params.rgvarg = &var; | 197 params.rgvarg = &var; |
197 params.rgdispidNamedArgs = 0; | 198 params.rgdispidNamedArgs = 0; |
198 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); | 199 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); |
199 DEBUG_GENERAL("Invoke"); | 200 DEBUG_GENERAL("Invoke"); |
200 if (FAILED(hr)) | 201 if (FAILED(hr)) |
201 { | 202 { |
202 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"); |
203 } | 204 } |
204 } | 205 } |
205 | 206 |
207 namespace | |
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) | |
210 { | |
211 ATL::CComPtr<IDispatch> parentDispatch; | |
212 if (FAILED(browser.get_Parent(&parentDispatch)) || !parentDispatch) | |
213 { | |
214 return nullptr; | |
215 } | |
216 // The InternetExplorer application always returns a pointer to itself. | |
217 // https://msdn.microsoft.com/en-us/library/aa752136(v=vs.85).aspx | |
218 if (parentDispatch.IsEqualObject(&browser)) | |
219 { | |
220 return nullptr; | |
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; | |
223 if (!parentDocumentServiceProvider) | |
224 { | |
225 return nullptr; | |
226 } | |
227 ATL::CComPtr<IWebBrowserApp> webBrowserApp; | |
228 if (FAILED(parentDocumentServiceProvider->QueryService(IID_IWebBrowserApp, & webBrowserApp)) || !webBrowserApp) | |
229 { | |
230 return nullptr; | |
231 } | |
232 return ATL::CComQIPtr<IWebBrowser2>(webBrowserApp); | |
233 } | |
234 | |
235 bool IsFrameWhiteListed(ATL::CComPtr<IWebBrowser2> frame) | |
236 { | |
237 if (!frame) | |
238 { | |
239 return false; | |
240 } | |
241 auto url = GetLocationUrl(*frame); | |
242 std::vector<std::string> frameHierarchy; | |
243 while(frame = GetParent(*frame)) | |
244 { | |
245 frameHierarchy.push_back(ToUtf8String(GetLocationUrl(*frame))); | |
246 } | |
247 CPluginClient* client = CPluginClient::GetInstance(); | |
248 return client->IsWhitelistedUrl(url, frameHierarchy) | |
249 || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy); | |
250 } | |
251 } | |
252 | |
206 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) | 253 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) |
207 { | 254 { |
208 CPluginClient* client = CPluginClient::GetInstance(); | 255 CPluginClient* client = CPluginClient::GetInstance(); |
209 std::wstring url = GetDocumentUrl(); | 256 std::wstring url = GetDocumentUrl(); |
210 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u rl)) | 257 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u rl)) |
211 { | 258 { |
212 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); | 259 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); |
213 } | 260 } |
214 InjectABP(browser); | 261 InjectABP(browser); |
215 } | 262 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 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()); |
386 } | 433 } |
387 | 434 |
388 // Non-hanging sleep | 435 // Non-hanging sleep |
389 Sleep(50); | 436 Sleep(50); |
390 } | 437 } |
391 | 438 |
392 tabLoopIteration++; | 439 tabLoopIteration++; |
393 } | 440 } |
394 } | 441 } |
OLD | NEW |