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 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 params.rgvarg = &var; | 170 params.rgvarg = &var; |
171 params.rgdispidNamedArgs = 0; | 171 params.rgdispidNamedArgs = 0; |
172 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); | 172 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); |
173 DEBUG_GENERAL("Invoke"); | 173 DEBUG_GENERAL("Invoke"); |
174 if (FAILED(hr)) | 174 if (FAILED(hr)) |
175 { | 175 { |
176 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"); | 176 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"); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 namespace | |
181 { | |
182 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser) | |
183 { | |
184 ATL::CComPtr<IDispatch> browserParentDispatch; | |
Eric
2015/05/14 17:07:26
I'd call this 'parentDispatch' here, in analogy wi
sergei
2015/05/15 11:55:55
renamed
| |
185 if (FAILED(browser.get_Parent(&browserParentDispatch)) || !browserParentDisp atch) | |
186 { | |
187 return nullptr; | |
188 } | |
189 // The InternetExplorer application always returns a pointer to itself. | |
190 if (browserParentDispatch.IsEqualObject(&browser)) | |
191 { | |
192 return nullptr; | |
193 } | |
194 ATL::CComQIPtr<IServiceProvider> parentDocumentServiceProvider = browserPare ntDispatch; | |
195 if (!parentDocumentServiceProvider) | |
196 { | |
197 return nullptr; | |
198 } | |
199 ATL::CComPtr<IWebBrowserApp> webBrowserApp; | |
200 if (FAILED(parentDocumentServiceProvider->QueryService(IID_IWebBrowserApp, & webBrowserApp)) || !webBrowserApp) | |
201 { | |
202 return nullptr; | |
203 } | |
204 return ATL::CComQIPtr<IWebBrowser2>(webBrowserApp); | |
205 } | |
206 | |
207 bool IsFrameWhiteListed(ATL::CComPtr<IWebBrowser2> frame) | |
208 { | |
209 if (!frame) | |
210 { | |
211 return false; | |
212 } | |
213 auto url = GetLocationUrl(*frame); | |
214 std::vector<std::string> frameHierarchy; | |
215 for(frame = GetParent(*frame); frame; frame = GetParent(*frame)) | |
216 { | |
217 frameHierarchy.push_back(ToUtf8String(GetLocationUrl(*frame))); | |
218 } | |
219 CPluginClient* client = CPluginClient::GetInstance(); | |
220 return client->IsWhitelistedUrl(url, frameHierarchy) | |
221 || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy); | |
222 } | |
223 } | |
224 | |
180 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) | 225 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) |
181 { | 226 { |
182 CPluginClient* client = CPluginClient::GetInstance(); | 227 CPluginClient* client = CPluginClient::GetInstance(); |
183 std::wstring url = GetDocumentUrl(); | 228 std::wstring url = GetDocumentUrl(); |
184 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u rl)) | 229 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u rl)) |
185 { | 230 { |
186 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); | 231 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); |
187 } | 232 } |
188 InjectABP(browser); | 233 InjectABP(browser); |
189 } | 234 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId()); | 404 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId()); |
360 } | 405 } |
361 | 406 |
362 // Non-hanging sleep | 407 // Non-hanging sleep |
363 Sleep(50); | 408 Sleep(50); |
364 } | 409 } |
365 | 410 |
366 tabLoopIteration++; | 411 tabLoopIteration++; |
367 } | 412 } |
368 } | 413 } |
OLD | NEW |