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

Delta Between Two Patch Sets: src/FilterEngine.cpp

Issue 9987009: Interface for the libadblockplus API (Closed)
Left Patch Set: Rename to FilterEngine, add a dummy implementation Created March 26, 2013, 1:50 p.m.
Right Patch Set: Reduce redundant redundancy Created March 27, 2013, 6:45 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 2
3 using namespace AdblockPlus; 3 using namespace AdblockPlus;
4 4
5 Subscription::Subscription(const std::string& url, const std::string& title)
6 : url(url), title(title)
7 {
8 }
9
5 FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine) 10 FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine)
6 { 11 {
12 // TODO: Load ABP:
13 // jsEngine.Load("adblockplus_compat.js");
14 // jsEngine.Load("adblockplus.js");
7 } 15 }
8 16
9 void FilterEngine::AddSubscription(Subscription subscription) 17 void FilterEngine::AddSubscription(Subscription subscription)
10 { 18 {
19 subscriptions.push_back(subscription);
11 } 20 }
12 21
13 void FilterEngine::RemoveSubscription(const Subscription& subscription) 22 void FilterEngine::RemoveSubscription(const Subscription& subscription)
14 { 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++;
15 } 30 }
16 31
17 std::vector<Subscription> FilterEngine::GetSubscriptions() 32 const Subscription* FilterEngine::FindSubscription(const std::string& url) const
18 { 33 {
19 return std::vector<Subscription>(); 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;
20 } 44 }
21 45
22 void FilterEngine::UpdateSubscriptionFilters(const Subscription& subscription) 46 void FilterEngine::UpdateSubscriptionFilters(const Subscription& subscription)
23 { 47 {
24 } 48 }
25 49
26 std::vector<Subscription> FilterEngine::FetchSubscriptionList() 50 std::vector<Subscription> FilterEngine::FetchAvailableSubscriptions()
27 { 51 {
28 return std::vector<Subscription>(); 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;
29 } 56 }
30 57
31 bool FilterEngine::FiltersMatch(const std::string& url, 58 bool FilterEngine::Matches(const std::string& url,
32 const std::string& contentType) const 59 const std::string& contentType) const
33 { 60 {
Oleksandr 2013/03/27 08:37:01 I guess it probably won't be an issue on Linux, bu
Felix Dahlke 2013/03/27 08:59:18 That's tricky actually... std::string works fine f
34 return false; 61 return subscriptions.size() && url.length() % 2;
35 } 62 }
36 63
37 std::vector<std::string> FilterEngine::GetElementHidingRules() const 64 std::vector<std::string> FilterEngine::GetElementHidingRules() const
38 { 65 {
39 return std::vector<std::string>(); 66 std::vector<std::string> hidingRules;
67 hidingRules.push_back("###ad");
68 hidingRules.push_back("##.ad");
69 return hidingRules;
40 } 70 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld