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

Delta Between Two Patch Sets: src/plugin/PluginFilter.h

Issue 6567422169448448: Issue 119 - Switch to injecting CSS for element hiding (Closed)
Left Patch Set: Created Dec. 10, 2014, 5:12 p.m.
Right Patch Set: rename OnQuit Created Sept. 30, 2016, 3:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginDomTraverserBase.h ('k') | src/plugin/PluginFilter.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
1 #ifndef _PLUGIN_FILTER_H_ 18 #ifndef _PLUGIN_FILTER_H_
2 #define _PLUGIN_FILTER_H_ 19 #define _PLUGIN_FILTER_H_
3 20
4
5 #include "PluginTypedef.h"
6 #include <memory> 21 #include <memory>
22 #include <AdblockPlus/FilterEngine.h>
7 23
8 enum CFilterElementHideAttrPos 24 enum CFilterElementHideAttrPos
9 { 25 {
10 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT 26 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT
11 }; 27 };
12 28
13 enum CFilterElementHideAttrType 29 enum CFilterElementHideAttrType
14 { 30 {
15 TYPE_NONE = 0, STYLE, ID, CLASS 31 TYPE_NONE = 0, STYLE, ID, CLASS
16 }; 32 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 89
74 // ============================================================================ 90 // ============================================================================
75 // CFilter 91 // CFilter
76 // ============================================================================ 92 // ============================================================================
77 93
78 class CFilter 94 class CFilter
79 { 95 {
80 96
81 public: 97 public:
82 98
83 enum EContentType
84 {
85 contentTypeUnknown = 0,
86 contentTypeOther = 1,
87 contentTypeScript = 2,
88 contentTypeImage = 4,
89 contentTypeStyleSheet = 8,
90 contentTypeObject = 16,
91 contentTypeSubdocument = 32,
92 contentTypeDocument = 64,
93 contentTypeBackground = 256,
94 contentTypeXbl = 512,
95 contentTypePing = 1024,
96 contentTypeXmlHttpRequest = 2048,
97 contentTypeObjectSubrequest = 4096,
98 contentTypeDtd = 8192,
99 contentTypeAny = 65535
100 } contentType;
101 99
102 enum EFilterType 100 enum EFilterType
103 { 101 {
104 filterTypeBlocking = 0, 102 filterTypeBlocking = 0,
105 filterTypeWhiteList = 1, 103 filterTypeWhiteList = 1,
106 filterTypeElementHide = 2, 104 filterTypeElementHide = 2,
107 filterTypeUnknown = 3 105 filterTypeUnknown = 3
108 } filterType; 106 } filterType;
109 107
110 int m_contentType;
111 enum EFilterType m_filterType; 108 enum EFilterType m_filterType;
112 bool m_isMatchCase; 109 bool m_isMatchCase;
113 bool m_isFirstParty; 110 bool m_isFirstParty;
114 bool m_isThirdParty; 111 bool m_isThirdParty;
115 bool m_isFromStart; 112 bool m_isFromStart;
116 bool m_isFromEnd; 113 bool m_isFromEnd;
117 int m_hitCount; 114 int m_hitCount;
118 CString m_filterText; 115 CString m_filterText;
119 116
120 CFilter(const CFilter&); 117 CFilter(const CFilter&);
121 CFilter(); 118 CFilter();
122 }; 119 };
123 120
124 // ============================================================================ 121 // ============================================================================
125 // CPluginFilter 122 // CPluginFilter
126 // ============================================================================ 123 // ============================================================================
127 124
128 class CPluginFilter 125 class CPluginFilter
129 { 126 {
130 127
131 private: 128 private:
132 129
133 CString m_dataPath;
134
135 std::map<int, CString> m_contentMapText;
136
137 typedef std::map<DWORD, CFilter> TFilterMap;
138 typedef std::vector<CFilter> TFilterMapDefault;
139
140 // (Tag,Name) -> Filter 130 // (Tag,Name) -> Filter
141 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed; 131 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed;
142 132
143 // Tag -> Filter 133 // Tag -> Filter
144 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags; 134 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags;
145 135
146 136
147 TFilterElementHideTagsNamed m_elementHideTagsId; 137 TFilterElementHideTagsNamed m_elementHideTagsId;
148 TFilterElementHideTagsNamed m_elementHideTagsClass; 138 TFilterElementHideTagsNamed m_elementHideTagsClass;
149 TFilterElementHideTags m_elementHideTags; 139 TFilterElementHideTags m_elementHideTags;
150
151 TFilterMap m_filterMap[2][2];
152 TFilterMapDefault m_filterMapDefault[2];
153 std::vector<std::wstring> m_hideFilters; 140 std::vector<std::wstring> m_hideFilters;
154 141
155 void ClearFilters();
156 142
157 public: 143 public:
158 144 explicit CPluginFilter(const std::vector<std::wstring>& filters);
159 CPluginFilter(const CString& dataPath = "");
160
161 bool LoadHideFilters(const std::vector<std::wstring>& filters);
162
163 bool AddFilterElementHide(CString filter); 145 bool AddFilterElementHide(CString filter);
164
165
166 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const; 146 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const;
167 147 const std::vector<std::wstring>& GetHideFilters() const {
168 148 return m_hideFilters;
169 bool ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug=false) const; 149 }
170
171 HANDLE hideFiltersLoadedEvent;
172 const std::vector<std::wstring>& getHideFilters() const;
Oleksandr 2015/02/04 20:59:57 GetHideFilters() to be consistent?
sergei 2015/04/13 08:06:58 fixed
173 }; 150 };
174 151
152 typedef std::shared_ptr<CPluginFilter> PluginFilterPtr;
175 153
176 #endif // _PLUGIN_FILTER_H_ 154 #endif // _PLUGIN_FILTER_H_
LEFTRIGHT

Powered by Google App Engine
This is Rietveld