Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: Shared/AdblockPlusClient.h

Issue 9998007: Initial libadblockplus integration (Closed)
Patch Set: Created April 1, 2013, 9:55 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Shared/AdblockPlusClient.h
===================================================================
--- a/Shared/AdblockPlusClient.h
+++ b/Shared/AdblockPlusClient.h
@@ -4,17 +4,45 @@
#include "PluginTypedef.h"
#include "PluginClientBase.h"
+#include "AdblockPlus.h"
+using namespace AdblockPlus;
Felix Dahlke 2013/04/03 05:35:27 I'd really prefer to avoid using namespace in head
+
class CPluginFilter;
+class LibFileReader : public AdblockPlus::FileReader
+{
+public:
+ 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
+ {
+ std::ifstream* file = new std::ifstream;
+ file->open(("lib/" + path).c_str());
Wladimir Palant 2013/04/03 12:42:19 Does that assume a particular current work directo
+ return std::auto_ptr<std::istream>(file);
+ }
+};
+
+class CerrErrorCallback : public AdblockPlus::ErrorCallback
+{
+public:
+ void operator()(const std::string& message)
Felix Dahlke 2013/04/03 05:35:27 Should be declared inline or, preferably, have its
+ {
+// 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
+ }
+};
+
Oleksandr 2013/04/03 13:12:17 To be honest, these 2 classes LibFileReader and Ce
+
class CAdblockPlusClient : public CPluginClientBase
{
private:
std::auto_ptr<CPluginFilter> m_filter;
+ std::auto_ptr<LibFileReader> fileReader;
+ std::auto_ptr<CerrErrorCallback> errorCallback;
+ std::auto_ptr<AdblockPlus::JsEngine> jsEngine;
+ std::auto_ptr<AdblockPlus::FilterEngine> filterEngine;
TFilterFileList m_filterDownloads;
@@ -30,14 +58,14 @@
public:
static CAdblockPlusClient* s_instance;
+
~CAdblockPlusClient();
static CAdblockPlusClient* GetInstance();
- // Read the filters from the persistent storage and make them ready for use
- void ReadFilters();
- void RequestFilterDownload(const CString& filter, const CString& filterPath);
- bool DownloadFirstMissingFilter();
+ bool LoadFilters();
+
+ AdblockPlus::FilterEngine* GetFilterEngine();
// Removes the url from the list of whitelisted urls if present
// Only called from ui thread
@@ -47,6 +75,7 @@
bool IsUrlWhiteListed(const CString& url);
int GetIEVersion();
+
};
#endif // _SIMPLE_ADBLOCK_CLIENT_H_

Powered by Google App Engine
This is Rietveld