| 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-2015 Eyeo GmbH | 3  * Copyright (C) 2006-2015 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 | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 27 }; | 27 }; | 
| 28 | 28 | 
| 29 enum CFilterElementHideAttrType | 29 enum CFilterElementHideAttrType | 
| 30 { | 30 { | 
| 31   TYPE_NONE = 0, STYLE, ID, CLASS | 31   TYPE_NONE = 0, STYLE, ID, CLASS | 
| 32 }; | 32 }; | 
| 33 // ============================================================================ | 33 // ============================================================================ | 
| 34 // CFilterElementHideAttrSelector | 34 // CFilterElementHideAttrSelector | 
| 35 // ============================================================================ | 35 // ============================================================================ | 
| 36 | 36 | 
| 37 class CFilterElementHideAttrSelector | 37 struct CFilterElementHideAttrSelector | 
| 38 { | 38 { | 
|  | 39   CFilterElementHideAttrPos m_pos; | 
|  | 40   CFilterElementHideAttrType m_type; | 
|  | 41   std::wstring m_attr; | 
|  | 42   std::wstring m_value; | 
| 39 | 43 | 
| 40 public: | 44   CFilterElementHideAttrSelector() | 
| 41 | 45     : m_type(TYPE_NONE), m_pos(POS_NONE) | 
| 42   CFilterElementHideAttrPos m_pos; | 46   { | 
| 43 | 47   } | 
| 44   CFilterElementHideAttrType m_type; |  | 
| 45 |  | 
| 46   CComBSTR m_bstrAttr; |  | 
| 47   CString m_value; |  | 
| 48 |  | 
| 49   CFilterElementHideAttrSelector(); |  | 
| 50   CFilterElementHideAttrSelector(const CFilterElementHideAttrSelector& filter); |  | 
| 51   ~CFilterElementHideAttrSelector(); |  | 
| 52 }; | 48 }; | 
| 53 | 49 | 
| 54 | 50 | 
| 55 | 51 | 
| 56 // ============================================================================ | 52 // ============================================================================ | 
| 57 // CFilterElementHide | 53 // CFilterElementHide | 
| 58 // ============================================================================ | 54 // ============================================================================ | 
| 59 class CFilterElementHide | 55 class CFilterElementHide | 
| 60 { | 56 { | 
| 61 | 57 | 
| 62 public: | 58 public: | 
| 63 | 59 | 
| 64   enum ETraverserComplexType | 60   enum ETraverserComplexType | 
| 65   { | 61   { | 
| 66     TRAVERSER_TYPE_PARENT, | 62     TRAVERSER_TYPE_PARENT, | 
| 67     TRAVERSER_TYPE_IMMEDIATE, | 63     TRAVERSER_TYPE_IMMEDIATE, | 
| 68     TRAVERSER_TYPE_ERROR | 64     TRAVERSER_TYPE_ERROR | 
| 69   }; | 65   }; | 
| 70 | 66 | 
| 71 | 67   std::wstring m_filterText; | 
| 72   CString m_filterText; |  | 
| 73 | 68 | 
| 74   // For domain specific filters only | 69   // For domain specific filters only | 
| 75   CString m_tagId; | 70   std::wstring m_tagId; | 
| 76   CString m_tagClassName; | 71   std::wstring m_tagClassName; | 
| 77   CString m_tag; | 72   std::wstring m_tag; | 
| 78 | 73 | 
| 79   std::vector<CFilterElementHideAttrSelector> m_attributeSelectors; | 74   std::vector<CFilterElementHideAttrSelector> m_attributeSelectors; | 
| 80   std::shared_ptr<CFilterElementHide> m_predecessor; | 75   std::shared_ptr<CFilterElementHide> m_predecessor; | 
| 81 | 76 | 
| 82   CFilterElementHide(const CString& filterText=""); | 77   CFilterElementHide(const std::wstring& filterText = L""); | 
| 83   CFilterElementHide(const CFilterElementHide& filter); | 78   CFilterElementHide(const CFilterElementHide& filter); | 
| 84   ETraverserComplexType m_type; | 79   ETraverserComplexType m_type; | 
| 85 | 80 | 
| 86   bool IsMatchFilterElementHide(IHTMLElement* pEl) const; | 81   bool IsMatchFilterElementHide(IHTMLElement* pEl) const; | 
| 87 | 82 | 
| 88 }; | 83 }; | 
| 89 | 84 | 
| 90 // ============================================================================ | 85 // ============================================================================ | 
| 91 // CFilter | 86 // CFilter | 
| 92 // ============================================================================ | 87 // ============================================================================ | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 105     filterTypeUnknown = 3 | 100     filterTypeUnknown = 3 | 
| 106   } filterType; | 101   } filterType; | 
| 107 | 102 | 
| 108   enum EFilterType m_filterType; | 103   enum EFilterType m_filterType; | 
| 109   bool m_isMatchCase; | 104   bool m_isMatchCase; | 
| 110   bool m_isFirstParty; | 105   bool m_isFirstParty; | 
| 111   bool m_isThirdParty; | 106   bool m_isThirdParty; | 
| 112   bool m_isFromStart; | 107   bool m_isFromStart; | 
| 113   bool m_isFromEnd; | 108   bool m_isFromEnd; | 
| 114   int m_hitCount; | 109   int m_hitCount; | 
| 115   CString m_filterText; | 110   std::wstring m_filterText; | 
| 116 | 111 | 
| 117   CFilter(const CFilter&); | 112   CFilter(const CFilter&); | 
| 118   CFilter(); | 113   CFilter(); | 
| 119 }; | 114 }; | 
| 120 | 115 | 
| 121 // ============================================================================ | 116 // ============================================================================ | 
| 122 // CPluginFilter | 117 // CPluginFilter | 
| 123 // ============================================================================ | 118 // ============================================================================ | 
| 124 | 119 | 
| 125 class CPluginFilter | 120 class CPluginFilter | 
| 126 { | 121 { | 
| 127 | 122 | 
| 128 private: | 123 private: | 
| 129 | 124 | 
| 130   CString m_dataPath; | 125   std::wstring m_dataPath; | 
| 131 | 126 | 
| 132   // (Tag,Name) -> Filter | 127   // (Tag,Name) -> Filter | 
| 133   typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE
     lementHideTagsNamed; | 128   typedef std::multimap<std::pair<std::wstring, std::wstring>, CFilterElementHid
     e> TFilterElementHideTagsNamed; | 
| 134 | 129 | 
| 135   // Tag -> Filter | 130   // Tag -> Filter | 
| 136   typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags; | 131   typedef std::multimap<std::wstring, CFilterElementHide> TFilterElementHideTags
     ; | 
| 137 | 132 | 
| 138 | 133 | 
| 139   TFilterElementHideTagsNamed m_elementHideTagsId; | 134   TFilterElementHideTagsNamed m_elementHideTagsId; | 
| 140   TFilterElementHideTagsNamed m_elementHideTagsClass; | 135   TFilterElementHideTagsNamed m_elementHideTagsClass; | 
| 141   TFilterElementHideTags m_elementHideTags; | 136   TFilterElementHideTags m_elementHideTags; | 
| 142 | 137 | 
| 143   void ClearFilters(); | 138   void ClearFilters(); | 
| 144 | 139 | 
| 145 public: | 140 public: | 
| 146 | 141 | 
| 147   CPluginFilter(const CString& dataPath = ""); | 142   CPluginFilter(const std::wstring& dataPath = L""); | 
| 148 | 143 | 
| 149   bool LoadHideFilters(std::vector<std::wstring> filters); | 144   bool LoadHideFilters(std::vector<std::wstring> filters); | 
| 150 | 145 | 
| 151   bool AddFilterElementHide(CString filter); | 146   bool AddFilterElementHide(std::wstring filter); | 
| 152 | 147 | 
| 153 | 148 | 
| 154   bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws
     tring& domain, const std::wstring& indent) const; | 149   bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws
     tring& domain, const std::wstring& indent) const; | 
| 155 | 150 | 
| 156 | 151 | 
| 157   bool ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentTy
     pe contentType, const std::wstring& domain, bool addDebug=false) const; | 152   bool ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentTy
     pe contentType, const std::wstring& domain, bool addDebug=false) const; | 
| 158 | 153 | 
| 159   HANDLE hideFiltersLoadedEvent; | 154   HANDLE hideFiltersLoadedEvent; | 
| 160 }; | 155 }; | 
| 161 | 156 | 
| 162 | 157 | 
| 163 #endif // _PLUGIN_FILTER_H_ | 158 #endif // _PLUGIN_FILTER_H_ | 
| OLD | NEW | 
|---|