OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 { | 131 { |
132 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt
ring(); | 132 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt
ring(); |
133 } | 133 } |
134 | 134 |
135 FilterEngine::FilterEngine(JsEnginePtr jsEngine) : jsEngine(jsEngine) | 135 FilterEngine::FilterEngine(JsEnginePtr jsEngine) : jsEngine(jsEngine) |
136 { | 136 { |
137 for (int i = 0; !jsSources[i].empty(); i += 2) | 137 for (int i = 0; !jsSources[i].empty(); i += 2) |
138 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); | 138 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); |
139 } | 139 } |
140 | 140 |
| 141 bool FilterEngine::IsInitialized() const |
| 142 { |
| 143 return jsEngine->Evaluate("_abpInitialized")->AsBool(); |
| 144 } |
| 145 |
141 FilterPtr FilterEngine::GetFilter(const std::string& text) | 146 FilterPtr FilterEngine::GetFilter(const std::string& text) |
142 { | 147 { |
143 JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); | 148 JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); |
144 JsValueList params; | 149 JsValueList params; |
145 params.push_back(jsEngine->NewValue(text)); | 150 params.push_back(jsEngine->NewValue(text)); |
146 return FilterPtr(new Filter(func->Call(params))); | 151 return FilterPtr(new Filter(func->Call(params))); |
147 } | 152 } |
148 | 153 |
149 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) | 154 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) |
150 { | 155 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 { | 209 { |
205 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 210 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); |
206 JsValueList params; | 211 JsValueList params; |
207 params.push_back(jsEngine->NewValue(domain)); | 212 params.push_back(jsEngine->NewValue(domain)); |
208 JsValueList result = func->Call(params)->AsList(); | 213 JsValueList result = func->Call(params)->AsList(); |
209 std::vector<std::string> selectors; | 214 std::vector<std::string> selectors; |
210 for (JsValueList::iterator it = result.begin(); it != result.end(); ++it) | 215 for (JsValueList::iterator it = result.begin(); it != result.end(); ++it) |
211 selectors.push_back((*it)->AsString()); | 216 selectors.push_back((*it)->AsString()); |
212 return selectors; | 217 return selectors; |
213 } | 218 } |
OLD | NEW |