OLD | NEW |
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 | 6 |
7 | 7 |
8 // ============================================================================ | 8 // ============================================================================ |
9 // CFilterElementHideAttrSelector | 9 // CFilterElementHideAttrSelector |
10 // ============================================================================ | 10 // ============================================================================ |
(...skipping 23 matching lines...) Expand all Loading... |
34 // ============================================================================ | 34 // ============================================================================ |
35 // CFilterElementHide | 35 // CFilterElementHide |
36 // ============================================================================ | 36 // ============================================================================ |
37 | 37 |
38 class CFilterElementHide | 38 class CFilterElementHide |
39 { | 39 { |
40 | 40 |
41 public: | 41 public: |
42 | 42 |
43 CString m_filterText; | 43 CString m_filterText; |
44 CString m_filterFile; | |
45 | 44 |
46 // For domain specific filters only | 45 // For domain specific filters only |
47 CString m_tagId; | 46 CString m_tagId; |
48 CString m_tagClassName; | 47 CString m_tagClassName; |
49 | 48 |
50 std::set<CString> m_domainsNot; | 49 std::set<CString> m_domainsNot; |
51 | 50 |
52 std::vector<CFilterElementHideAttrSelector> m_attributeSelectors; | 51 std::vector<CFilterElementHideAttrSelector> m_attributeSelectors; |
53 | 52 |
54 CFilterElementHide(const CString& filterText="", const CString& filterFile="")
; | 53 CFilterElementHide(const CString& filterText=""); |
55 CFilterElementHide(const CFilterElementHide& filter); | 54 CFilterElementHide(const CFilterElementHide& filter); |
56 }; | 55 }; |
57 | 56 |
58 // ============================================================================ | 57 // ============================================================================ |
59 // CFilter | 58 // CFilter |
60 // ============================================================================ | 59 // ============================================================================ |
61 | 60 |
62 class CFilter | 61 class CFilter |
63 { | 62 { |
64 | 63 |
(...skipping 30 matching lines...) Expand all Loading... |
95 enum EFilterType m_filterType; | 94 enum EFilterType m_filterType; |
96 std::vector<CString> m_stringElements; | 95 std::vector<CString> m_stringElements; |
97 bool m_isMatchCase; | 96 bool m_isMatchCase; |
98 bool m_isFirstParty; | 97 bool m_isFirstParty; |
99 bool m_isThirdParty; | 98 bool m_isThirdParty; |
100 bool m_isFromStart; | 99 bool m_isFromStart; |
101 bool m_isFromStartDomain; | 100 bool m_isFromStartDomain; |
102 bool m_isFromEnd; | 101 bool m_isFromEnd; |
103 int m_hitCount; | 102 int m_hitCount; |
104 CString m_filterText; | 103 CString m_filterText; |
105 CString m_filterFile; | |
106 std::set<CString> m_domains; | 104 std::set<CString> m_domains; |
107 std::set<CString> m_domainsNot; | 105 std::set<CString> m_domainsNot; |
108 | 106 |
109 CFilter(const CFilter&); | 107 CFilter(const CFilter&); |
110 CFilter(); | 108 CFilter(); |
111 }; | 109 }; |
112 | 110 |
113 // ============================================================================ | 111 // ============================================================================ |
114 // CPluginFilter | 112 // CPluginFilter |
115 // ============================================================================ | 113 // ============================================================================ |
(...skipping 27 matching lines...) Expand all Loading... |
143 | 141 |
144 TFilterElementHideTagsNamed m_elementHideTagsId; | 142 TFilterElementHideTagsNamed m_elementHideTagsId; |
145 TFilterElementHideTagsNamed m_elementHideTagsClass; | 143 TFilterElementHideTagsNamed m_elementHideTagsClass; |
146 TFilterElementHideTags m_elementHideTags; | 144 TFilterElementHideTags m_elementHideTags; |
147 | 145 |
148 TFilterElementHideDomains m_elementHideDomains; | 146 TFilterElementHideDomains m_elementHideDomains; |
149 | 147 |
150 TFilterMap m_filterMap[2][2]; | 148 TFilterMap m_filterMap[2][2]; |
151 TFilterMapDefault m_filterMapDefault[2]; | 149 TFilterMapDefault m_filterMapDefault[2]; |
152 | 150 |
153 void ParseFilters(const TFilterFileList& urlList); | 151 void ClearFilters(); |
154 | 152 |
155 int FindMatch(const CString& src, CString filterPart, int startPos=0) const; | 153 int FindMatch(const CString& src, CString filterPart, int startPos=0) const; |
156 bool IsSpecialChar(TCHAR testChar) const; | 154 bool IsSpecialChar(TCHAR testChar) const; |
157 bool IsSubdomain(const CString& subdomain, const CString& domain) const; | 155 bool IsSubdomain(const CString& subdomain, const CString& domain) const; |
158 | 156 |
159 public: | 157 public: |
160 | 158 |
161 CPluginFilter(const TFilterFileList& urlList, const CString& dataPath); | |
162 CPluginFilter(const CString& dataPath = ""); | 159 CPluginFilter(const CString& dataPath = ""); |
163 | 160 |
164 bool ReadFilter(const CString& filename, const CString& downloadPath=""); | 161 bool LoadHideFilters(std::vector<std::string> filters); |
165 | 162 |
166 void AddFilter(CString filter, CString filterFile, int filterType); | 163 bool AddFilterElementHide(CString filter); |
167 bool AddFilterElementHide(CString filter, CString filterFile); | 164 |
168 | 165 |
169 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom
ain, const CString& indent) const; | 166 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom
ain, const CString& indent) const; |
170 | 167 |
171 const CFilter* MatchFilter(int filterType, const CString& src, int contentType
, const CString& domain) const; | 168 const CFilter* MatchFilter(int filterType, const CString& src, int contentType
, const CString& domain) const; |
172 bool IsMatchFilter(const CFilter& filter, CString src, const CString& srcDomai
n, const CString& domain) const; | 169 bool IsMatchFilter(const CFilter& filter, CString src, const CString& srcDomai
n, const CString& domain) const; |
173 | 170 |
174 bool IsMatchFilterElementHide(const CFilterElementHide& filter, IHTMLElement*
pEl, const CString& domain) const; | 171 bool IsMatchFilterElementHide(const CFilterElementHide& filter, IHTMLElement*
pEl, const CString& domain) const; |
175 | 172 |
176 #if (defined PRODUCT_ADBLOCKPLUS) | |
177 bool static DownloadFilterFile(const CString& url, const CString& filename); | |
178 void static CreateFilters(); | |
179 bool IsAlive() const; | |
180 #endif | |
181 | |
182 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add
Debug=false) const; | 173 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add
Debug=false) const; |
183 bool ShouldWhiteList(CString url) const; | 174 bool ShouldWhiteList(CString url) const; |
184 }; | 175 }; |
185 | 176 |
186 | 177 |
187 #endif // _PLUGIN_FILTER_H_ | 178 #endif // _PLUGIN_FILTER_H_ |
OLD | NEW |