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