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

Side by Side Diff: src/FilterEngine.cpp

Issue 29419623: Issue 5165 - Remove SubscriptionPtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added arg name in declaration Created April 24, 2017, 6:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « shell/src/SubscriptionsCommand.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 { 70 {
71 JsValue func = jsEngine->Evaluate("API.removeFilterFromList"); 71 JsValue func = jsEngine->Evaluate("API.removeFilterFromList");
72 func.Call(*this); 72 func.Call(*this);
73 } 73 }
74 74
75 bool Filter::operator==(const Filter& filter) const 75 bool Filter::operator==(const Filter& filter) const
76 { 76 {
77 return GetProperty("text").AsString() == filter.GetProperty("text").AsString() ; 77 return GetProperty("text").AsString() == filter.GetProperty("text").AsString() ;
78 } 78 }
79 79
80 Subscription::Subscription(const Subscription& src)
81 : JsValue(src)
82 {
83 }
84
85 Subscription::Subscription(Subscription&& src)
86 : JsValue(std::move(src))
87 {
88 }
89
80 Subscription::Subscription(JsValue&& value) 90 Subscription::Subscription(JsValue&& value)
81 : JsValue(std::move(value)) 91 : JsValue(std::move(value))
82 { 92 {
83 if (!IsObject()) 93 if (!IsObject())
84 throw std::runtime_error("JavaScript value is not an object"); 94 throw std::runtime_error("JavaScript value is not an object");
85 } 95 }
86 96
97 Subscription& Subscription::operator=(const Subscription& src)
98 {
99 *this = src;
100 return *this;
101 }
102
87 bool Subscription::IsListed() const 103 bool Subscription::IsListed() const
88 { 104 {
89 JsValue func = jsEngine->Evaluate("API.isListedSubscription"); 105 JsValue func = jsEngine->Evaluate("API.isListedSubscription");
90 return func.Call(*this).AsBool(); 106 return func.Call(*this).AsBool();
91 } 107 }
92 108
93 void Subscription::AddToList() 109 void Subscription::AddToList()
94 { 110 {
95 JsValue func = jsEngine->Evaluate("API.addSubscriptionToList"); 111 JsValue func = jsEngine->Evaluate("API.addSubscriptionToList");
96 func.Call(*this); 112 func.Call(*this);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 { 291 {
276 return firstRun; 292 return firstRun;
277 } 293 }
278 294
279 Filter FilterEngine::GetFilter(const std::string& text) const 295 Filter FilterEngine::GetFilter(const std::string& text) const
280 { 296 {
281 JsValue func = jsEngine->Evaluate("API.getFilterFromText"); 297 JsValue func = jsEngine->Evaluate("API.getFilterFromText");
282 return Filter(func.Call(jsEngine->NewValue(text))); 298 return Filter(func.Call(jsEngine->NewValue(text)));
283 } 299 }
284 300
285 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const 301 Subscription FilterEngine::GetSubscription(const std::string& url) const
286 { 302 {
287 JsValue func = jsEngine->Evaluate("API.getSubscriptionFromUrl"); 303 JsValue func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
288 return SubscriptionPtr(new Subscription(func.Call(jsEngine->NewValue(url)))); 304 return Subscription(func.Call(jsEngine->NewValue(url)));
289 } 305 }
290 306
291 std::vector<Filter> FilterEngine::GetListedFilters() const 307 std::vector<Filter> FilterEngine::GetListedFilters() const
292 { 308 {
293 JsValue func = jsEngine->Evaluate("API.getListedFilters"); 309 JsValue func = jsEngine->Evaluate("API.getListedFilters");
294 JsValueList values = func.Call().AsList(); 310 JsValueList values = func.Call().AsList();
295 std::vector<Filter> result; 311 std::vector<Filter> result;
296 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) 312 for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
297 result.push_back(Filter(std::move(*it))); 313 result.push_back(Filter(std::move(*it)));
298 return result; 314 return result;
299 } 315 }
300 316
301 std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const 317 std::vector<Subscription> FilterEngine::GetListedSubscriptions() const
302 { 318 {
303 JsValue func = jsEngine->Evaluate("API.getListedSubscriptions"); 319 JsValue func = jsEngine->Evaluate("API.getListedSubscriptions");
304 JsValueList values = func.Call().AsList(); 320 JsValueList values = func.Call().AsList();
305 std::vector<SubscriptionPtr> result; 321 std::vector<Subscription> result;
306 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) 322 for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
307 result.push_back(SubscriptionPtr(new Subscription(std::move(*it)))); 323 result.push_back(Subscription(std::move(*it)));
308 return result; 324 return result;
309 } 325 }
310 326
311 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const 327 std::vector<Subscription> FilterEngine::FetchAvailableSubscriptions() const
312 { 328 {
313 JsValue func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); 329 JsValue func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
314 JsValueList values = func.Call().AsList(); 330 JsValueList values = func.Call().AsList();
315 std::vector<SubscriptionPtr> result; 331 std::vector<Subscription> result;
316 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) 332 for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
317 result.push_back(SubscriptionPtr(new Subscription(std::move(*it)))); 333 result.push_back(Subscription(std::move(*it)));
318 return result; 334 return result;
319 } 335 }
320 336
321 void FilterEngine::SetAAEnabled(bool enabled) 337 void FilterEngine::SetAAEnabled(bool enabled)
322 { 338 {
323 jsEngine->Evaluate("API.setAASubscriptionEnabled").Call(jsEngine->NewValue(ena bled)); 339 jsEngine->Evaluate("API.setAASubscriptionEnabled").Call(jsEngine->NewValue(ena bled));
324 } 340 }
325 341
326 bool FilterEngine::IsAAEnabled() const 342 bool FilterEngine::IsAAEnabled() const
327 { 343 {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 589 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
574 if (filter) 590 if (filter)
575 { 591 {
576 return filter; 592 return filter;
577 } 593 }
578 currentUrl = parentUrl; 594 currentUrl = parentUrl;
579 } 595 }
580 while (urlIterator != documentUrls.end()); 596 while (urlIterator != documentUrls.end());
581 return FilterPtr(); 597 return FilterPtr();
582 } 598 }
OLDNEW
« no previous file with comments | « shell/src/SubscriptionsCommand.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld