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: remove debugging code Created Nov. 24, 2014, 11:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef _PLUGIN_FILTER_H_ 1 #ifndef _PLUGIN_FILTER_H_
2 #define _PLUGIN_FILTER_H_ 2 #define _PLUGIN_FILTER_H_
3 3
4 4
5 #include "PluginTypedef.h" 5 #include "PluginTypedef.h"
6 #include <memory> 6 #include <memory>
7 #include <AdblockPlus/FilterEngine.h>
7 8
8 enum CFilterElementHideAttrPos 9 enum CFilterElementHideAttrPos
9 { 10 {
10 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT 11 POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT
11 }; 12 };
12 13
13 enum CFilterElementHideAttrType 14 enum CFilterElementHideAttrType
14 { 15 {
15 TYPE_NONE = 0, STYLE, ID, CLASS 16 TYPE_NONE = 0, STYLE, ID, CLASS
16 }; 17 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 // ============================================================================ 75 // ============================================================================
75 // CFilter 76 // CFilter
76 // ============================================================================ 77 // ============================================================================
77 78
78 class CFilter 79 class CFilter
79 { 80 {
80 81
81 public: 82 public:
82 83
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 84
102 enum EFilterType 85 enum EFilterType
103 { 86 {
104 filterTypeBlocking = 0, 87 filterTypeBlocking = 0,
105 filterTypeWhiteList = 1, 88 filterTypeWhiteList = 1,
106 filterTypeElementHide = 2, 89 filterTypeElementHide = 2,
107 filterTypeUnknown = 3 90 filterTypeUnknown = 3
108 } filterType; 91 } filterType;
109 92
110 int m_contentType; 93 AdblockPlus::FilterEngine::ContentType m_contentType;
111 enum EFilterType m_filterType; 94 enum EFilterType m_filterType;
112 bool m_isMatchCase; 95 bool m_isMatchCase;
113 bool m_isFirstParty; 96 bool m_isFirstParty;
114 bool m_isThirdParty; 97 bool m_isThirdParty;
115 bool m_isFromStart; 98 bool m_isFromStart;
116 bool m_isFromEnd; 99 bool m_isFromEnd;
117 int m_hitCount; 100 int m_hitCount;
118 CString m_filterText; 101 CString m_filterText;
119 102
120 CFilter(const CFilter&); 103 CFilter(const CFilter&);
121 CFilter(); 104 CFilter();
122 }; 105 };
123 106
124 // ============================================================================ 107 // ============================================================================
125 // CPluginFilter 108 // CPluginFilter
126 // ============================================================================ 109 // ============================================================================
127 110
128 class CPluginFilter 111 class CPluginFilter
129 { 112 {
130 113
131 private: 114 private:
132 115
133 CString m_dataPath; 116 CString m_dataPath;
134 117
135 std::map<int, CString> m_contentMapText;
136
137 typedef std::map<DWORD, CFilter> TFilterMap; 118 typedef std::map<DWORD, CFilter> TFilterMap;
138 typedef std::vector<CFilter> TFilterMapDefault; 119 typedef std::vector<CFilter> TFilterMapDefault;
139 120
140 // (Tag,Name) -> Filter 121 // (Tag,Name) -> Filter
141 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed; 122 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed;
142 123
143 // Tag -> Filter 124 // Tag -> Filter
144 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags; 125 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags;
145 126
146 127
(...skipping 11 matching lines...) Expand all
158 CPluginFilter(const CString& dataPath = ""); 139 CPluginFilter(const CString& dataPath = "");
159 140
160 bool LoadHideFilters(std::vector<std::wstring> filters); 141 bool LoadHideFilters(std::vector<std::wstring> filters);
161 142
162 bool AddFilterElementHide(CString filter); 143 bool AddFilterElementHide(CString filter);
163 144
164 145
165 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;
166 147
167 148
168 bool ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug=false) const; 149 bool ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentTy pe contentType, const std::wstring& domain, bool addDebug=false) const;
169 150
170 HANDLE hideFiltersLoadedEvent; 151 HANDLE hideFiltersLoadedEvent;
171 }; 152 };
172 153
173 154
174 #endif // _PLUGIN_FILTER_H_ 155 #endif // _PLUGIN_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld