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-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 | 267 |
268 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, | 268 AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url, |
269 ContentType contentType, | 269 ContentType contentType, |
270 const std::vector<std::string>& documentUrls) const | 270 const std::vector<std::string>& documentUrls) const |
271 { | 271 { |
272 if (documentUrls.empty()) | 272 if (documentUrls.empty()) |
273 return CheckFilterMatch(url, contentType, ""); | 273 return CheckFilterMatch(url, contentType, ""); |
274 | 274 |
275 std::string lastDocumentUrl = documentUrls.front(); | 275 std::string lastDocumentUrl = documentUrls.front(); |
276 for (std::vector<std::string>::const_iterator it = documentUrls.begin(); | 276 for (std::vector<std::string>::const_iterator it = documentUrls.begin(); |
277 it != documentUrls.end(); it++) { | 277 it != documentUrls.end(); ++it) |
278 const std::string documentUrl = *it; | 278 { |
279 AdblockPlus::FilterPtr match = CheckFilterMatch(documentUrl, | 279 lastDocumentUrl = *it; |
280 CONTENT_TYPE_DOCUMENT, | 280 AdblockPlus::FilterPtr match = CheckFilterMatch(url, contentType, |
281 lastDocumentUrl); | 281 lastDocumentUrl); |
Oleksandr
2014/11/13 13:32:18
I would add a comment before CheckFilterMatch some
sergei
2014/11/13 13:58:13
added
| |
282 if (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) | 282 if (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) |
283 return match; | 283 return match; |
284 lastDocumentUrl = documentUrl; | 284 // We need to start from the same url for the filters like |
285 // @@||example.org^$document, because "document the page itself", so | |
286 // we whitelist the everything which is requested by the page example.org. | |
Oleksandr
2014/11/13 13:32:18
This comment is confusing, I would remove it.
sergei
2014/11/13 13:58:13
See the updated version. It says ''parent'' but we
| |
287 for (std::vector<std::string>::const_iterator ii = it; | |
288 ii != documentUrls.end(); ++ii) | |
289 { | |
290 const std::string& documentUrl = *ii; | |
291 AdblockPlus::FilterPtr match = CheckFilterMatch(documentUrl, | |
292 CONTENT_TYPE_DOCUMENT, lastDocumentUrl); | |
Oleksandr
2014/11/13 13:32:18
Before this CheckFilterMatch I'll add a comment li
sergei
2014/11/13 13:58:13
add before the for loop
| |
293 if (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) | |
294 return match; | |
295 } | |
285 } | 296 } |
286 | 297 |
287 return CheckFilterMatch(url, contentType, lastDocumentUrl); | 298 return CheckFilterMatch(url, contentType, lastDocumentUrl); |
288 } | 299 } |
289 | 300 |
290 AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, | 301 AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, |
291 ContentType contentType, | 302 ContentType contentType, |
292 const std::string& documentUrl) const | 303 const std::string& documentUrl) const |
293 { | 304 { |
294 JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch"); | 305 JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch"); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 } | 414 } |
404 | 415 |
405 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) | 416 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) |
406 { | 417 { |
407 JsValueList params; | 418 JsValueList params; |
408 params.push_back(jsEngine->NewValue(v1)); | 419 params.push_back(jsEngine->NewValue(v1)); |
409 params.push_back(jsEngine->NewValue(v2)); | 420 params.push_back(jsEngine->NewValue(v2)); |
410 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); | 421 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); |
411 return func->Call(params)->AsInt(); | 422 return func->Call(params)->AsInt(); |
412 } | 423 } |
OLD | NEW |