| Left: | ||
| Right: | 
| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 params.push_back(jsEngine->NewValue(url)); | 220 params.push_back(jsEngine->NewValue(url)); | 
| 221 params.push_back(jsEngine->NewValue(contentType)); | 221 params.push_back(jsEngine->NewValue(contentType)); | 
| 222 params.push_back(jsEngine->NewValue(documentUrl)); | 222 params.push_back(jsEngine->NewValue(documentUrl)); | 
| 223 JsValuePtr result = func->Call(params); | 223 JsValuePtr result = func->Call(params); | 
| 224 if (!result->IsNull()) | 224 if (!result->IsNull()) | 
| 225 return FilterPtr(new Filter(result)); | 225 return FilterPtr(new Filter(result)); | 
| 226 else | 226 else | 
| 227 return FilterPtr(); | 227 return FilterPtr(); | 
| 228 } | 228 } | 
| 229 | 229 | 
| 230 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, | |
| 231 const std::string& contentType, | |
| 232 const std::vector<std::string>& documentUrls) const | |
| 233 { | |
| 234 AdblockPlus::FilterPtr match; | |
| 235 for (std::vector<std::string>::const_iterator it = documentUrls.begin(); | |
| 236 it != documentUrls.end(); it++) { | |
| 237 match = Matches(url, contentType, *it); | |
| 238 if (!match || match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) | |
| 239 return match; | |
| 240 } | |
| 
 
Wladimir Palant
2013/10/30 07:39:56
No, this approach is wrong - and it seems that we
 
Felix Dahlke
2013/11/03 03:51:15
I was actually wondering about this after seeing p
 
 | |
| 241 return match; | |
| 242 } | |
| 243 | |
| 230 std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri ng& domain) const | 244 std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri ng& domain) const | 
| 231 { | 245 { | 
| 232 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 246 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 
| 233 JsValueList params; | 247 JsValueList params; | 
| 234 params.push_back(jsEngine->NewValue(domain)); | 248 params.push_back(jsEngine->NewValue(domain)); | 
| 235 JsValueList result = func->Call(params)->AsList(); | 249 JsValueList result = func->Call(params)->AsList(); | 
| 236 std::vector<std::string> selectors; | 250 std::vector<std::string> selectors; | 
| 237 for (JsValueList::iterator it = result.begin(); it != result.end(); ++it) | 251 for (JsValueList::iterator it = result.begin(); it != result.end(); ++it) | 
| 238 selectors.push_back((*it)->AsString()); | 252 selectors.push_back((*it)->AsString()); | 
| 239 return selectors; | 253 return selectors; | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 { | 302 { | 
| 289 jsEngine->RemoveEventCallback("filterChange"); | 303 jsEngine->RemoveEventCallback("filterChange"); | 
| 290 } | 304 } | 
| 291 | 305 | 
| 292 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params) | 306 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params) | 
| 293 { | 307 { | 
| 294 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : ""); | 308 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : ""); | 
| 295 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); | 309 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); | 
| 296 callback(action, item); | 310 callback(action, item); | 
| 297 } | 311 } | 
| OLD | NEW |