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

Unified Diff: src/FilterEngine.cpp

Issue 10171027: Compile subscriptions.xml into the libadblockplus build and make itusable (Closed)
Patch Set: Created April 19, 2013, 7:59 a.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
« convert_js.py ('K') | « shell/src/SubscriptionsCommand.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -324,60 +324,65 @@ SubscriptionPtr FilterEngine::GetSubscri
#else
JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
JsValueList params;
params.push_back(jsEngine->NewValue(url));
return SubscriptionPtr(new Subscription(func->Call(params)));
#endif
}
-const std::vector<FilterPtr> FilterEngine::GetListedFilters() const
+std::vector<FilterPtr> FilterEngine::GetListedFilters() const
{
#if FILTER_ENGINE_STUBS
return listedFilters;
#else
JsValuePtr func = jsEngine->Evaluate("API.getListedFilters");
JsValueList values = func->Call()->AsList();
std::vector<FilterPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(FilterPtr(new Filter(*it)));
return result;
#endif
}
-const std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
+std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
{
#if FILTER_ENGINE_STUBS
return listedSubscriptions;
#else
JsValuePtr func = jsEngine->Evaluate("API.getListedSubscriptions");
JsValueList values = func->Call()->AsList();
std::vector<SubscriptionPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(SubscriptionPtr(new Subscription(*it)));
return result;
#endif
}
-void FilterEngine::FetchAvailableSubscriptions(SubscriptionsCallback callback)
+std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const
{
#if FILTER_ENGINE_STUBS
Felix Dahlke 2013/04/30 08:59:17 What's with this diff? FILTER_ENGINE_STUBS has bee
Wladimir Palant 2013/04/30 09:35:49 This diff is rather old as well, check the issue d
std::vector<SubscriptionPtr> availableSubscriptions;
SubscriptionPtr subscription1 = GetSubscription("https://easylist-downloads.adblockplus.org/easylist.txt");
subscription1->SetProperty("title", "EasyList");
availableSubscriptions.push_back(subscription1);
SubscriptionPtr subscription2 = GetSubscription("https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt");
subscription2->SetProperty("title", "EasyList Germany+EasyList");
availableSubscriptions.push_back(subscription2);
callback(availableSubscriptions);
#else
- // TODO!
+ JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
+ JsValueList values = func->Call()->AsList();
+ std::vector<SubscriptionPtr> result;
+ for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
+ result.push_back(SubscriptionPtr(new Subscription(*it)));
+ return result;
#endif
}
AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url,
const std::string& contentType,
const std::string& documentUrl)
{
#if FILTER_ENGINE_STUBS
« convert_js.py ('K') | « shell/src/SubscriptionsCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld