Left: | ||
Right: |
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 | 122 |
123 bool Subscription::IsUpdating() | 123 bool Subscription::IsUpdating() |
124 { | 124 { |
125 JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating"); | 125 JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating"); |
126 JsValueList params; | 126 JsValueList params; |
127 params.push_back(shared_from_this()); | 127 params.push_back(shared_from_this()); |
128 JsValuePtr result = func->Call(params); | 128 JsValuePtr result = func->Call(params); |
129 return result->AsBool(); | 129 return result->AsBool(); |
130 } | 130 } |
131 | 131 |
132 bool Subscription::IsAA() | |
133 { | |
134 JsContext context(jsEngine); | |
135 return jsEngine->Evaluate("API.isAASubscription")->Call(*shared_from_this())-> AsBool(); | |
136 } | |
137 | |
132 bool Subscription::operator==(const Subscription& subscription) const | 138 bool Subscription::operator==(const Subscription& subscription) const |
133 { | 139 { |
134 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring(); | 140 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt ring(); |
135 } | 141 } |
136 | 142 |
137 FilterEngine::FilterEngine(JsEnginePtr jsEngine, | 143 FilterEngine::FilterEngine(JsEnginePtr jsEngine, |
138 const FilterEngine::Prefs& preconfiguredPrefs) | 144 const FilterEngine::Prefs& preconfiguredPrefs) |
139 : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) | 145 : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) |
140 { | 146 { |
141 jsEngine->SetEventCallback("_init", std::bind(&FilterEngine::InitDone, | 147 jsEngine->SetEventCallback("_init", std::bind(&FilterEngine::InitDone, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const | 270 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const |
265 { | 271 { |
266 JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); | 272 JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); |
267 JsValueList values = func->Call()->AsList(); | 273 JsValueList values = func->Call()->AsList(); |
268 std::vector<SubscriptionPtr> result; | 274 std::vector<SubscriptionPtr> result; |
269 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 275 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
270 result.push_back(SubscriptionPtr(new Subscription(std::move(**it)))); | 276 result.push_back(SubscriptionPtr(new Subscription(std::move(**it)))); |
271 return result; | 277 return result; |
272 } | 278 } |
273 | 279 |
280 void FilterEngine::SetAAEnabled(bool enabled) | |
281 { | |
282 jsEngine->Evaluate("API.setAASubscriptionEnabled")->Call(*jsEngine->NewValue(e nabled)); | |
Eric
2016/12/05 14:40:58
Why is there a context instantiated at line 134 bu
sergei
2017/03/17 15:55:25
JsContext context(jsEngine); is removed on line 13
| |
283 } | |
284 | |
285 bool FilterEngine::IsAAEnabled() const | |
286 { | |
287 return jsEngine->Evaluate("API.isAASubscriptionEnabled()")->AsBool(); | |
288 } | |
289 | |
290 std::string FilterEngine::GetAAURL() const | |
291 { | |
292 return GetPref("subscriptions_exceptionsurl")->AsString(); | |
293 } | |
294 | |
274 void FilterEngine::ShowNextNotification(const std::string& url) | 295 void FilterEngine::ShowNextNotification(const std::string& url) |
275 { | 296 { |
276 JsValuePtr func = jsEngine->Evaluate("API.showNextNotification"); | 297 JsValuePtr func = jsEngine->Evaluate("API.showNextNotification"); |
277 JsValueList params; | 298 JsValueList params; |
278 if (!url.empty()) | 299 if (!url.empty()) |
279 { | 300 { |
280 params.push_back(jsEngine->NewValue(url)); | 301 params.push_back(jsEngine->NewValue(url)); |
281 } | 302 } |
282 func->Call(params); | 303 func->Call(params); |
283 } | 304 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); | 527 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); |
507 if (filter) | 528 if (filter) |
508 { | 529 { |
509 return filter; | 530 return filter; |
510 } | 531 } |
511 currentUrl = parentUrl; | 532 currentUrl = parentUrl; |
512 } | 533 } |
513 while (urlIterator != documentUrls.end()); | 534 while (urlIterator != documentUrls.end()); |
514 return FilterPtr(); | 535 return FilterPtr(); |
515 } | 536 } |
OLD | NEW |