| 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 "../shared/Utils.h" |
| 26 #include <Mshtmhst.h> | 26 #include <Mshtmhst.h> |
| 27 | 27 |
| 28 CPluginTabBase::CPluginTabBase(CPluginClass* plugin) | 28 CPluginTab::CPluginTab() |
| 29 : m_plugin(plugin) | 29 : m_isActivated(false) |
| 30 , m_isActivated(false) | |
| 31 , m_continueThreadRunning(true) | 30 , m_continueThreadRunning(true) |
| 32 { | 31 { |
| 33 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); | 32 m_filter.hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL); |
| 34 m_filter->hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL); | |
| 35 | 33 |
| 36 CPluginClient* client = CPluginClient::GetInstance(); | 34 CPluginClient* client = CPluginClient::GetInstance(); |
| 37 if (AdblockPlus::IE::InstalledMajorVersion() < 10) | 35 if (AdblockPlus::IE::InstalledMajorVersion() < 10) |
| 38 { | 36 { |
| 39 m_isActivated = true; | 37 m_isActivated = true; |
| 40 } | 38 } |
| 41 | 39 |
| 42 try | 40 try |
| 43 { | 41 { |
| 44 m_thread = std::thread(&CPluginTabBase::ThreadProc, this); | 42 m_thread = std::thread(&CPluginTab::ThreadProc, this); |
| 45 } | 43 } |
| 46 catch (const std::system_error& ex) | 44 catch (const std::system_error& ex) |
| 47 { | 45 { |
| 48 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREA
TE_PROCESS, | 46 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREA
TE_PROCESS, |
| 49 "Tab::Thread - Failed to create tab thread"); | 47 "Tab::Thread - Failed to create tab thread"); |
| 50 } | 48 } |
| 51 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this)); | 49 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this)); |
| 52 } | 50 } |
| 53 | 51 |
| 54 | 52 |
| 55 CPluginTabBase::~CPluginTabBase() | 53 CPluginTab::~CPluginTab() |
| 56 { | 54 { |
| 57 delete m_traverser; | 55 delete m_traverser; |
| 58 m_traverser = NULL; | 56 m_traverser = NULL; |
| 59 m_continueThreadRunning = false; | 57 m_continueThreadRunning = false; |
| 60 if (m_thread.joinable()) { | 58 if (m_thread.joinable()) { |
| 61 m_thread.join(); | 59 m_thread.join(); |
| 62 } | 60 } |
| 63 } | 61 } |
| 64 | 62 |
| 65 void CPluginTabBase::OnActivate() | 63 void CPluginTab::OnActivate() |
| 66 { | 64 { |
| 67 m_isActivated = true; | 65 m_isActivated = true; |
| 68 } | 66 } |
| 69 | 67 |
| 70 | 68 |
| 71 void CPluginTabBase::OnUpdate() | 69 void CPluginTab::OnUpdate() |
| 72 { | 70 { |
| 73 m_isActivated = true; | 71 m_isActivated = true; |
| 74 } | 72 } |
| 75 | 73 |
| 76 namespace | 74 namespace |
| 77 { | 75 { |
| 78 // Entry Point | 76 // Entry Point |
| 79 void FilterLoader(CPluginTabBase* tabBase) | 77 void FilterLoader(CPluginFilter* filter, const std::wstring& domain) |
| 80 { | 78 { |
| 81 try | 79 try |
| 82 { | 80 { |
| 83 tabBase->m_filter->LoadHideFilters(CPluginClient::GetInstance()->GetElemen
tHidingSelectors(tabBase->GetDocumentDomain())); | 81 filter->LoadHideFilters(CPluginClient::GetInstance()->GetElementHidingSele
ctors(domain)); |
| 84 SetEvent(tabBase->m_filter->hideFiltersLoadedEvent); | 82 SetEvent(filter->hideFiltersLoadedEvent); |
| 85 } | 83 } |
| 86 catch (...) | 84 catch (...) |
| 87 { | 85 { |
| 88 // As a thread-main function, we truncate any C++ exception. | 86 // As a thread-main function, we truncate any C++ exception. |
| 89 } | 87 } |
| 90 } | 88 } |
| 91 } | 89 } |
| 92 | 90 |
| 93 void CPluginTabBase::OnNavigate(const std::wstring& url) | 91 void CPluginTab::OnNavigate(const std::wstring& url) |
| 94 { | 92 { |
| 95 SetDocumentUrl(url); | 93 SetDocumentUrl(url); |
| 96 ClearFrameCache(GetDocumentDomain()); | 94 ClearFrameCache(GetDocumentDomain()); |
| 97 std::wstring domainString = GetDocumentDomain(); | 95 std::wstring domainString = GetDocumentDomain(); |
| 98 ResetEvent(m_filter->hideFiltersLoadedEvent); | 96 ResetEvent(m_filter.hideFiltersLoadedEvent); |
| 99 try | 97 try |
| 100 { | 98 { |
| 101 std::thread filterLoaderThread(&FilterLoader, this); | 99 std::thread filterLoaderThread(&FilterLoader, &m_filter, GetDocumentDomain()
); |
| 102 filterLoaderThread.detach(); // TODO: but actually we should wait for the th
read in the dtr. | 100 filterLoaderThread.detach(); // TODO: but actually we should wait for the th
read in the dtr. |
| 103 } | 101 } |
| 104 catch (const std::system_error& ex) | 102 catch (const std::system_error& ex) |
| 105 { | 103 { |
| 106 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE
ATE_PROCESS, | 104 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE
ATE_PROCESS, |
| 107 "Class::Thread - Failed to start filter loader thread"); | 105 "Class::Thread - Failed to start filter loader thread"); |
| 108 } | 106 } |
| 109 m_traverser->ClearCache(); | 107 m_traverser->ClearCache(); |
| 110 } | 108 } |
| 111 | 109 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 140 return false; | 138 return false; |
| 141 } | 139 } |
| 142 auto urlCstr = url.c_str(); | 140 auto urlCstr = url.c_str(); |
| 143 // Check the prefix to match our directory | 141 // Check the prefix to match our directory |
| 144 // Check the suffix to be an HTML file | 142 // Check the suffix to be an HTML file |
| 145 return (_wcsnicmp(urlCstr, dir.c_str(), dir.length()) == 0) && | 143 return (_wcsnicmp(urlCstr, dir.c_str(), dir.length()) == 0) && |
| 146 (_wcsnicmp(urlCstr + url.length() - 5, L".html", 5) == 0); | 144 (_wcsnicmp(urlCstr + url.length() - 5, L".html", 5) == 0); |
| 147 } | 145 } |
| 148 } | 146 } |
| 149 | 147 |
| 150 void CPluginTabBase::InjectABP(IWebBrowser2* browser) | 148 void CPluginTab::InjectABP(IWebBrowser2* browser) |
| 151 { | 149 { |
| 152 CriticalSection::Lock lock(m_csInject); | 150 CriticalSection::Lock lock(m_csInject); |
| 153 auto url = GetDocumentUrl(); | 151 auto url = GetDocumentUrl(); |
| 154 if (!IsOurHtmlFile(url)) | 152 if (!IsOurHtmlFile(url)) |
| 155 { | 153 { |
| 156 DEBUG_GENERAL(L"InjectABP. Not injecting"); | 154 DEBUG_GENERAL(L"InjectABP. Not injecting"); |
| 157 return; | 155 return; |
| 158 } | 156 } |
| 159 DEBUG_GENERAL(L"InjectABP. Injecting"); | 157 DEBUG_GENERAL(L"InjectABP. Injecting"); |
| 160 CComPtr<IDispatch> pDocDispatch; | 158 CComPtr<IDispatch> pDocDispatch; |
| 161 browser->get_Document(&pDocDispatch); | 159 browser->get_Document(&pDocDispatch); |
| 162 CComQIPtr<IHTMLDocument2> pDoc2(pDocDispatch); | 160 CComQIPtr<IHTMLDocument2> pDoc2(pDocDispatch); |
| 163 if (!pDoc2) | 161 if (!pDoc2) |
| 164 { | 162 { |
| 165 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to QI docume
nt"); | 163 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTab::InjectABP - Failed to QI document")
; |
| 166 return; | 164 return; |
| 167 } | 165 } |
| 168 CComPtr<IHTMLWindow2> pWnd2; | 166 CComPtr<IHTMLWindow2> pWnd2; |
| 169 pDoc2->get_parentWindow(&pWnd2); | 167 pDoc2->get_parentWindow(&pWnd2); |
| 170 if (!pWnd2) | 168 if (!pWnd2) |
| 171 { | 169 { |
| 172 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to get paren
t window"); | 170 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTab::InjectABP - Failed to get parent wi
ndow"); |
| 173 return; | 171 return; |
| 174 } | 172 } |
| 175 CComQIPtr<IDispatchEx> pWndEx(pWnd2); | 173 CComQIPtr<IDispatchEx> pWndEx(pWnd2); |
| 176 if (!pWndEx) | 174 if (!pWndEx) |
| 177 { | 175 { |
| 178 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to QI dispat
ch"); | 176 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTab::InjectABP - Failed to QI dispatch")
; |
| 179 return; | 177 return; |
| 180 } | 178 } |
| 181 // Create "Settings" object in JavaScript. | 179 // Create "Settings" object in JavaScript. |
| 182 // A method call of "Settings" in JavaScript, transfered to "Invoke" of m_plug
inUserSettings | 180 // A method call of "Settings" in JavaScript, transfered to "Invoke" of m_plug
inUserSettings |
| 183 DISPID dispid; | 181 DISPID dispid; |
| 184 HRESULT hr = pWndEx->GetDispID(L"Settings", fdexNameEnsure, &dispid); | 182 HRESULT hr = pWndEx->GetDispID(L"Settings", fdexNameEnsure, &dispid); |
| 185 if (FAILED(hr)) | 183 if (FAILED(hr)) |
| 186 { | 184 { |
| 187 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to get disp
atch"); | 185 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTab::InjectABP - Failed to get dispatch
"); |
| 188 return; | 186 return; |
| 189 } | 187 } |
| 190 CComVariant var((IDispatch*)&m_pluginUserSettings); | 188 CComVariant var((IDispatch*)&m_pluginUserSettings); |
| 191 | 189 |
| 192 DEBUG_GENERAL("Injecting"); | 190 DEBUG_GENERAL("Injecting"); |
| 193 | 191 |
| 194 DISPPARAMS params; | 192 DISPPARAMS params; |
| 195 params.cArgs = 1; | 193 params.cArgs = 1; |
| 196 params.cNamedArgs = 0; | 194 params.cNamedArgs = 0; |
| 197 params.rgvarg = &var; | 195 params.rgvarg = &var; |
| 198 params.rgdispidNamedArgs = 0; | 196 params.rgdispidNamedArgs = 0; |
| 199 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU
T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); | 197 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU
T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); |
| 200 DEBUG_GENERAL("Invoke"); | 198 DEBUG_GENERAL("Invoke"); |
| 201 if (FAILED(hr)) | 199 if (FAILED(hr)) |
| 202 { | 200 { |
| 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"); | 201 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTab::InjectABP - Failed to create Setti
ngs in JavaScript"); |
| 204 } | 202 } |
| 205 } | 203 } |
| 206 | 204 |
| 207 namespace | 205 namespace |
| 208 { | 206 { |
| 209 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser) | 207 ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser) |
| 210 { | 208 { |
| 211 ATL::CComPtr<IDispatch> parentDispatch; | 209 ATL::CComPtr<IDispatch> parentDispatch; |
| 212 if (FAILED(browser.get_Parent(&parentDispatch)) || !parentDispatch) | 210 if (FAILED(browser.get_Parent(&parentDispatch)) || !parentDispatch) |
| 213 { | 211 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 243 while(frame = GetParent(*frame)) | 241 while(frame = GetParent(*frame)) |
| 244 { | 242 { |
| 245 frameHierarchy.push_back(ToUtf8String(GetLocationUrl(*frame))); | 243 frameHierarchy.push_back(ToUtf8String(GetLocationUrl(*frame))); |
| 246 } | 244 } |
| 247 CPluginClient* client = CPluginClient::GetInstance(); | 245 CPluginClient* client = CPluginClient::GetInstance(); |
| 248 return client->IsWhitelistedUrl(url, frameHierarchy) | 246 return client->IsWhitelistedUrl(url, frameHierarchy) |
| 249 || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy); | 247 || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy); |
| 250 } | 248 } |
| 251 } | 249 } |
| 252 | 250 |
| 253 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) | 251 void CPluginTab::OnDownloadComplete(IWebBrowser2* browser) |
| 254 { | 252 { |
| 255 CPluginClient* client = CPluginClient::GetInstance(); | 253 CPluginClient* client = CPluginClient::GetInstance(); |
| 256 std::wstring url = GetDocumentUrl(); | 254 std::wstring url = GetDocumentUrl(); |
| 257 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u
rl)) | 255 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u
rl)) |
| 258 { | 256 { |
| 259 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl()
); | 257 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl()
); |
| 260 } | 258 } |
| 261 InjectABP(browser); | 259 InjectABP(browser); |
| 262 } | 260 } |
| 263 | 261 |
| 264 void CPluginTabBase::OnDocumentComplete(IWebBrowser2* browser, const std::wstrin
g& url, bool isDocumentBrowser) | 262 void CPluginTab::OnDocumentComplete(IWebBrowser2* browser, const std::wstring& u
rl, bool isDocumentBrowser) |
| 265 { | 263 { |
| 266 std::wstring documentUrl = GetDocumentUrl(); | 264 std::wstring documentUrl = GetDocumentUrl(); |
| 267 | 265 |
| 268 if (isDocumentBrowser) | 266 if (isDocumentBrowser) |
| 269 { | 267 { |
| 270 if (url != documentUrl) | 268 if (url != documentUrl) |
| 271 { | 269 { |
| 272 SetDocumentUrl(url); | 270 SetDocumentUrl(url); |
| 273 } | 271 } |
| 274 InjectABP(browser); | 272 InjectABP(browser); |
| 275 } | 273 } |
| 276 CString urlLegacy = ToCString(url); | 274 if (BeginsWith(url, L"res://")) |
| 277 if (urlLegacy.Left(6) != "res://") | |
| 278 { | 275 { |
| 279 // Get document | 276 return; |
| 280 CComPtr<IDispatch> pDocDispatch; | 277 } |
| 281 HRESULT hr = browser->get_Document(&pDocDispatch); | 278 // Get document |
| 282 if (FAILED(hr) || !pDocDispatch) | 279 CComPtr<IDispatch> pDocDispatch; |
| 280 HRESULT hr = browser->get_Document(&pDocDispatch); |
| 281 if (FAILED(hr) || !pDocDispatch) |
| 282 { |
| 283 return; |
| 284 } |
| 285 |
| 286 CComQIPtr<IHTMLDocument2> pDoc(pDocDispatch); |
| 287 if (!pDoc) |
| 288 { |
| 289 return; |
| 290 } |
| 291 |
| 292 CComPtr<IOleObject> pOleObj; |
| 293 pDocDispatch->QueryInterface(&pOleObj); |
| 294 if (!pOleObj) |
| 295 { |
| 296 return; |
| 297 } |
| 298 CComPtr<IOleClientSite> pClientSite; |
| 299 pOleObj->GetClientSite(&pClientSite); |
| 300 if (pClientSite != NULL) |
| 301 { |
| 302 CComPtr<IDocHostUIHandler> docHostUIHandler; |
| 303 pClientSite->QueryInterface(&docHostUIHandler); |
| 304 if (docHostUIHandler != NULL) |
| 283 { | 305 { |
| 284 return; | 306 docHostUIHandler->UpdateUI(); |
| 285 } | |
| 286 | |
| 287 CComQIPtr<IHTMLDocument2> pDoc(pDocDispatch); | |
| 288 if (!pDoc) | |
| 289 { | |
| 290 return; | |
| 291 } | |
| 292 | |
| 293 CComPtr<IOleObject> pOleObj; | |
| 294 pDocDispatch->QueryInterface(&pOleObj); | |
| 295 if (!pOleObj) | |
| 296 { | |
| 297 return; | |
| 298 } | |
| 299 CComPtr<IOleClientSite> pClientSite; | |
| 300 pOleObj->GetClientSite(&pClientSite); | |
| 301 if (pClientSite != NULL) | |
| 302 { | |
| 303 CComPtr<IDocHostUIHandler> docHostUIHandler; | |
| 304 pClientSite->QueryInterface(&docHostUIHandler); | |
| 305 if (docHostUIHandler != NULL) | |
| 306 { | |
| 307 docHostUIHandler->UpdateUI(); | |
| 308 } | |
| 309 } | 307 } |
| 310 } | 308 } |
| 311 } | 309 } |
| 312 | 310 |
| 313 std::wstring CPluginTabBase::GetDocumentDomain() | 311 std::wstring CPluginTab::GetDocumentDomain() |
| 314 { | 312 { |
| 315 std::wstring domain; | 313 std::wstring domain; |
| 316 | 314 |
| 317 m_criticalSection.Lock(); | 315 m_criticalSection.Lock(); |
| 318 { | 316 { |
| 319 domain = m_documentDomain; | 317 domain = m_documentDomain; |
| 320 } | 318 } |
| 321 m_criticalSection.Unlock(); | 319 m_criticalSection.Unlock(); |
| 322 | 320 |
| 323 return domain; | 321 return domain; |
| 324 } | 322 } |
| 325 | 323 |
| 326 void CPluginTabBase::SetDocumentUrl(const std::wstring& url) | 324 void CPluginTab::SetDocumentUrl(const std::wstring& url) |
| 327 { | 325 { |
| 328 m_criticalSection.Lock(); | 326 m_criticalSection.Lock(); |
| 329 { | 327 { |
| 330 m_documentUrl = url; | 328 m_documentUrl = url; |
| 331 m_documentDomain = CAdblockPlusClient::GetInstance()->GetHostFromUrl(url); | 329 m_documentDomain = CAdblockPlusClient::GetInstance()->GetHostFromUrl(url); |
| 332 } | 330 } |
| 333 m_criticalSection.Unlock(); | 331 m_criticalSection.Unlock(); |
| 334 } | 332 } |
| 335 | 333 |
| 336 std::wstring CPluginTabBase::GetDocumentUrl() | 334 std::wstring CPluginTab::GetDocumentUrl() |
| 337 { | 335 { |
| 338 std::wstring url; | 336 std::wstring url; |
| 339 | 337 |
| 340 m_criticalSection.Lock(); | 338 m_criticalSection.Lock(); |
| 341 { | 339 { |
| 342 url = m_documentUrl; | 340 url = m_documentUrl; |
| 343 } | 341 } |
| 344 m_criticalSection.Unlock(); | 342 m_criticalSection.Unlock(); |
| 345 | 343 |
| 346 return url; | 344 return url; |
| 347 } | 345 } |
| 348 | 346 |
| 349 | 347 |
| 350 // ============================================================================ | 348 // ============================================================================ |
| 351 // Frame caching | 349 // Frame caching |
| 352 // ============================================================================ | 350 // ============================================================================ |
| 353 bool CPluginTabBase::IsFrameCached(const std::wstring& url) | 351 bool CPluginTab::IsFrameCached(const std::wstring& url) |
| 354 { | 352 { |
| 355 bool isFrame; | 353 bool isFrame; |
| 356 | 354 |
| 357 m_criticalSectionCache.Lock(); | 355 m_criticalSectionCache.Lock(); |
| 358 { | 356 { |
| 359 isFrame = m_cacheFrames.find(url) != m_cacheFrames.end(); | 357 isFrame = m_cacheFrames.find(url) != m_cacheFrames.end(); |
| 360 } | 358 } |
| 361 m_criticalSectionCache.Unlock(); | 359 m_criticalSectionCache.Unlock(); |
| 362 | 360 |
| 363 return isFrame; | 361 return isFrame; |
| 364 } | 362 } |
| 365 | 363 |
| 366 void CPluginTabBase::CacheFrame(const std::wstring& url) | 364 void CPluginTab::CacheFrame(const std::wstring& url) |
| 367 { | 365 { |
| 368 m_criticalSectionCache.Lock(); | 366 m_criticalSectionCache.Lock(); |
| 369 { | 367 { |
| 370 m_cacheFrames.insert(url); | 368 m_cacheFrames.insert(url); |
| 371 } | 369 } |
| 372 m_criticalSectionCache.Unlock(); | 370 m_criticalSectionCache.Unlock(); |
| 373 } | 371 } |
| 374 | 372 |
| 375 void CPluginTabBase::ClearFrameCache(const std::wstring& domain) | 373 void CPluginTab::ClearFrameCache(const std::wstring& domain) |
| 376 { | 374 { |
| 377 m_criticalSectionCache.Lock(); | 375 m_criticalSectionCache.Lock(); |
| 378 { | 376 { |
| 379 if (domain.empty() || domain != m_cacheDomain) | 377 if (domain.empty() || domain != m_cacheDomain) |
| 380 { | 378 { |
| 381 m_cacheFrames.clear(); | 379 m_cacheFrames.clear(); |
| 382 m_cacheDomain = domain; | 380 m_cacheDomain = domain; |
| 383 } | 381 } |
| 384 } | 382 } |
| 385 m_criticalSectionCache.Unlock(); | 383 m_criticalSectionCache.Unlock(); |
| 386 } | 384 } |
| 387 | 385 |
| 388 void CPluginTabBase::ThreadProc() | 386 void CPluginTab::ThreadProc() |
| 389 { | 387 { |
| 390 // Force loading/creation of settings | 388 // Force loading/creation of settings |
| 391 CPluginSettings::GetInstance()->SetWorkingThreadId(); | 389 CPluginSettings::GetInstance()->SetWorkingThreadId(); |
| 392 | 390 |
| 393 std::string message = | 391 std::string message = |
| 394 "===========================================================================
=====\n" | 392 "===========================================================================
=====\n" |
| 395 "TAB THREAD process="; | 393 "TAB THREAD process="; |
| 396 message += std::to_string(::GetCurrentProcessId()); | 394 message += std::to_string(::GetCurrentProcessId()); |
| 397 message + " thread="; | 395 message + " thread="; |
| 398 message += std::to_string(::GetCurrentThreadId()); | 396 message += std::to_string(::GetCurrentThreadId()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 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()); |
| 435 } | 433 } |
| 436 | 434 |
| 437 // Non-hanging sleep | 435 // Non-hanging sleep |
| 438 Sleep(50); | 436 Sleep(50); |
| 439 } | 437 } |
| 440 | 438 |
| 441 tabLoopIteration++; | 439 tabLoopIteration++; |
| 442 } | 440 } |
| 443 } | 441 } |
| OLD | NEW |