OLD | NEW |
(Empty) | |
| 1 #ifndef ADBLOCK_PLUS_ACTIVE_FILTER_H |
| 2 #define ADBLOCK_PLUS_ACTIVE_FILTER_H |
| 3 |
| 4 #include <emscripten.h> |
| 5 |
| 6 #include "Filter.h" |
| 7 #include "StringMap.h" |
| 8 |
| 9 #define FILTER_PROPERTY(type, name, getter, setter) \ |
| 10 private:\ |
| 11 type name;\ |
| 12 public:\ |
| 13 type EMSCRIPTEN_KEEPALIVE getter() const\ |
| 14 {\ |
| 15 return name;\ |
| 16 }\ |
| 17 void EMSCRIPTEN_KEEPALIVE setter(type value)\ |
| 18 {\ |
| 19 if (name != value)\ |
| 20 {\ |
| 21 type oldvalue = name;\ |
| 22 name = value;\ |
| 23 String action(u"filter."_str #name);\ |
| 24 EM_ASM_ARGS({\ |
| 25 var filter = new (exports[Filter_mapping[$2]])($1);\ |
| 26 FilterNotifier.triggerListeners(getStringData($0), filter, $3, $4);\ |
| 27 }, &action, this, GetType(), value, oldvalue);\ |
| 28 }\ |
| 29 } |
| 30 |
| 31 class ActiveFilter : public Filter |
| 32 { |
| 33 private: |
| 34 bool mIgnoreTrailingDot; |
| 35 typedef StringMap<bool> DomainMap; |
| 36 typedef StringSet SitekeySet; |
| 37 protected: |
| 38 std::unique_ptr<DomainMap> mDomains; |
| 39 std::unique_ptr<SitekeySet> mSitekeys; |
| 40 void ParseDomains(const String& str, char16_t separator); |
| 41 void AddSitekey(const String& sitekey); |
| 42 public: |
| 43 explicit ActiveFilter(const String& text, |
| 44 bool ignoreTrailingDot); |
| 45 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); |
| 46 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); |
| 47 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); |
| 48 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(String& docDomain, |
| 49 const String& sitekey) const; |
| 50 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(String& docDomain) const; |
| 51 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; |
| 52 String EMSCRIPTEN_KEEPALIVE Serialize() const; |
| 53 }; |
| 54 |
| 55 #endif |
OLD | NEW |