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

Unified Diff: src/FilterEngine.cpp

Issue 9987009: Interface for the libadblockplus API (Closed)
Patch Set: Renamed match method, added tests for the stubs Created March 26, 2013, 3:39 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
« no previous file with comments | « libadblockplus.gyp ('k') | test/FilterEngineStubs.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/FilterEngine.cpp
@@ -0,0 +1,58 @@
+#include <AdblockPlus.h>
+
+using namespace AdblockPlus;
+
+Subscription::Subscription(const std::string& title, const std::string& url)
+ : title(title), url(url)
+{
+}
+
+FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine)
+{
+}
+
+void FilterEngine::AddSubscription(Subscription subscription)
+{
+ subscriptions.push_back(subscription);
+}
+
+void FilterEngine::RemoveSubscription(const Subscription& subscription)
+{
+ for (std::vector<Subscription>::iterator it = subscriptions.begin();
+ it != subscriptions.end();)
+ if (it->url == subscription.url)
+ it = subscriptions.erase(it);
+ else
+ it++;
+}
+
+const std::vector<Subscription>& FilterEngine::GetSubscriptions() const
+{
+ return subscriptions;
+}
+
+void FilterEngine::UpdateSubscriptionFilters(const Subscription& subscription)
+{
+}
+
+std::vector<Subscription> FilterEngine::FetchAvailableSubscriptions()
+{
+ std::vector<Subscription> availableSubscriptions;
+ availableSubscriptions.push_back(Subscription("EasyList", "https://easylist-downloads.adblockplus.org/easylist.txt"));
+ availableSubscriptions.push_back(Subscription("EasyList Germany+EasyList", "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt"));
+ return availableSubscriptions;
+}
+
+bool FilterEngine::MatchesFilters(const std::string& url,
+ const std::string& contentType) const
+{
+ return subscriptions.size() && url.length() % 2;
+}
+
+std::vector<std::string> FilterEngine::GetElementHidingRules() const
+{
+ std::vector<std::string> hidingRules;
+ hidingRules.push_back("###ad");
+ hidingRules.push_back("##.ad");
+ return hidingRules;
+}
« no previous file with comments | « libadblockplus.gyp ('k') | test/FilterEngineStubs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld