OLD | NEW |
1 #include "Filter.h" | 1 #include "Filter.h" |
2 #include "CommentFilter.h" | 2 #include "CommentFilter.h" |
3 #include "InvalidFilter.h" | 3 #include "InvalidFilter.h" |
4 #include "RegExpFilter.h" | 4 #include "RegExpFilter.h" |
5 #include "BlockingFilter.h" | 5 #include "BlockingFilter.h" |
6 #include "WhitelistFilter.h" | 6 #include "WhitelistFilter.h" |
7 #include "ElemHideBase.h" | 7 #include "ElemHideBase.h" |
8 #include "ElemHideFilter.h" | 8 #include "ElemHideFilter.h" |
9 #include "ElemHideException.h" | 9 #include "ElemHideException.h" |
10 #include "ElemHideEmulationFilter.h" | 10 #include "ElemHideEmulationFilter.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (knownFilter) | 99 if (knownFilter) |
100 { | 100 { |
101 knownFilter->second->AddRef(); | 101 knownFilter->second->AddRef(); |
102 return knownFilter->second; | 102 return knownFilter->second; |
103 } | 103 } |
104 | 104 |
105 FilterPtr filter; | 105 FilterPtr filter; |
106 switch (type) | 106 switch (type) |
107 { | 107 { |
108 case Filter::Type::COMMENT: | 108 case Filter::Type::COMMENT: |
109 filter = new CommentFilter(text); | 109 filter = FilterPtr(new CommentFilter(text), false); |
110 break; | 110 break; |
111 case Filter::Type::INVALID: | 111 case Filter::Type::INVALID: |
112 filter = new InvalidFilter(text, error); | 112 filter = FilterPtr(new InvalidFilter(text, error), false); |
113 break; | 113 break; |
114 case Filter::Type::BLOCKING: | 114 case Filter::Type::BLOCKING: |
115 filter = new BlockingFilter(text, data.regexp); | 115 filter = FilterPtr(new BlockingFilter(text, data.regexp), false); |
116 break; | 116 break; |
117 case Filter::Type::WHITELIST: | 117 case Filter::Type::WHITELIST: |
118 filter = new WhitelistFilter(text, data.regexp); | 118 filter = FilterPtr(new WhitelistFilter(text, data.regexp), false); |
119 break; | 119 break; |
120 case Filter::Type::ELEMHIDE: | 120 case Filter::Type::ELEMHIDE: |
121 filter = new ElemHideFilter(text, data.elemhide); | 121 filter = FilterPtr(new ElemHideFilter(text, data.elemhide), false); |
122 break; | 122 break; |
123 case Filter::Type::ELEMHIDEEXCEPTION: | 123 case Filter::Type::ELEMHIDEEXCEPTION: |
124 filter = new ElemHideException(text, data.elemhide); | 124 filter = FilterPtr(new ElemHideException(text, data.elemhide), false); |
125 break; | 125 break; |
126 case Filter::Type::ELEMHIDEEMULATION: | 126 case Filter::Type::ELEMHIDEEMULATION: |
127 filter = new ElemHideEmulationFilter(text, data.elemhide); | 127 filter = FilterPtr(new ElemHideEmulationFilter(text, data.elemhide), false
); |
128 if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric()) | 128 if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric()) |
129 filter = new InvalidFilter(text, u"filter_elemhideemulation_nodomain"_st
r); | 129 filter = FilterPtr(new InvalidFilter(text, u"filter_elemhideemulation_no
domain"_str), false); |
130 break; | 130 break; |
131 default: | 131 default: |
132 // This should never happen but just in case | 132 // This should never happen but just in case |
133 return nullptr; | 133 return nullptr; |
134 } | 134 } |
135 | 135 |
136 // This is a hack: we looked up the entry using text but create it using | 136 // This is a hack: we looked up the entry using text but create it using |
137 // filter->mText. This works because both are equal at this point. However, | 137 // filter->mText. This works because both are equal at this point. However, |
138 // text refers to a temporary buffer which will go away. | 138 // text refers to a temporary buffer which will go away. |
139 enter_context("Adding to known filters"); | 139 enter_context("Adding to known filters"); |
140 knownFilter.assign(filter->mText, filter.get()); | 140 knownFilter.assign(filter->mText, filter.get()); |
141 exit_context(); | 141 exit_context(); |
142 | 142 |
143 return filter.release(); | 143 return filter.release(); |
144 } | 144 } |
OLD | NEW |