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: Call the inherited operator Created April 24, 2017, 8:13 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 static_cast<JsValue&>(*this) = src;
100 return *this;
101 }
102
103 Subscription& Subscription::operator=(Subscription&& src)
104 {
105 static_cast<JsValue&>(*this) = std::move(src);
106 return *this;
107 }
108
87 bool Subscription::IsListed() const 109 bool Subscription::IsListed() const
88 { 110 {
89 JsValue func = jsEngine->Evaluate("API.isListedSubscription"); 111 JsValue func = jsEngine->Evaluate("API.isListedSubscription");
90 return func.Call(*this).AsBool(); 112 return func.Call(*this).AsBool();
91 } 113 }
92 114
93 void Subscription::AddToList() 115 void Subscription::AddToList()
94 { 116 {
95 JsValue func = jsEngine->Evaluate("API.addSubscriptionToList"); 117 JsValue func = jsEngine->Evaluate("API.addSubscriptionToList");
96 func.Call(*this); 118 func.Call(*this);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 { 297 {
276 return firstRun; 298 return firstRun;
277 } 299 }
278 300
279 Filter FilterEngine::GetFilter(const std::string& text) const 301 Filter FilterEngine::GetFilter(const std::string& text) const
280 { 302 {
281 JsValue func = jsEngine->Evaluate("API.getFilterFromText"); 303 JsValue func = jsEngine->Evaluate("API.getFilterFromText");
282 return Filter(func.Call(jsEngine->NewValue(text))); 304 return Filter(func.Call(jsEngine->NewValue(text)));
283 } 305 }
284 306
285 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const 307 Subscription FilterEngine::GetSubscription(const std::string& url) const
286 { 308 {
287 JsValue func = jsEngine->Evaluate("API.getSubscriptionFromUrl"); 309 JsValue func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
288 return SubscriptionPtr(new Subscription(func.Call(jsEngine->NewValue(url)))); 310 return Subscription(func.Call(jsEngine->NewValue(url)));
289 } 311 }
290 312
291 std::vector<Filter> FilterEngine::GetListedFilters() const 313 std::vector<Filter> FilterEngine::GetListedFilters() const
292 { 314 {
293 JsValue func = jsEngine->Evaluate("API.getListedFilters"); 315 JsValue func = jsEngine->Evaluate("API.getListedFilters");
294 JsValueList values = func.Call().AsList(); 316 JsValueList values = func.Call().AsList();
295 std::vector<Filter> result; 317 std::vector<Filter> result;
296 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) 318 for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
297 result.push_back(Filter(std::move(*it))); 319 result.push_back(Filter(std::move(*it)));
298 return result; 320 return result;
299 } 321 }
300 322
301 std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const 323 std::vector<Subscription> FilterEngine::GetListedSubscriptions() const
302 { 324 {
303 JsValue func = jsEngine->Evaluate("API.getListedSubscriptions"); 325 JsValue func = jsEngine->Evaluate("API.getListedSubscriptions");
304 JsValueList values = func.Call().AsList(); 326 JsValueList values = func.Call().AsList();
305 std::vector<SubscriptionPtr> result; 327 std::vector<Subscription> result;
306 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) 328 for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
307 result.push_back(SubscriptionPtr(new Subscription(std::move(*it)))); 329 result.push_back(Subscription(std::move(*it)));
308 return result; 330 return result;
309 } 331 }
310 332
311 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const 333 std::vector<Subscription> FilterEngine::FetchAvailableSubscriptions() const
312 { 334 {
313 JsValue func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); 335 JsValue func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
314 JsValueList values = func.Call().AsList(); 336 JsValueList values = func.Call().AsList();
315 std::vector<SubscriptionPtr> result; 337 std::vector<Subscription> result;
316 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) 338 for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
317 result.push_back(SubscriptionPtr(new Subscription(std::move(*it)))); 339 result.push_back(Subscription(std::move(*it)));
318 return result; 340 return result;
319 } 341 }
320 342
321 void FilterEngine::SetAAEnabled(bool enabled) 343 void FilterEngine::SetAAEnabled(bool enabled)
322 { 344 {
323 jsEngine->Evaluate("API.setAASubscriptionEnabled").Call(jsEngine->NewValue(ena bled)); 345 jsEngine->Evaluate("API.setAASubscriptionEnabled").Call(jsEngine->NewValue(ena bled));
324 } 346 }
325 347
326 bool FilterEngine::IsAAEnabled() const 348 bool FilterEngine::IsAAEnabled() const
327 { 349 {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 595 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
574 if (filter) 596 if (filter)
575 { 597 {
576 return filter; 598 return filter;
577 } 599 }
578 currentUrl = parentUrl; 600 currentUrl = parentUrl;
579 } 601 }
580 while (urlIterator != documentUrls.end()); 602 while (urlIterator != documentUrls.end());
581 return FilterPtr(); 603 return FilterPtr();
582 } 604 }
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