OLD | NEW |
(Empty) | |
| 1 #include <AdblockPlus.h> |
| 2 |
| 3 using namespace AdblockPlus; |
| 4 |
| 5 Subscription::Subscription(const std::string& title, const std::string& url) |
| 6 : title(title), url(url) |
| 7 { |
| 8 } |
| 9 |
| 10 FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine) |
| 11 { |
| 12 } |
| 13 |
| 14 void FilterEngine::AddSubscription(Subscription subscription) |
| 15 { |
| 16 subscriptions.push_back(subscription); |
| 17 } |
| 18 |
| 19 void FilterEngine::RemoveSubscription(const Subscription& subscription) |
| 20 { |
| 21 for (std::vector<Subscription>::iterator it = subscriptions.begin(); |
| 22 it != subscriptions.end();) |
| 23 if (it->url == subscription.url) |
| 24 it = subscriptions.erase(it); |
| 25 else |
| 26 it++; |
| 27 } |
| 28 |
| 29 const std::vector<Subscription>& FilterEngine::GetSubscriptions() const |
| 30 { |
| 31 return subscriptions; |
| 32 } |
| 33 |
| 34 void FilterEngine::UpdateSubscriptionFilters(const Subscription& subscription) |
| 35 { |
| 36 } |
| 37 |
| 38 std::vector<Subscription> FilterEngine::FetchAvailableSubscriptions() |
| 39 { |
| 40 std::vector<Subscription> availableSubscriptions; |
| 41 availableSubscriptions.push_back(Subscription("EasyList", "https://easylist-do
wnloads.adblockplus.org/easylist.txt")); |
| 42 availableSubscriptions.push_back(Subscription("EasyList Germany+EasyList", "ht
tps://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt")); |
| 43 return availableSubscriptions; |
| 44 } |
| 45 |
| 46 bool FilterEngine::MatchesFilters(const std::string& url, |
| 47 const std::string& contentType) const |
| 48 { |
| 49 return subscriptions.size() && url.length() % 2; |
| 50 } |
| 51 |
| 52 std::vector<std::string> FilterEngine::GetElementHidingRules() const |
| 53 { |
| 54 std::vector<std::string> hidingRules; |
| 55 hidingRules.push_back("###ad"); |
| 56 hidingRules.push_back("##.ad"); |
| 57 return hidingRules; |
| 58 } |
OLD | NEW |