LEFT | RIGHT |
1 #ifndef _ADBLOCK_PLUS_CLIENT_H_ | 1 #ifndef _ADBLOCK_PLUS_CLIENT_H_ |
2 #define _ADBLOCK_PLUS_CLIENT_H_ | 2 #define _ADBLOCK_PLUS_CLIENT_H_ |
3 | 3 |
4 | 4 |
5 #include "PluginTypedef.h" | 5 #include "PluginTypedef.h" |
6 #include "PluginClientBase.h" | 6 #include "PluginClientBase.h" |
| 7 #include "../shared/Communication.h" |
7 | 8 |
8 | 9 |
9 class CPluginFilter; | 10 class CPluginFilter; |
10 | 11 |
11 struct SubscriptionDescription | 12 struct SubscriptionDescription |
12 { | 13 { |
13 std::wstring url; | 14 std::wstring url; |
14 std::wstring title; | 15 std::wstring title; |
15 std::wstring specialization; | 16 std::wstring specialization; |
16 bool listed; | 17 bool listed; |
17 }; | 18 }; |
18 | 19 |
19 class CAdblockPlusClient : public CPluginClientBase | 20 class CAdblockPlusClient : public CPluginClientBase |
20 { | 21 { |
21 | 22 |
22 private: | 23 private: |
23 | 24 |
24 std::auto_ptr<CPluginFilter> m_filter; | 25 std::auto_ptr<CPluginFilter> m_filter; |
25 | 26 |
26 CComAutoCriticalSection m_criticalSectionFilter; | 27 CComAutoCriticalSection m_criticalSectionFilter; |
27 CComAutoCriticalSection m_criticalSectionCache; | 28 CComAutoCriticalSection m_criticalSectionCache; |
28 | 29 |
29 std::map<CString,bool> m_cacheBlockedSources; | 30 std::map<CString,bool> m_cacheBlockedSources; |
30 | 31 |
31 | 32 |
32 // Private constructor used by the singleton pattern | 33 // Private constructor used by the singleton pattern |
33 CAdblockPlusClient(); | 34 CAdblockPlusClient(); |
34 | |
35 public: | 35 public: |
36 | 36 |
37 static CAdblockPlusClient* s_instance; | 37 static CAdblockPlusClient* s_instance; |
38 | 38 |
39 ~CAdblockPlusClient(); | 39 ~CAdblockPlusClient(); |
40 | 40 |
41 static CAdblockPlusClient* GetInstance(); | 41 static CAdblockPlusClient* GetInstance(); |
42 | 42 |
43 // Removes the url from the list of whitelisted urls if present | 43 // Removes the url from the list of whitelisted urls if present |
44 // Only called from ui thread | 44 // Only called from ui thread |
45 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add
Debug=false); | 45 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add
Debug=false); |
46 | 46 |
47 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom
ain, const CString& indent, CPluginFilter* filter); | 47 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom
ain, const CString& indent, CPluginFilter* filter); |
48 bool IsWhitelistedUrl(const std::wstring& url); | 48 bool IsWhitelistedUrl(const std::wstring& url); |
49 | 49 |
50 int GetIEVersion(); | 50 int GetIEVersion(); |
51 | 51 |
52 bool Matches(const std::wstring& url, const std::wstring& contentType, const s
td::wstring& domain); | 52 bool Matches(const std::wstring& url, const std::wstring& contentType, const s
td::wstring& domain); |
53 std::vector<std::wstring> GetElementHidingSelectors(const std::wstring& domain
); | 53 std::vector<std::wstring> GetElementHidingSelectors(const std::wstring& domain
); |
54 std::vector<SubscriptionDescription> FetchAvailableSubscriptions(); | 54 std::vector<SubscriptionDescription> FetchAvailableSubscriptions(); |
55 std::vector<SubscriptionDescription> GetListedSubscriptions(); | 55 std::vector<SubscriptionDescription> GetListedSubscriptions(); |
56 void SetSubscription(const std::wstring& url); | 56 void SetSubscription(const std::wstring& url); |
57 void UpdateAllSubscriptions(); | 57 void UpdateAllSubscriptions(); |
58 std::vector<std::wstring> GetExceptionDomains(); | 58 std::vector<std::wstring> GetExceptionDomains(); |
59 void AddFilter(const std::wstring& text); | 59 void AddFilter(const std::wstring& text); |
60 void RemoveFilter(const std::wstring& text); | 60 void RemoveFilter(const std::wstring& text); |
61 void SetPref(const std::wstring& name, const std::wstring& value); | 61 void SetPref(const std::wstring& name, const std::wstring& value); |
62 std::wstring GetPref(const std::wstring& name); | 62 void SetPref(const std::wstring& name, const int64_t& value); |
| 63 void SetPref(const std::wstring& name, bool value); |
| 64 std::wstring GetPref(const std::wstring& name, const std::wstring& defaultValu
e = L""); |
| 65 std::wstring GetPref(const std::wstring& name, const wchar_t* defaultValue); |
| 66 bool GetPref(const std::wstring& name, bool defaultValue = false); |
| 67 int64_t GetPref(const std::wstring& name, int64_t defaultValue = 0); |
63 }; | 68 }; |
64 | 69 |
65 #endif // _ADBLOCK_PLUS_CLIENT_H_ | 70 #endif // _ADBLOCK_PLUS_CLIENT_H_ |
LEFT | RIGHT |