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

Side by Side Diff: src/plugin/PluginFilter.h

Issue 29334397: Issue #2230, #3391 - Load filters on "download begin" event
Patch Set: address comments Created Feb. 3, 2016, 6:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginDomTraverserBase.h ('k') | src/plugin/PluginFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 #ifndef _PLUGIN_FILTER_H_ 18 #ifndef _PLUGIN_FILTER_H_
19 #define _PLUGIN_FILTER_H_ 19 #define _PLUGIN_FILTER_H_
20 20
21 #include <memory> 21 #include <memory>
22 #include <AdblockPlus/FilterEngine.h> 22 #include <AdblockPlus/FilterEngine.h>
23 #include "DetachedInitialization.h"
23 24
24 enum CFilterElementHideAttrPos 25 enum CFilterElementHideAttrPos
25 { 26 {
26 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT 27 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT
27 }; 28 };
28 29
29 enum CFilterElementHideAttrType 30 enum CFilterElementHideAttrType
30 { 31 {
31 TYPE_NONE = 0, STYLE, ID, CLASS 32 TYPE_NONE = 0, STYLE, ID, CLASS
32 }; 33 };
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 CFilter(const CFilter&); 113 CFilter(const CFilter&);
113 CFilter(); 114 CFilter();
114 }; 115 };
115 116
116 // ============================================================================ 117 // ============================================================================
117 // CPluginFilter 118 // CPluginFilter
118 // ============================================================================ 119 // ============================================================================
119 120
120 class CPluginFilter 121 class CPluginFilter
122 : private DetachedInitializer
121 { 123 {
122 // (Tag,Name) -> Filter 124 // (Tag,Name) -> Filter
123 typedef std::multimap<std::pair<std::wstring, std::wstring>, CFilterElementHid e> TFilterElementHideTagsNamed; 125 typedef std::multimap<std::pair<std::wstring, std::wstring>, CFilterElementHid e> TFilterElementHideTagsNamed;
124 // Tag -> Filter 126 // Tag -> Filter
125 typedef std::multimap<std::wstring, CFilterElementHide> TFilterElementHideTags ; 127 typedef std::multimap<std::wstring, CFilterElementHide> TFilterElementHideTags ;
126 TFilterElementHideTagsNamed m_elementHideTagsId; 128 TFilterElementHideTagsNamed m_elementHideTagsId;
127 TFilterElementHideTagsNamed m_elementHideTagsClass; 129 TFilterElementHideTagsNamed m_elementHideTagsClass;
128 TFilterElementHideTags m_elementHideTags; 130 TFilterElementHideTags m_elementHideTags;
129 void ClearFilters(); 131 bool AddFilterElementHide(std::wstring filter);
132 bool LoadHideFilters();
133 const std::wstring domain;
134 InitializerType Initializer() override
135 {
136 return [this] { LoadHideFilters(); };
137 }
130 138
131 public: 139 public:
132 CPluginFilter(); 140 CPluginFilter(const std::wstring& domain)
133 bool LoadHideFilters(std::vector<std::wstring> filters); 141 : domain(domain)
134 bool AddFilterElementHide(std::wstring filter); 142 {
143 SpawnInitializer();
144 }
135 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const; 145 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const;
136 HANDLE hideFiltersLoadedEvent; 146 void EnsureInitialized() { DetachedInitializer::EnsureInitialized(); }
137 }; 147 };
138 148
139 149
140 #endif // _PLUGIN_FILTER_H_ 150 #endif // _PLUGIN_FILTER_H_
OLDNEW
« no previous file with comments | « src/plugin/PluginDomTraverserBase.h ('k') | src/plugin/PluginFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld