| LEFT | RIGHT | 
|---|
|  | 1 /* | 
|  | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
|  | 3  * Copyright (C) 2006-2015 Eyeo GmbH | 
|  | 4  * | 
|  | 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 | 
|  | 7  * published by the Free Software Foundation. | 
|  | 8  * | 
|  | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
|  | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12  * GNU General Public License for more details. | 
|  | 13  * | 
|  | 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/>. | 
|  | 16  */ | 
|  | 17 | 
| 1 #ifndef _ADBLOCK_PLUS_CLIENT_H_ | 18 #ifndef _ADBLOCK_PLUS_CLIENT_H_ | 
| 2 #define _ADBLOCK_PLUS_CLIENT_H_ | 19 #define _ADBLOCK_PLUS_CLIENT_H_ | 
| 3 | 20 | 
| 4 | 21 #include <MsHTML.h> | 
| 5 #include "PluginTypedef.h" |  | 
| 6 #include "PluginClientBase.h" |  | 
| 7 #include "../shared/Communication.h" | 22 #include "../shared/Communication.h" | 
| 8 #include "../shared/CriticalSection.h" | 23 #include "../shared/CriticalSection.h" | 
| 9 | 24 #include <AdblockPlus/FilterEngine.h> | 
| 10 | 25 | 
| 11 class CPluginFilter; | 26 class CPluginFilter; | 
| 12 | 27 | 
| 13 struct SubscriptionDescription | 28 struct SubscriptionDescription | 
| 14 { | 29 { | 
| 15   std::wstring url; | 30   std::wstring url; | 
| 16   std::wstring title; | 31   std::wstring title; | 
| 17   std::wstring specialization; | 32   std::wstring specialization; | 
| 18   bool listed; | 33   bool listed; | 
| 19 }; | 34 }; | 
| 20 | 35 | 
| 21 class CAdblockPlusClient : public CPluginClientBase | 36 class CAdblockPlusClient | 
| 22 { | 37 { | 
| 23 | 38 | 
| 24 private: | 39 private: | 
| 25 | 40 | 
| 26   std::auto_ptr<CPluginFilter> m_filter; | 41   std::auto_ptr<CPluginFilter> m_filter; | 
| 27 | 42 | 
| 28   CComAutoCriticalSection m_criticalSectionFilter; | 43   CComAutoCriticalSection m_criticalSectionFilter; | 
| 29   CComAutoCriticalSection m_criticalSectionCache; | 44   CComAutoCriticalSection m_criticalSectionCache; | 
|  | 45   static CComAutoCriticalSection s_criticalSectionLocal; | 
| 30 | 46 | 
| 31   std::map<std::wstring, bool> m_cacheBlockedSources; | 47   std::map<std::wstring, bool> m_cacheBlockedSources; | 
| 32 | 48 | 
| 33   std::shared_ptr<Communication::Pipe> enginePipe; | 49   std::shared_ptr<Communication::Pipe> enginePipe; | 
| 34   CriticalSection enginePipeLock; | 50   CriticalSection enginePipeLock; | 
| 35 | 51 | 
| 36 | 52 | 
| 37   // Private constructor used by the singleton pattern | 53   // Private constructor used by the singleton pattern | 
| 38   CAdblockPlusClient(); | 54   CAdblockPlusClient(); | 
| 39 | 55 | 
| 40   bool CallEngine(Communication::OutputBuffer& message, Communication::InputBuff
     er& inputBuffer = Communication::InputBuffer()); | 56   bool CallEngine(Communication::OutputBuffer& message, Communication::InputBuff
     er& inputBuffer = Communication::InputBuffer()); | 
| 41   bool CallEngine(Communication::ProcType proc, Communication::InputBuffer& inpu
     tBuffer = Communication::InputBuffer()); | 57   bool CallEngine(Communication::ProcType proc, Communication::InputBuffer& inpu
     tBuffer = Communication::InputBuffer()); | 
| 42 public: | 58 public: | 
| 43 | 59 | 
| 44   static CAdblockPlusClient* s_instance; | 60   static CAdblockPlusClient* s_instance; | 
| 45 | 61 | 
| 46   ~CAdblockPlusClient(); | 62   ~CAdblockPlusClient(); | 
| 47 | 63 | 
| 48   static CAdblockPlusClient* GetInstance(); | 64   static CAdblockPlusClient* GetInstance(); | 
| 49 | 65 | 
| 50   // Removes the url from the list of whitelisted urls if present | 66   // Removes the url from the list of whitelisted urls if present | 
| 51   // Only called from ui thread | 67   // Only called from ui thread | 
| 52   bool ShouldBlock(const std::wstring& src, int contentType, const std::wstring&
      domain, bool addDebug=false); | 68   bool ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentTy
     pe contentType, const std::wstring& domain, bool addDebug=false); | 
| 53 | 69 | 
| 54   bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws
     tring& domain, const std::wstring& indent, CPluginFilter* filter); | 70   bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws
     tring& domain, const std::wstring& indent, CPluginFilter* filter); | 
| 55   bool IsWhitelistedUrl(const std::wstring& url, const std::vector<std::string>&
      frameHierarchy = std::vector<std::string>()); | 71   bool IsWhitelistedUrl(const std::wstring& url, const std::vector<std::string>&
      frameHierarchy = std::vector<std::string>()); | 
|  | 72   std::string GetWhitelistingFilter(const std::wstring& url, const std::vector<s
     td::string>& frameHierarchy = std::vector<std::string>()); | 
| 56   bool IsElemhideWhitelistedOnDomain(const std::wstring& url, const std::vector<
     std::string>& frameHierarchy = std::vector<std::string>()); | 73   bool IsElemhideWhitelistedOnDomain(const std::wstring& url, const std::vector<
     std::string>& frameHierarchy = std::vector<std::string>()); | 
| 57 | 74 | 
| 58   bool Matches(const std::wstring& url, const std::wstring& contentType, const s
     td::wstring& domain); | 75   bool Matches(const std::wstring& url, AdblockPlus::FilterEngine::ContentType c
     ontentType, const std::wstring& domain); | 
| 59   std::vector<std::wstring> GetElementHidingSelectors(const std::wstring& domain
     ); | 76   std::vector<std::wstring> GetElementHidingSelectors(const std::wstring& domain
     ); | 
| 60   std::vector<SubscriptionDescription> FetchAvailableSubscriptions(); | 77   std::vector<SubscriptionDescription> FetchAvailableSubscriptions(); | 
| 61   std::vector<SubscriptionDescription> GetListedSubscriptions(); | 78   std::vector<SubscriptionDescription> GetListedSubscriptions(); | 
| 62   bool IsAcceptableAdsEnabled(); | 79   bool IsAcceptableAdsEnabled(); | 
| 63   void SetSubscription(const std::wstring& url); | 80   void SetSubscription(const std::wstring& url); | 
| 64   void AddSubscription(const std::wstring& url); | 81   void AddSubscription(const std::wstring& url); | 
| 65   void RemoveSubscription(const std::wstring& url); | 82   void RemoveSubscription(const std::wstring& url); | 
| 66   void UpdateAllSubscriptions(); | 83   void UpdateAllSubscriptions(); | 
| 67   std::vector<std::wstring> GetExceptionDomains(); | 84   std::vector<std::wstring> GetExceptionDomains(); | 
| 68   void AddFilter(const std::wstring& text); | 85   void AddFilter(const std::wstring& text); | 
| 69   void RemoveFilter(const std::wstring& text); | 86   void RemoveFilter(const std::wstring& text); | 
|  | 87   void RemoveFilter(const std::string& text); | 
| 70   void SetPref(const std::wstring& name, const std::wstring& value); | 88   void SetPref(const std::wstring& name, const std::wstring& value); | 
| 71   void SetPref(const std::wstring& name, const int64_t& value); | 89   void SetPref(const std::wstring& name, const int64_t& value); | 
| 72   void SetPref(const std::wstring& name, bool value); | 90   void SetPref(const std::wstring& name, bool value); | 
| 73   std::wstring GetPref(const std::wstring& name, const std::wstring& defaultValu
     e = L""); | 91   std::wstring GetPref(const std::wstring& name, const std::wstring& defaultValu
     e = L""); | 
| 74   std::wstring GetPref(const std::wstring& name, const wchar_t* defaultValue); | 92   std::wstring GetPref(const std::wstring& name, const wchar_t* defaultValue); | 
| 75   bool GetPref(const std::wstring& name, bool defaultValue = false); | 93   bool GetPref(const std::wstring& name, bool defaultValue = false); | 
| 76   int64_t GetPref(const std::wstring& name, int64_t defaultValue = 0); | 94   int64_t GetPref(const std::wstring& name, int64_t defaultValue = 0); | 
| 77   void CheckForUpdates(HWND callbackWindow); | 95   void CheckForUpdates(HWND callbackWindow); | 
| 78   std::wstring GetAppLocale(); |  | 
| 79   std::wstring GetDocumentationLink(); | 96   std::wstring GetDocumentationLink(); | 
| 80   bool TogglePluginEnabled(); | 97   bool TogglePluginEnabled(); | 
| 81   std::wstring GetHostFromUrl(const std::wstring& url); | 98   std::wstring GetHostFromUrl(const std::wstring& url); | 
| 82   int CompareVersions(const std::wstring& v1, const std::wstring& v2); | 99   int CompareVersions(const std::wstring& v1, const std::wstring& v2); | 
| 83 | 100 | 
| 84   bool IsFirstRun(); | 101   bool IsFirstRun(); | 
| 85 }; | 102 }; | 
| 86 | 103 | 
|  | 104 typedef CAdblockPlusClient CPluginClient; | 
|  | 105 | 
| 87 #endif // _ADBLOCK_PLUS_CLIENT_H_ | 106 #endif // _ADBLOCK_PLUS_CLIENT_H_ | 
| LEFT | RIGHT | 
|---|