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

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

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: rebase and remove member of CFilter Created Feb. 4, 2015, 12:50 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/AdblockPlusDomTraverser.cpp ('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-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 #ifndef _PLUGIN_FILTER_H_ 18 #ifndef _PLUGIN_FILTER_H_
19 #define _PLUGIN_FILTER_H_ 19 #define _PLUGIN_FILTER_H_
20 20
21 21
22 #include "PluginTypedef.h" 22 #include "PluginTypedef.h"
23 #include <memory> 23 #include <memory>
24 #include <AdblockPlus/FilterEngine.h>
24 25
25 enum CFilterElementHideAttrPos 26 enum CFilterElementHideAttrPos
26 { 27 {
27 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT 28 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT
28 }; 29 };
29 30
30 enum CFilterElementHideAttrType 31 enum CFilterElementHideAttrType
31 { 32 {
32 TYPE_NONE = 0, STYLE, ID, CLASS 33 TYPE_NONE = 0, STYLE, ID, CLASS
33 }; 34 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 // ============================================================================ 92 // ============================================================================
92 // CFilter 93 // CFilter
93 // ============================================================================ 94 // ============================================================================
94 95
95 class CFilter 96 class CFilter
96 { 97 {
97 98
98 public: 99 public:
99 100
100 enum EContentType
101 {
102 contentTypeUnknown = 0,
103 contentTypeOther = 1,
104 contentTypeScript = 2,
105 contentTypeImage = 4,
106 contentTypeStyleSheet = 8,
107 contentTypeObject = 16,
108 contentTypeSubdocument = 32,
109 contentTypeDocument = 64,
110 contentTypeBackground = 256,
111 contentTypeXbl = 512,
112 contentTypePing = 1024,
113 contentTypeXmlHttpRequest = 2048,
114 contentTypeObjectSubrequest = 4096,
115 contentTypeDtd = 8192,
116 contentTypeAny = 65535
117 } contentType;
118 101
119 enum EFilterType 102 enum EFilterType
120 { 103 {
121 filterTypeBlocking = 0, 104 filterTypeBlocking = 0,
122 filterTypeWhiteList = 1, 105 filterTypeWhiteList = 1,
123 filterTypeElementHide = 2, 106 filterTypeElementHide = 2,
124 filterTypeUnknown = 3 107 filterTypeUnknown = 3
125 } filterType; 108 } filterType;
126 109
127 int m_contentType;
128 enum EFilterType m_filterType; 110 enum EFilterType m_filterType;
129 bool m_isMatchCase; 111 bool m_isMatchCase;
130 bool m_isFirstParty; 112 bool m_isFirstParty;
131 bool m_isThirdParty; 113 bool m_isThirdParty;
132 bool m_isFromStart; 114 bool m_isFromStart;
133 bool m_isFromEnd; 115 bool m_isFromEnd;
134 int m_hitCount; 116 int m_hitCount;
135 CString m_filterText; 117 CString m_filterText;
136 118
137 CFilter(const CFilter&); 119 CFilter(const CFilter&);
138 CFilter(); 120 CFilter();
139 }; 121 };
140 122
141 // ============================================================================ 123 // ============================================================================
142 // CPluginFilter 124 // CPluginFilter
143 // ============================================================================ 125 // ============================================================================
144 126
145 class CPluginFilter 127 class CPluginFilter
146 { 128 {
147 129
148 private: 130 private:
149 131
150 CString m_dataPath; 132 CString m_dataPath;
151 133
152 std::map<int, CString> m_contentMapText;
153
154 typedef std::map<DWORD, CFilter> TFilterMap; 134 typedef std::map<DWORD, CFilter> TFilterMap;
155 typedef std::vector<CFilter> TFilterMapDefault; 135 typedef std::vector<CFilter> TFilterMapDefault;
156 136
157 // (Tag,Name) -> Filter 137 // (Tag,Name) -> Filter
158 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed; 138 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed;
159 139
160 // Tag -> Filter 140 // Tag -> Filter
161 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags; 141 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags;
162 142
163 143
(...skipping 11 matching lines...) Expand all
175 CPluginFilter(const CString& dataPath = ""); 155 CPluginFilter(const CString& dataPath = "");
176 156
177 bool LoadHideFilters(std::vector<std::wstring> filters); 157 bool LoadHideFilters(std::vector<std::wstring> filters);
178 158
179 bool AddFilterElementHide(CString filter); 159 bool AddFilterElementHide(CString filter);
180 160
181 161
182 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const; 162 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const;
183 163
184 164
185 bool ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug=false) const; 165 bool ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentTy pe contentType, const std::wstring& domain, bool addDebug=false) const;
186 166
187 HANDLE hideFiltersLoadedEvent; 167 HANDLE hideFiltersLoadedEvent;
188 }; 168 };
189 169
190 170
191 #endif // _PLUGIN_FILTER_H_ 171 #endif // _PLUGIN_FILTER_H_
OLDNEW
« no previous file with comments | « src/plugin/AdblockPlusDomTraverser.cpp ('k') | src/plugin/PluginFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld