OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const | 250 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const |
251 { | 251 { |
252 JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); | 252 JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); |
253 JsValueList values = func->Call()->AsList(); | 253 JsValueList values = func->Call()->AsList(); |
254 std::vector<SubscriptionPtr> result; | 254 std::vector<SubscriptionPtr> result; |
255 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 255 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
256 result.push_back(SubscriptionPtr(new Subscription(*it))); | 256 result.push_back(SubscriptionPtr(new Subscription(*it))); |
257 return result; | 257 return result; |
258 } | 258 } |
259 | 259 |
| 260 std::tr1::shared_ptr<Notification> FilterEngine::GetNextNotificationToShow(const
std::string& url /*= std::string()*/) |
| 261 { |
| 262 JsValuePtr func = jsEngine->Evaluate("API.getNextNotificationToShow"); |
| 263 if (!func) |
| 264 { |
| 265 return std::tr1::shared_ptr<Notification>(); |
| 266 } |
| 267 JsValueList params; |
| 268 if (!url.empty()) |
| 269 { |
| 270 params.push_back(jsEngine->NewValue(url)); |
| 271 } |
| 272 return Notification::JsValueToNotification(func->Call(params)); |
| 273 } |
| 274 |
260 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, | 275 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, |
261 ContentType contentType, | 276 ContentType contentType, |
262 const std::string& documentUrl) const | 277 const std::string& documentUrl) const |
263 { | 278 { |
264 std::vector<std::string> documentUrls; | 279 std::vector<std::string> documentUrls; |
265 documentUrls.push_back(documentUrl); | 280 documentUrls.push_back(documentUrl); |
266 return Matches(url, contentType, documentUrls); | 281 return Matches(url, contentType, documentUrls); |
267 } | 282 } |
268 | 283 |
269 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, | 284 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 419 } |
405 | 420 |
406 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) | 421 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) |
407 { | 422 { |
408 JsValueList params; | 423 JsValueList params; |
409 params.push_back(jsEngine->NewValue(v1)); | 424 params.push_back(jsEngine->NewValue(v1)); |
410 params.push_back(jsEngine->NewValue(v2)); | 425 params.push_back(jsEngine->NewValue(v2)); |
411 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); | 426 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); |
412 return func->Call(params)->AsInt(); | 427 return func->Call(params)->AsInt(); |
413 } | 428 } |
OLD | NEW |