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; |
+} |