OLD | NEW |
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 for (const auto& pref : params.preconfiguredPrefs) | 252 for (const auto& pref : params.preconfiguredPrefs) |
253 { | 253 { |
254 preconfiguredPrefsObject.SetProperty(pref.first, pref.second); | 254 preconfiguredPrefsObject.SetProperty(pref.first, pref.second); |
255 } | 255 } |
256 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject); | 256 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject); |
257 // Load adblockplus scripts | 257 // Load adblockplus scripts |
258 for (int i = 0; !jsSources[i].empty(); i += 2) | 258 for (int i = 0; !jsSources[i].empty(); i += 2) |
259 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); | 259 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); |
260 } | 260 } |
261 | 261 |
262 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine, | |
263 const FilterEngine::CreationParameters& params) | |
264 { | |
265 FilterEnginePtr retValue; | |
266 Sync sync; | |
267 CreateAsync(jsEngine, [&retValue, &sync](const FilterEnginePtr& filterEngine) | |
268 { | |
269 retValue = filterEngine; | |
270 sync.Set(); | |
271 }, params); | |
272 sync.Wait(); | |
273 return retValue; | |
274 } | |
275 | |
276 namespace | 262 namespace |
277 { | 263 { |
278 typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap; | 264 typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap; |
279 | 265 |
280 ContentTypeMap CreateContentTypeMap() | 266 ContentTypeMap CreateContentTypeMap() |
281 { | 267 { |
282 ContentTypeMap contentTypes; | 268 ContentTypeMap contentTypes; |
283 contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER"; | 269 contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER"; |
284 contentTypes[FilterEngine::CONTENT_TYPE_SCRIPT] = "SCRIPT"; | 270 contentTypes[FilterEngine::CONTENT_TYPE_SCRIPT] = "SCRIPT"; |
285 contentTypes[FilterEngine::CONTENT_TYPE_IMAGE] = "IMAGE"; | 271 contentTypes[FilterEngine::CONTENT_TYPE_IMAGE] = "IMAGE"; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent
Url); | 591 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent
Url); |
606 if (filter) | 592 if (filter) |
607 { | 593 { |
608 return filter; | 594 return filter; |
609 } | 595 } |
610 currentUrl = parentUrl; | 596 currentUrl = parentUrl; |
611 } | 597 } |
612 while (urlIterator != documentUrls.end()); | 598 while (urlIterator != documentUrls.end()); |
613 return FilterPtr(); | 599 return FilterPtr(); |
614 } | 600 } |
OLD | NEW |