Index: src/FilterEngine.cpp |
=================================================================== |
--- a/src/FilterEngine.cpp |
+++ b/src/FilterEngine.cpp |
@@ -182,44 +182,44 @@ void Subscription::UpdateFilters() |
FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine) |
{ |
#if !FILTER_ENGINE_STUBS |
for (int i = 0; jsSources[i] && jsSources[i + 1]; i += 2) |
jsEngine.Evaluate(jsSources[i + 1], jsSources[i]); |
#endif |
} |
-Filter& FilterEngine::GetFilter(const std::string& text) |
+FilterPtr FilterEngine::GetFilter(const std::string& text) |
{ |
#if FILTER_ENGINE_STUBS |
// Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring |
std::string trimmed(text); |
trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); |
trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), trimmed.end()); |
std::map<std::string, FilterPtr>::const_iterator it = knownFilters.find(trimmed); |
if (it != knownFilters.end()) |
- return *it->second; |
+ return it->second; |
FilterPtr result(new Filter(*this, trimmed)); |
- knownFilters[trimmed] = result->shared_from_this(); |
- return *result; |
+ knownFilters[trimmed] = result; |
+ return result; |
#endif |
} |
-Subscription& FilterEngine::GetSubscription(const std::string& url) |
+SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) |
{ |
#if FILTER_ENGINE_STUBS |
std::map<std::string, SubscriptionPtr>::const_iterator it = knownSubscriptions.find(url); |
if (it != knownSubscriptions.end()) |
- return *it->second; |
+ return it->second; |
SubscriptionPtr result(new Subscription(*this, url)); |
- knownSubscriptions[url] = result->shared_from_this(); |
- return *result; |
+ knownSubscriptions[url] = result; |
+ return result; |
#endif |
} |
const std::vector<FilterPtr>& FilterEngine::GetListedFilters() const |
{ |
#if FILTER_ENGINE_STUBS |
return listedFilters; |
#endif |
@@ -232,38 +232,38 @@ const std::vector<SubscriptionPtr>& Filt |
#endif |
} |
void FilterEngine::FetchAvailableSubscriptions(SubscriptionsCallback callback) |
{ |
#if FILTER_ENGINE_STUBS |
std::vector<SubscriptionPtr> availableSubscriptions; |
- Subscription& subscription1 = GetSubscription("https://easylist-downloads.adblockplus.org/easylist.txt"); |
- subscription1.SetProperty("title", "EasyList"); |
- availableSubscriptions.push_back(subscription1.shared_from_this()); |
+ SubscriptionPtr subscription1 = GetSubscription("https://easylist-downloads.adblockplus.org/easylist.txt"); |
+ subscription1->SetProperty("title", "EasyList"); |
+ availableSubscriptions.push_back(subscription1); |
- Subscription& subscription2 = GetSubscription("https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt"); |
- subscription2.SetProperty("title", "EasyList Germany+EasyList"); |
- availableSubscriptions.push_back(subscription2.shared_from_this()); |
+ SubscriptionPtr subscription2 = GetSubscription("https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt"); |
+ subscription2->SetProperty("title", "EasyList Germany+EasyList"); |
+ availableSubscriptions.push_back(subscription2); |
callback(availableSubscriptions); |
#endif |
} |
AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, |
const std::string& contentType, |
const std::string& documentUrl) |
{ |
#if FILTER_ENGINE_STUBS |
//For test on http://simple-adblock.com/faq/testing-your-adblocker/ |
if (url.find("adbanner.gif") != std::string::npos) |
- return GetFilter("adbanner.gif").shared_from_this(); |
+ return GetFilter("adbanner.gif"); |
else if (url.find("notbanner.gif") != std::string::npos) |
- return GetFilter("@@notbanner.gif").shared_from_this(); |
+ return GetFilter("@@notbanner.gif"); |
else |
return AdblockPlus::FilterPtr(); |
#endif |
} |
std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::string& domain) const |
{ |
#if FILTER_ENGINE_STUBS |