Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #ifndef _SIMPLE_ADBLOCK_CLIENT_H_ | 1 #ifndef _SIMPLE_ADBLOCK_CLIENT_H_ |
2 #define _SIMPLE_ADBLOCK_CLIENT_H_ | 2 #define _SIMPLE_ADBLOCK_CLIENT_H_ |
3 | 3 |
4 | 4 |
5 #include "PluginTypedef.h" | 5 #include "PluginTypedef.h" |
6 #include "PluginClientBase.h" | 6 #include "PluginClientBase.h" |
7 #include "AdblockPlus.h" | 7 #include "AdblockPlus.h" |
8 | 8 |
9 | 9 |
10 using namespace AdblockPlus; | 10 using namespace AdblockPlus; |
Felix Dahlke
2013/04/03 05:35:27
I'd really prefer to avoid using namespace in head
| |
11 | 11 |
12 class CPluginFilter; | 12 class CPluginFilter; |
13 | 13 |
14 | 14 |
15 class LibFileReader : public AdblockPlus::FileReader | 15 class LibFileReader : public AdblockPlus::FileReader |
16 { | 16 { |
17 public: | 17 public: |
18 std::auto_ptr<std::istream> Read(const std::string& path) const | 18 std::auto_ptr<std::istream> Read(const std::string& path) const |
Felix Dahlke
2013/04/03 05:35:27
Should be declared inline or, preferably, have its
| |
19 { | 19 { |
20 std::ifstream* file = new std::ifstream; | 20 std::ifstream* file = new std::ifstream; |
21 file->open(("lib/" + path).c_str()); | 21 file->open(("lib/" + path).c_str()); |
Wladimir Palant
2013/04/03 12:42:19
Does that assume a particular current work directo
| |
22 return std::auto_ptr<std::istream>(file); | 22 return std::auto_ptr<std::istream>(file); |
23 } | 23 } |
24 }; | 24 }; |
25 | 25 |
26 class CerrErrorCallback : public AdblockPlus::ErrorCallback | 26 class CerrErrorCallback : public AdblockPlus::ErrorCallback |
27 { | 27 { |
28 public: | 28 public: |
29 void operator()(const std::string& message) | 29 void operator()(const std::string& message) |
Felix Dahlke
2013/04/03 05:35:27
Should be declared inline or, preferably, have its
| |
30 { | 30 { |
31 // std::cerr << "Error: " << message << std::endl; | 31 // std::cerr << "Error: " << message << std::endl; |
Wladimir Palant
2013/04/03 12:42:19
I'm not a big fan of code that has been outcomment
| |
32 } | 32 } |
33 }; | 33 }; |
34 | 34 |
Oleksandr
2013/04/03 13:12:17
To be honest, these 2 classes LibFileReader and Ce
| |
35 | 35 |
36 class CAdblockPlusClient : public CPluginClientBase | 36 class CAdblockPlusClient : public CPluginClientBase |
37 { | 37 { |
38 | 38 |
39 private: | 39 private: |
40 | 40 |
41 std::auto_ptr<CPluginFilter> m_filter; | 41 std::auto_ptr<CPluginFilter> m_filter; |
42 std::auto_ptr<LibFileReader> fileReader; | 42 std::auto_ptr<LibFileReader> fileReader; |
43 std::auto_ptr<CerrErrorCallback> errorCallback; | 43 std::auto_ptr<CerrErrorCallback> errorCallback; |
44 std::auto_ptr<AdblockPlus::JsEngine> jsEngine; | 44 std::auto_ptr<AdblockPlus::JsEngine> jsEngine; |
45 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | 45 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
46 | 46 |
47 TFilterFileList m_filterDownloads; | |
48 | |
49 CComAutoCriticalSection m_criticalSectionFilter; | 47 CComAutoCriticalSection m_criticalSectionFilter; |
50 CComAutoCriticalSection m_criticalSectionCache; | 48 CComAutoCriticalSection m_criticalSectionCache; |
51 | 49 |
52 std::map<CString,bool> m_cacheBlockedSources; | 50 std::map<CString,bool> m_cacheBlockedSources; |
53 | 51 |
54 | 52 |
55 // Private constructor used by the singleton pattern | 53 // Private constructor used by the singleton pattern |
56 CAdblockPlusClient(); | 54 CAdblockPlusClient(); |
57 | 55 |
58 public: | 56 public: |
59 | 57 |
60 static CAdblockPlusClient* s_instance; | 58 static CAdblockPlusClient* s_instance; |
61 | 59 |
62 ~CAdblockPlusClient(); | 60 ~CAdblockPlusClient(); |
63 | 61 |
64 static CAdblockPlusClient* GetInstance(); | 62 static CAdblockPlusClient* GetInstance(); |
65 | 63 |
66 bool LoadFilters(); | |
67 | |
68 AdblockPlus::FilterEngine* GetFilterEngine(); | 64 AdblockPlus::FilterEngine* GetFilterEngine(); |
69 | 65 |
70 // Removes the url from the list of whitelisted urls if present | 66 // Removes the url from the list of whitelisted urls if present |
71 // Only called from ui thread | 67 // Only called from ui thread |
72 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add Debug=false); | 68 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add Debug=false); |
73 | 69 |
74 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom ain, const CString& indent); | 70 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom ain, const CString& indent, CPluginFilter* filter); |
75 bool IsUrlWhiteListed(const CString& url); | 71 bool IsUrlWhiteListed(const CString& url); |
76 | 72 |
77 int GetIEVersion(); | 73 int GetIEVersion(); |
78 | 74 |
79 }; | 75 }; |
80 | 76 |
81 #endif // _SIMPLE_ADBLOCK_CLIENT_H_ | 77 #endif // _SIMPLE_ADBLOCK_CLIENT_H_ |
LEFT | RIGHT |