| Index: src/plugin/PluginTabBase.cpp |
| =================================================================== |
| --- a/src/plugin/PluginTabBase.cpp |
| +++ b/src/plugin/PluginTabBase.cpp |
| @@ -29,8 +29,6 @@ |
| : m_isActivated(false) |
| , m_continueThreadRunning(true) |
| { |
| - m_filter.hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL); |
| - |
| CPluginClient* client = CPluginClient::GetInstance(); |
| if (AdblockPlus::IE::InstalledMajorVersion() < 10) |
| { |
| @@ -79,38 +77,29 @@ |
| m_isActivated = true; |
| } |
| -namespace |
| +void CPluginTab::OnNavigate(const std::wstring& url) |
| { |
| - // Entry Point |
| - void FilterLoader(CPluginFilter* filter, const std::wstring& domain) |
| + SetDocumentUrl(url); |
| +} |
| + |
| +void CPluginTab::OnDownloadBegin() |
| +{ |
| + std::wstring domain = GetDocumentDomain(); |
| + ClearFrameCache(domain); |
| + if (!filter) |
| { |
| try |
| { |
| - filter->LoadHideFilters(CPluginClient::GetInstance()->GetElementHidingSelectors(domain)); |
| - SetEvent(filter->hideFiltersLoadedEvent); |
| + filter.reset(new CPluginFilter(domain)); |
| } |
| - catch (...) |
| + catch (const std::exception& e) |
| { |
| - // As a thread-main function, we truncate any C++ exception. |
| + DEBUG_EXCEPTION(e); |
| } |
| } |
| -} |
| - |
| -void CPluginTab::OnNavigate(const std::wstring& url) |
| -{ |
| - SetDocumentUrl(url); |
| - ClearFrameCache(GetDocumentDomain()); |
| - std::wstring domainString = GetDocumentDomain(); |
| - ResetEvent(m_filter.hideFiltersLoadedEvent); |
| - try |
| + else |
| { |
| - std::thread filterLoaderThread(&FilterLoader, &m_filter, GetDocumentDomain()); |
| - filterLoaderThread.detach(); // TODO: but actually we should wait for the thread in the dtr. |
| - } |
| - catch (const std::system_error& ex) |
| - { |
| - DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CREATE_PROCESS, |
| - "Class::Thread - Failed to start filter loader thread"); |
| + DEBUG_GENERAL("Suspicious: Reached CPluginTab::OnDownloadBegin with a non-null filter") |
| } |
| } |
| @@ -261,9 +250,15 @@ |
| std::wstring url = GetDocumentUrl(); |
| if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(url)) |
| { |
| - CPluginDomTraverser traversal(&m_filter); |
| - traversal.TraverseDocumentRoot(browser, GetDocumentDomain(), GetDocumentUrl()); |
| + CPluginFilter* f = filter.get(); |
| + if (f) |
| + { |
| + f->EnsureInitialized(); |
| + CPluginDomTraverser traversal(f); |
| + traversal.TraverseDocumentRoot(browser, GetDocumentDomain(), GetDocumentUrl()); |
| + } |
| } |
| + filter.reset(); |
| InjectABP(browser); |
| } |