Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginFilter.h

Issue 29334397: Issue #2230, #3391 - Load filters on "download begin" event
Patch Set: Created Jan. 22, 2016, 6:02 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginFilter.h
===================================================================
--- a/src/plugin/PluginFilter.h
+++ b/src/plugin/PluginFilter.h
@@ -20,6 +20,7 @@
#include <memory>
#include <AdblockPlus/FilterEngine.h>
+#include "DetachedInitialization.h"
enum CFilterElementHideAttrPos
{
@@ -118,6 +119,7 @@
// ============================================================================
class CPluginFilter
+ : private DetachedInitializer
{
// (Tag,Name) -> Filter
typedef std::multimap<std::pair<std::wstring, std::wstring>, CFilterElementHide> TFilterElementHideTagsNamed;
@@ -126,14 +128,22 @@
TFilterElementHideTagsNamed m_elementHideTagsId;
TFilterElementHideTagsNamed m_elementHideTagsClass;
TFilterElementHideTags m_elementHideTags;
- void ClearFilters();
+ bool AddFilterElementHide(std::wstring filter);
+ bool LoadHideFilters();
+ const std::wstring& domain;
sergei 2016/01/29 10:03:20 That's very dangerous, make it non-reference.
Eric 2016/02/03 18:03:20 Done.
+ InitializerType Initializer() override
+ {
+ return [this] { LoadHideFilters(); };
+ }
public:
- CPluginFilter();
- bool LoadHideFilters(std::vector<std::wstring> filters);
- bool AddFilterElementHide(std::wstring filter);
+ CPluginFilter(const std::wstring& domain)
+ : domain(domain)
+ {
+ SpawnInitializer();
+ }
bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::wstring& domain, const std::wstring& indent) const;
- HANDLE hideFiltersLoadedEvent;
+ void EnsureInitialized() { DetachedInitializer::EnsureInitialized(); }
};

Powered by Google App Engine
This is Rietveld