| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3  * Copyright (C) 2006-present eyeo GmbH | 3  * Copyright (C) 2006-present eyeo GmbH | 
| 4  * | 4  * | 
| 5  * Adblock Plus is free software: you can redistribute it and/or modify | 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 | 6  * it under the terms of the GNU General Public License version 3 as | 
| 7  * published by the Free Software Foundation. | 7  * published by the Free Software Foundation. | 
| 8  * | 8  * | 
| 9  * Adblock Plus is distributed in the hope that it will be useful, | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
| 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 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/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 #pragma once | 18 #pragma once | 
| 19 | 19 | 
|  | 20 #include "../base.h" | 
| 20 #include "Filter.h" | 21 #include "Filter.h" | 
| 21 #include "../StringMap.h" | 22 #include "../StringMap.h" | 
| 22 #include "../FilterNotifier.h" | 23 #include "../FilterNotifier.h" | 
| 23 #include "../bindings/runtime.h" | 24 #include "../bindings/runtime.h" | 
| 24 | 25 | 
| 25 #define FILTER_PROPERTY(type, name, topic, getter, setter) \ | 26 #define FILTER_PROPERTY(type, name, topic, getter, setter) \ | 
| 26     private:\ | 27     private:\ | 
| 27       type name;\ | 28       type name;\ | 
| 28     public:\ | 29     public:\ | 
| 29       type BINDINGS_EXPORTED getter() const\ | 30       type BINDINGS_EXPORTED getter() const\ | 
| 30       {\ | 31       {\ | 
| 31         return name;\ | 32         return name;\ | 
| 32       }\ | 33       }\ | 
| 33       void BINDINGS_EXPORTED setter(type value)\ | 34       void BINDINGS_EXPORTED setter(type value)\ | 
| 34       {\ | 35       {\ | 
| 35         if (name != value)\ | 36         if (name != value)\ | 
| 36         {\ | 37         {\ | 
| 37           name = value;\ | 38           name = value;\ | 
| 38           if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ | 39           if (ABP_NS::FilterNotifier::Topic::topic != ABP_NS::FilterNotifier::To
    pic::NONE)\ | 
| 39           {\ | 40           {\ | 
| 40             FilterNotifier::FilterChange(FilterNotifier::Topic::topic, *this);\ | 41             ABP_NS::FilterNotifier::FilterChange(ABP_NS::FilterNotifier::Topic::
    topic, *this);\ | 
| 41           }\ | 42           }\ | 
| 42         }\ | 43         }\ | 
| 43       } | 44       } | 
| 44 | 45 | 
|  | 46 ABP_NS_BEGIN | 
|  | 47 | 
| 45 class ActiveFilter : public Filter | 48 class ActiveFilter : public Filter | 
| 46 { | 49 { | 
| 47 protected: | 50 protected: | 
| 48   typedef StringMap<bool> DomainMap; | 51   typedef StringMap<bool> DomainMap; | 
| 49   typedef StringSet SitekeySet; | 52   typedef StringSet SitekeySet; | 
| 50   void ParseDomains(const String& domains, String::value_type separator) const; | 53   void ParseDomains(const String& domains, String::value_type separator) const; | 
| 51   void AddSitekey(const String& sitekey) const; | 54   void AddSitekey(const String& sitekey) const; | 
| 52   virtual DomainMap* GetDomains() const; | 55   virtual DomainMap* GetDomains() const; | 
| 53   virtual SitekeySet* GetSitekeys() const; | 56   virtual SitekeySet* GetSitekeys() const; | 
| 54   mutable std::unique_ptr<DomainMap> mDomains; | 57   mutable std::unique_ptr<DomainMap> mDomains; | 
| 55   mutable std::unique_ptr<SitekeySet> mSitekeys; | 58   mutable std::unique_ptr<SitekeySet> mSitekeys; | 
| 56 private: | 59 private: | 
| 57   bool mIgnoreTrailingDot; | 60   bool mIgnoreTrailingDot; | 
| 58 public: | 61 public: | 
| 59   explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); | 62   explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); | 
| 60   FILTER_PROPERTY(bool, mDisabled, FILTER_DISABLED, GetDisabled, SetDisabled); | 63   FILTER_PROPERTY(bool, mDisabled, FILTER_DISABLED, GetDisabled, SetDisabled); | 
| 61   FILTER_PROPERTY(unsigned int, mHitCount, FILTER_HITCOUNT, | 64   FILTER_PROPERTY(unsigned int, mHitCount, FILTER_HITCOUNT, | 
| 62       GetHitCount, SetHitCount); | 65       GetHitCount, SetHitCount); | 
| 63   FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT, | 66   FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT, | 
| 64       GetLastHit, SetLastHit); | 67       GetLastHit, SetLastHit); | 
| 65   bool BINDINGS_EXPORTED IsActiveOnDomain(DependentString& docDomain, | 68   bool BINDINGS_EXPORTED IsActiveOnDomain(DependentString& docDomain, | 
| 66       const String& sitekey) const; | 69       const String& sitekey) const; | 
| 67   bool BINDINGS_EXPORTED IsActiveOnlyOnDomain(DependentString& docDomain) const; | 70   bool BINDINGS_EXPORTED IsActiveOnlyOnDomain(DependentString& docDomain) const; | 
| 68   bool BINDINGS_EXPORTED IsGeneric() const; | 71   bool BINDINGS_EXPORTED IsGeneric() const; | 
| 69   OwnedString BINDINGS_EXPORTED Serialize() const; | 72   OwnedString BINDINGS_EXPORTED Serialize() const; | 
| 70 }; | 73 }; | 
|  | 74 | 
|  | 75 ABP_NS_END | 
| OLD | NEW | 
|---|