Left: | ||
Right: |
OLD | NEW |
---|---|
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 | 8 |
8 | 9 |
10 using namespace AdblockPlus; | |
Felix Dahlke
2013/04/03 05:35:27
I'd really prefer to avoid using namespace in head
| |
11 | |
9 class CPluginFilter; | 12 class CPluginFilter; |
10 | 13 |
11 | 14 |
15 class LibFileReader : public AdblockPlus::FileReader | |
16 { | |
17 public: | |
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 { | |
20 std::ifstream* file = new std::ifstream; | |
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); | |
23 } | |
24 }; | |
25 | |
26 class CerrErrorCallback : public AdblockPlus::ErrorCallback | |
27 { | |
28 public: | |
29 void operator()(const std::string& message) | |
Felix Dahlke
2013/04/03 05:35:27
Should be declared inline or, preferably, have its
| |
30 { | |
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 } | |
33 }; | |
34 | |
Oleksandr
2013/04/03 13:12:17
To be honest, these 2 classes LibFileReader and Ce
| |
35 | |
12 class CAdblockPlusClient : public CPluginClientBase | 36 class CAdblockPlusClient : public CPluginClientBase |
13 { | 37 { |
14 | 38 |
15 private: | 39 private: |
16 | 40 |
17 std::auto_ptr<CPluginFilter> m_filter; | 41 std::auto_ptr<CPluginFilter> m_filter; |
42 std::auto_ptr<LibFileReader> fileReader; | |
43 std::auto_ptr<CerrErrorCallback> errorCallback; | |
44 std::auto_ptr<AdblockPlus::JsEngine> jsEngine; | |
45 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | |
18 | 46 |
19 TFilterFileList m_filterDownloads; | 47 TFilterFileList m_filterDownloads; |
20 | 48 |
21 CComAutoCriticalSection m_criticalSectionFilter; | 49 CComAutoCriticalSection m_criticalSectionFilter; |
22 CComAutoCriticalSection m_criticalSectionCache; | 50 CComAutoCriticalSection m_criticalSectionCache; |
23 | 51 |
24 std::map<CString,bool> m_cacheBlockedSources; | 52 std::map<CString,bool> m_cacheBlockedSources; |
25 | 53 |
26 | 54 |
27 // Private constructor used by the singleton pattern | 55 // Private constructor used by the singleton pattern |
28 CAdblockPlusClient(); | 56 CAdblockPlusClient(); |
29 | 57 |
30 public: | 58 public: |
31 | 59 |
32 static CAdblockPlusClient* s_instance; | 60 static CAdblockPlusClient* s_instance; |
61 | |
33 ~CAdblockPlusClient(); | 62 ~CAdblockPlusClient(); |
34 | 63 |
35 static CAdblockPlusClient* GetInstance(); | 64 static CAdblockPlusClient* GetInstance(); |
36 | 65 |
37 // Read the filters from the persistent storage and make them ready for use | 66 bool LoadFilters(); |
38 void ReadFilters(); | 67 |
39 void RequestFilterDownload(const CString& filter, const CString& filterPath); | 68 AdblockPlus::FilterEngine* GetFilterEngine(); |
40 bool DownloadFirstMissingFilter(); | |
41 | 69 |
42 // Removes the url from the list of whitelisted urls if present | 70 // Removes the url from the list of whitelisted urls if present |
43 // Only called from ui thread | 71 // Only called from ui thread |
44 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add Debug=false); | 72 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add Debug=false); |
45 | 73 |
46 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom ain, const CString& indent); | 74 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom ain, const CString& indent); |
47 bool IsUrlWhiteListed(const CString& url); | 75 bool IsUrlWhiteListed(const CString& url); |
48 | 76 |
49 int GetIEVersion(); | 77 int GetIEVersion(); |
78 | |
50 }; | 79 }; |
51 | 80 |
52 #endif // _SIMPLE_ADBLOCK_CLIENT_H_ | 81 #endif // _SIMPLE_ADBLOCK_CLIENT_H_ |
OLD | NEW |